Specifying a local xsd schema
Friday, November 13th, 2009An easy way to create client stubs for a Web Service call in Java is to use the wsdl2java call from apache axis.
java org.apache.axis.wsdl.WSDL2Java (MyWSDLFileOrURL)
While attempting to create Client Stubs for a Web Service call I received the following error.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:156)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema): fau
ltCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at ''
java.io.IOException: HTTPS hostname wrong: should be
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
The machine the service was hosted on was transforming requests to the domain name to the actual machine name.. or something along those line.
The fix was to download the wsdl file and edit the associated schemas within the WSDL that referenced the bad schema.
here is an arbitrary example.
before
<wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation="http://somerandomdomain.com/services/MyService.svc?xsd=xsd0" namespace="http://www.starstandards.org/webservices/2005/10/transport"/> <xsd:import schemaLocation="http://somerandomdomain.com/services/MyService.svc?xsd=xsd1" namespace="http://schemas.datacontract.org/2004/07/Honda.iN.LCC.Service"/> <xsd:import schemaLocation="http://somerandomdomain.com/services/MyService.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> </xsd:schema> </wsdl:types>
After
<wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation="file:///c:/temp/axis2_test/service0.xsd" namespace="http://www.starstandards.org/webservices/2005/10/transport"/> <xsd:import schemaLocation="file:///c:/temp/axis2_test/service1.xsd" namespace="http://schemas.datacontract.org/2004/07/Honda.iN.LCC.Service"/> <xsd:import schemaLocation="file:///c:/temp/axis2_test/service2.xsd" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> </xsd:schema> </wsdl:types>
Right now I am wresting with Axis, Java Web Services, Web Services Security and Micrsoft Foundation Class. I will post some pointers on this when the task is completed.