Compiling a common schema used by 2 WSDLs using XMLBeans

I have the following directory structure

Root CommonSchema 1.xsd 2.xsd Service1 XSD 3.xsd ( importing 1 and 2 xsd ) WSDL A.wsdl ( importing 3.xsd ) Service2 XSD 4.xsd ( importing 1 and 2 xsd ) WSDL B.wsdl ( importing 4.xsd ) 

I am trying to generate a source and compile them into a single jar using XMLBeans + CXF. The CommonSchema folder has schemas shared by Service1 and 2.

When I try to generate the source source, it seems that source 1 and 2 xsd has a name conflict, which can be seen below:

First generation WSDL

enter image description here

Second Generation WSDL

enter image description here

Any idea on how I can compile this general outline?

Here is my Ant Script:

 <target name="cxfWSDLToJava"> <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true"> <arg value="-databinding"/> <arg value="xmlbeans"/> <arg value="-client"/> <arg value="-d"/> <arg value="cxfsrc"/> <arg value="D:\Generation\Services\CBS-CustAccountInfo-I\WSDL\CBS-CustAccountInfo-I-Concrete.wsdl"/> <classpath> <path refid="cxf.classpath"/> </classpath> </java> </target> <target name="cxfWSDLTXNToJava"> <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true"> <arg value="-databinding"/> <arg value="xmlbeans"/> <arg value="-client"/> <arg value="-d"/> <arg value="cxfsrc"/> <arg value="D:\Generation\Services\CBS-DirectDebCredTransfer-C\WSDL\CBS-DirectDebCredTransfer-C-Concrete.wsdl"/> <classpath> <path refid="cxf.classpath"/> </classpath> </java> </target> 

my project is located here in the CXF-Generation section.

the whole scheme + WSDL can be found in CXF-Generation / Generation

+4
source share
2 answers

Use xsdconfig to solve my problem. In the end, I have a duplicate package, but it fits my needs.

My Maven to create a conflicting package

 <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <wsdlOptions> <wsdlOption> <wsdl>${basedir}\..\Generation\Services\CBS-DirectDebCredTransfer-C\WSDL\CBS-DirectDebCredTransfer-C-Concrete.wsdl</wsdl> <extraargs> <extraarg>-db</extraarg> <extraarg>xmlbeans</extraarg> <extraarg>-p</extraarg> <extraarg>com.xxx.txnpos.ws</extraarg> </extraargs> <bindingFiles> <bindingFile>${basedir}/txnpos.xsdconfig</bindingFile> </bindingFiles> </wsdlOption> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> 

My xsd configuration:

 <?xml version="1.0"?> <xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config"> <xb:namespace uri="http://schemas.xxx.com/soa/emf/common/aggregates/"> <xb:package>com.xxx.schemas.soa.emf.txnpost.aggregates</xb:package> </xb:namespace> <xb:namespace uri="http://schemas.xxx.com/soa/emf/common/body/"> <xb:package>com.xxx.schemas.soa.emf.txnpost.body</xb:package> </xb:namespace> <xb:namespace uri="http://schemas.xxx.com/soa/emf/common/elements/"> <xb:package>com.xxx.schemas.soa.emf.txnpost.elements</xb:package> </xb:namespace> <xb:namespace uri="http://schemas.xxx.com/soa/emf/common/envelope/"> <xb:package>com.xxx.schemas.soa.emf.txnpost.envelope</xb:package> </xb:namespace> <xb:namespace uri="http://schemas.xxx.com/soa/emf/common/header/"> <xb:package>com.xxx.schemas.soa.emf.txnpost.header</xb:package> </xb:namespace> <xb:namespace uri="http://schemas.xxx.com/soa/emf/common/monetaryErrorReponse/"> <xb:package>com.xxx.schemas.soa.emf.txnpost.monetaryErrorReponse</xb:package> </xb:namespace> </xb:config> 
0
source

I'm not an ant expert, so I'm not sure I'm right, but I think the problem is that one ovverides target is another.

When you run the XmlBeans command, if you run it as two separate commands:

 wsdl2java -uri my_service1.wsdl wsdl2java -uri my_service2.wsdl 

The first command will generate a jar, and the second will ovverride with the new code from the second wsdl.

I think you run it like this, and that is why you only get the code for one wsdl.

You need to combine them into one wsdl (possibly a wsdl shell), and then generate the code from it.

Or you can create 2 different jars.

EDIT:

Minor correction, apparently Only IBM supports importing wsdl from another wsdl .

Thus, the wrapper option is outside the table. IMHO, these are your options:

  • Change the target namespace of the general schema so that no conflict occurs and 2 jars are generated.
  • Combining both wsdls into one (simple copy) - it can be a little difficult if there are methods / parameters with the same name that have a different purpose.
+1
source

All Articles