【问题标题】:Type not prefixed in runtime generated WSDL with CXF在运行时生成的带有 CXF 的 WSDL 中的类型没有前缀
【发布时间】:2014-04-14 23:06:11
【问题描述】:

我有一个 Java 优先的 Web 服务,与 Spring 集成。服务接口简单:

@WebService
public interface ContactService {

    public void addContact(@WebParam(name="contact") Contact contact);
    public List<Contact> listContact();
    public void removeContact(@WebParam(name="id") Integer id);
}

实现:

@WebService(endpointInterface = "com.foobar.contact.service.ContactService")
@Service
public class ContactServiceImpl implements ContactService {
    // methods
}

型号:

@XmlAccessorType( XmlAccessType.FIELD )
public class Contact {
    private Integer id;
    private String firstname;
    private String lastname;
    private String email;
    private String telephone;
}

如果我使用 Maven 插件cxf-java2ws-plugin,生成的 WSDL 是正确的。但是如果不指定 WSDL,CXF 在运行时生成的那个是行不通的。

比如cxf-java2ws-plugin生成的那个,返回类型正确的加上tns前缀:

<xs:complexType name="listContactResponse">
<xs:sequence>
  <xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="tns:contact"/>
</xs:sequence>

在运行时生成的,contact没有前缀,所以无法解析:

<xsd:complexType name="listContactResponse">
<xsd:sequence>
  <xsd:element maxOccurs="unbounded" minOccurs="0" name="return" type="contact"/>
</xsd:sequence>

两个 WSDL 都包含正确的复杂类型 contact

我如何告诉 CXF/JAX-WS contact 是它在 WSDL 中定义的类型?

【问题讨论】:

    标签: web-services jax-ws cxf


    【解决方案1】:

    查看 xsd,它会使用 wsdl 自动生成:

    schemaLocation="http://<server>:<port>/<app>/<webservice>?xsd=1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多