user215054
user215054

Reputation:

Microsoft webservice and CXF client: JAXB fails to understand "s:schema"

I have ordinary Microsoft webservice and normal CXF of latest version with Java/JDK 1.6, Eclipse etc. When I am running wsdl2java, the JAXB part throws an error "Thrown by JAXB: undefined element declaration 's:schema' "

The part of WSDL which causes it looks like:

<s:element name="GetDepartmentsResponse">
 <s:complexType>
  <s:sequence>
   <s:element minOccurs="0" maxOccurs="1" name="GetDepartmentsResult">
    <s:complexType>
     <s:sequence>
      <s:element ref="s:schema" /> 
      <s:any /> 
     </s:sequence>
    </s:complexType>
   </s:element>
  </s:sequence>
 </s:complexType>
</s:element>

Can I simply remove <s:element ref="s:schema" /> everywhere and keep <s:any/> ? It looks like common obstacle for Java<->Microsoft webservices interoperability. But I can not find any workaround for CXF.

Upvotes: 8

Views: 4726

Answers (2)

Martin Cassidy
Martin Cassidy

Reputation: 736

Personally, I wouldn't suggest modifying your WSDL. The WSDL is defining the contract imposed by the service, and it's not really something you should be changing in your client. If you take a look at the answer here https://stackoverflow.com/a/19126124/1732319 it describes how you can get wsdl2java to deal with s:schema properly.

I'm using the CXF codegen maven plugin in my project and have the following configuration:

<configuration>
    <fork>once</fork>
    <additionalJvmArgs>-Djavax.xml.accessExternalDTD=all -Djavax.xml.accessExternalSchema=all</additionalJvmArgs>
    <sourceRoot>${project.build.directory}/generated-sources</sourceRoot>
    <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>
    <defaultOptions>
        <bindingFiles>
            <bindingFile>http://www.w3.org/2001/XMLSchema.xsd</bindingFile>
            <bindingFile>${basedir}/src/main/resources/customisation.xjb</bindingFile>
        </bindingFiles>
    </defaultOptions>
</configuration>

customisation.xjb is taken from the answer I references above.

Upvotes: 2

Daniel Kulp
Daniel Kulp

Reputation: 14607

Usually you can remove the schema ref. You may need to change the <s:any> to <s:any maxOccurs="2"> or similar to make sure there is room for both the schema element and anything that follows it.

Upvotes: 8

Related Questions