Create Modified WSDL for AppFxWebService to Bind Using JAXB or JAX-WS
In Communicate with AppFxWebService, we established the added difficulties with AppFxWebService as opposed to BizOps web services. We addressed the inclusion of ClientAppInfo in our message. But to work with the web service effectively, we need a library of classes that correspond to the definitions in the WSDL for AppFxWebService. The difficulty is the complexity of the WSDL, specifically the problems that occur when binding or web service proxy utilities in Java attempt to parse the schema.
Note: You can use a modified version of the WSDL that was already created and skip this discussion: appfxwebservice.asmx.wsdl.
In NetBeans, if we attempt to create a JAXB binding for AppFxWebService WSDL with the NetBeans wizard, we get a series of errors starting with:
[ERROR] undefined element declaration 's:schema' line 3254 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFxClassesExample/xml-resources/jaxb/AppFx/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] undefined element declaration 's:schema' line 4397 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFxClassesExample/xml-resources/jaxb/AppFx/localhost/bbAppFx/appfxwebservice.asmx.wsdl
We aren't the first to encounter this. Some solutions are out there that recover from this:
Here is a fragment of the WSDL where the first error occurs:
<s:complexType name="BusinessProcessOutputLoadReply">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DataSet">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
Let's adjust a local version of the WSDL to handle this.
First, replace:
<s:element ref="s:schema" /> <s:any />
With:
<s:any minOccurs="2" maxOccurs="2" />
Now when you regenerate, you'll get some more errors:
xjc-typedef-target: jaxb-code-generation: Compiling file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] Property "Description" is already defined. Use <jaxb:property> to resolve this conflict. line 9292 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] The following location is relevant to the above error line 5814 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] Property "Description" is already defined. Use <jaxb:property> to resolve this conflict. line 9388 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] The following location is relevant to the above error line 5814 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] Property "Description" is already defined. Use <jaxb:property> to resolve this conflict. line 9415 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] The following location is relevant to the above error line 5814 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl failure in the XJC task. Use the Ant -verbose switch for more details C:\Users\TomTr\Documents\NetBeansProjects\AppFx\nbproject\xml_binding_build.xml:17: unable to parse the schema. Error messages should have been provided BUILD FAILED (total time: 1 second)
Let's eliminate one of each of these pairs. Delete the lines in your version that correspond to 9292, 9388, and 9415. This isn't ideal, but we can address the problems this causes later.
The next set of errors involves ArrayOfString:
xjc-typedef-target: jaxb-code-generation: Compiling file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] A class/interface with the same name "a.ArrayOfString" is already in use. Use a class customization to resolve this conflict. line 114 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] (Relevant to above error) another "ArrayOfString" is generated from here. line 6341 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] A class/interface with the same name "a.ArrayOfParameterValueDescriptor" is already in use. Use a class customization to resolve this conflict. line 1260 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl [ERROR] (Relevant to above error) another "ArrayOfParameterValueDescriptor" is generated from here. line 6131 of file:/C:/Users/TomTr/Documents/NetBeansProjects/AppFx/xml-resources/jaxb/a/localhost/bbAppFx/appfxwebservice.asmx.wsdl ...
And so on... For this, we will rename some items. Starting at line 6341, rename ArrayOfString to ArrayOfStringA. Then change the references to it as well. This is a slightly better solution than removing the offending entities. First, we may want to use them, and second, removing one thing usually cascades into a problem with another.
Save the local version of the WSDL to use for future binding.