Question

I'm sucessfully exposing a contract-first JAX-WS web service on a Tomcat servlet container with Jax-WS Spring support. I'm having troulbes with xs:idref types though. The original XSD file contains a complex type

  <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>

which xjc correctly compiles to

public class DocumentScopeOptionalTypeReferenceIdentifier {

  @XmlValue
  @XmlIDREF
  protected Object value;

  ...
}

When I deploy the webservice, however, the @XmlIDREF annotation gets ignored and I end up with an xs:anyType in the namespace declaration of the resulting WSDL

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

Clients of the webservice in question report, that they cannot generate Client stubs (using C#) with this anyType present. How would I change that back to xs:idref? Thanks.

Was it helpful?

Solution

Ok, I guess my approach was a little bit too naiv. After doing a bit of research I came to the conclusion that customizing the generated WSDL is not possible. I now switched to a contract first approach and specify a hand-crafted WSDL file manually.

I've read that any WSDL file located under META-INF/wsdl should be picked up automatically by JAX-WS, if it contains a corresponding service and port name. This didn't work for me, so I had to specify the WSDL file explicitely using the wsdlLocation attribute on the @WebService annotation

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

Deploying the webservice on Tomcat was straight forward following the instructions on the Jax-WS community page

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top