0

我成功地在具有 Jax-WS Spring 支持的 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注释被忽略,我最终xs:anyType在生成的 WSDL 的命名空间声明中得到一个

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

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

4

1 回答 1

0

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

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

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

按照Jax-WS 社区页面上的说明,在 Tomcat 上部署 Web 服务非常简单

于 2012-04-23T14:58:06.710 回答