The XPath expression in my external binding files can\'t target the elements in my XML schemas which are imported into my WSDL.
Everything runs if I do inline bindin
Adding this section to my JAXB configuration helped to do away with a similar error:
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
<jaxws:enableAsyncMapping>false</jaxws:enableAsyncMapping>
</jaxws:bindings>
Complete configuration:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
<jaxws:enableAsyncMapping>false</jaxws:enableAsyncMapping>
</jaxws:bindings>
<jaxb:bindings schemaLocation="ContactService.wsdl" node="/wsdl:definitions/wsdl:types/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="za.org.kuali.kfs.sys.integration.iapi.contactservice"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
Credits:
For new people, you can simply use two binding files, one applied to wsdl and other applied to the schema by using the -b option of wsdl2java cxf code generation class accepts multiple binding files:
<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
<arg value="-d"/>
<arg value="${src}"/>
<arg value="-b"/>
<arg value="${wsdl.home}\jaxws-bindings.xml"/>
<arg value="-b"/>
<arg value="${wsdl.home}\jaxb-bindings.xml"/>
<arg value="${wsdl.home}\YOUR_WSDL.wsdl"/>
<classpath>
<path refid="cxf.classpath"/>
</classpath>
</java>
Content of file 'jaxws-bindings.xml':
<jaxws:bindings wsdlLocation="YOUR_WSDL.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>
Content of 'jaxb-bindings.xml':
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="2.0">
<jaxb:bindings schemaLocation="ManagePartyCustomerDataManagement_PARTY_G7-IOP_In_1.0.xsd">
<jaxb:bindings node="//xsd:element[@name='eventDate']">
<jaxb:javaType name="java.util.Date"
parseMethod="com.sofrecom.gaia.ebs.provider.utils.jaxb.StringDateAdapter.parseDate"
printMethod="com.sofrecom.gaia.ebs.provider.utils.jaxb.StringDateAdapter.printDate" />
</jaxb:bindings>
you should use it like:
<jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://duke.example.org']">
<jaxb:schemaBindings>
<jaxb:package name="fromwsdl.server"/>
</jaxb:schemaBindings>
</jaxws:bindings>
Be careful with the namespaces
It all is explained here: https://jax-ws.java.net/nonav/2.1.2/docs/customizations.html
You could compile each of the XML schemas to Java classes individually. Then you can leverage episode files so that the generated classes can be used when you compile schemas that import that XML schema.
Below is an example of how you produce an episode file.
xjc -b binding1.xml -episode common.episode common.xsd
And below is an example of how you consume and episode file. The episode file is just a JAXB external bindings file and therefore is specified using the -b
flag.
xjc -d out main.xsd -extension -b common.episode
For More Information