【问题标题】:How to change Jax-WS WSDL @IDREF binding如何更改 Jax-WS WSDL @IDREF 绑定
【发布时间】:2012-04-13 14:22:24
【问题描述】:

我成功地在一个带有 Jax-WS Spring support 的 Tomcat servlet 容器上公开了一个契约优先的 JAX-WS Web 服务。不过,我遇到了xs:idref 类型的麻烦。原始 XSD 文件包含复杂类型

  <xs:complexType name="DocumentScopeOptionalTypeReferenceIdentifier">
    <xs:simpleContent>
      <xs:extension base="DocumentScopeReferenceIdentifierContent">
         ...
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:simpleType name="DocumentScopeReferenceIdentifierContent">
    <xs:restriction base="xs:IDREF">
      <xs:minLength value="1"/>
      <xs:maxLength value="64"/>
    </xs:restriction>
  </xs:simpleType>

哪个xjc正确编译成

public class DocumentScopeOptionalTypeReferenceIdentifier {

  @XmlValue
  @XmlIDREF
  protected Object value;

  ...
}

然而,当我部署 web 服务时,@XmlIDREF 注释被忽略,我最终在生成的 WSDL 的命名空间声明中得到一个 xs:anyType

<xs:complexType name="DocumentScopeOptionalRoleReferenceIdentifier">
<xs:simpleContent>
<xs:extension base="xs:anyType">
...
</xs:extension>
</xs:simpleContent>
</xs:complexType>

有问题的 Web 服务的客户端报告说,他们无法生成存在此 anyType 的客户端存根(使用 C#)。我如何将其改回xs:idref?谢谢。

【问题讨论】:

    标签: web-services jaxb jax-ws spring-ws jax-ws-customization


    【解决方案1】:

    好吧,我想我的方法有点太天真了。在做了一些研究之后,我得出结论,定制生成的 WSDL 是不可能的。我现在切换到合同优先的方法并手动指定一个手工制作的 WSDL 文件。

    我已经读过,位于 META-INF/wsdl 下的任何 WSDL 文件都应该由 JAX-WS 自动拾取,如果它包含相应的服务和端口名称。这对我不起作用,所以我不得不使用 @WebService 注释上的 wsdlLocation 属性明确指定 WSDL 文件

    @WebService(
       targetNamespace = "...", 
       serviceName = "...", 
       portName = "...", 
       wsdlLocation = "/META-INF/wsdl/mywebservice.wsdl"
    )
    public class MyWebService { ... }
    

    按照Jax-WS community page 上的说明直接在 Tomcat 上部署 Web 服务

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-06
      • 1970-01-01
      • 2010-10-20
      • 1970-01-01
      相关资源
      最近更新 更多