views:

701

answers:

2

I'm converting some services from Apache SOAP to Axis2, so the Java service classes already exist. I created a new project in Eclipse, imported the source, made sure that the Axis2 project facets were installed, and Axis2 emitter properties are correct. Then, in Eclipse, I selected the service class and chose "Create Web Service," choosing the Axis2 runtime. The service is up and running on my PC, and when I append "?wsdl" to the service's path, I do indeed get a WSDL that I save locally. Attempting to import this into SoapUI to build a client gives the error:

ERROR:org.apache.xmlbeans.XmlException: C:\projects\soapUI\Axis2\DALService.wsdl:0: error: src-resolve: type 'SOAPException@http://www.w3.org/2001/XMLSchema' not found.

The type it's referring to (SOAPException) is a holdover from the Apache SOAP services, and in the service code, I changed all "import" references in the service code (not the WSDL) from org.apache.soap.SOAPException (the old Apache SOAP package name) to javax.xml.soap.SOAPException (the Axis2 location). The code compiles and works, once I can access it, but I can't access it without generating a client. Any thoughts as to why changing the namespace of an object would keep the generated WSDLs from having the proper namespace references?

A: 

Just use the "xxx?wsdl" URL which showed up the WSDL directly in SOAP UI, looks like some XSD schemas referred in the WSDL are not being found by the SOAP UI tool, generally these tools search the schema's in the same folder, also as you have org.apache.soap.SOAPException to javax.xml.soap.SOAPException, this might have changed the namespace.

Just try using the complete URL and see the result.

shivaspk
Passing the URL to the WSDL instead of a local copy gives the same error. I'm not sure what the rest of your advice is, but if Axis can properly name my custom objects as well as Apache SOAP objects and Axis2 objects, why should changing the path from one valid entry to another matter?
RJCantrell
Problem is with the namespace, check the namespace of SOAPException of in both of your WSDL's they will be different, in most of Java based Web Service Engines Element name spaces are derived from the Object types.
shivaspk
A: 

Let me be the first to say I have no idea WHY any of this is the case, but my guess is the exact content of the namespace may not matter so long as they're all the same. We're not even using any special features of SOAPException, because it only blindly extends the regular Exception. Anyhow, I was able to get SoapUI to build clients from the XML by doing three things.

First, I added a section to represent the SOAPException itself, as so:

    <xs:schema xmlns:test="http://service.PROJECT.DEPARTMENT.COMPANY.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://DEPARTMENT.COMPANY.com/xsd"&gt;
        <xs:import namespace="http://service.PROJECT.DEPARTMENT.COMPANY.com"/&gt;
        <xs:complexType name="SOAPException">
            <xs:complexContent>
                <xs:extension base="ns:Exception">
                    <xs:sequence/>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:schema>

Second, I added the following namespace to the wsdl:definitions block:

xmlns:im="http://DEPARTMENT.COMPANY.com/xsd"

Third, I changed the namespace referenced to the SOAPException base type (fron ns to im here) wherever it was previously referenced:

    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.ims.im.sa.homedepot.com/xsd"&gt;
        <xs:complexType name="SOAPLocatorException">
            <xs:complexContent>
                <xs:extension base="im:SOAPException">
                    <xs:sequence>
                        <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
                        <xs:element minOccurs="0" name="messageCode" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:schema>

The XML file still doesn't validate cleanly in XMLSpy, but only because of a more esoteric reason that doesn't affect me directly (the operations, which have faults defined for the Soap11 and Soap12 bindings, don't have faults defined for the raw HTTP bindings).

Even though it works, I'm still a bit confused about the following:

  • If Axis2 knew about the SOAPException type (and it did, because it mentioned it as the base class of the other exceptions), why didn't it define it in an xs:schema block?
  • Along those same lines, why did it reference the class from an incorrect namespace when using it as the base class for another type?
  • Why do I have to set a namespace for this type as DEPARTMENT.COMPANY.com and not either an Axis2 package or the package of the service object that uses it?
RJCantrell
changing the namespace prefix (fron ns to im here), doesn't help but setting the namespace DEPARTMENT.COMPANY.com makes sense, the problem was your SOAPException was a custom element created under "DEPARTMENT.COMPANY.com" namesapce, and Axis 2 name space for SOAPException is different so it will be like two elements of same bame but different types. (like from two vendors Apple and MS)
shivaspk