Question

I've been working for a few days on a problem with a WSDL we've defined. We are using wsimport to generate code from the WSDL and then using that to run a service. During WSImport, 2 elements cannot be resolved somehow which throws warnings. Runtime however, these warnings turn into errors and we cannot run our service. How can we get rid of these warnings and therefore errors?

All pointers will be greatly appreciated.

We are using Metro 2.3 and Java 7.

The WSDL is using xsds from the HR-XML specification, but I trimmed them down to display the problem clearer.

wsimport is reporting:

    MacBook-Pro-van-Martin:WSDL-problem sunsear$ wsimport -Xnocompile -s generated "file:DummyService.wsdl"
    parsing WSDL...


    [WARNING] src-resolve: Cannot resolve the name 'hr:Assignment' to a(n) 'element declaration' component.
    line 14 of file:xsd/AssignmentRequestElement.xsd

    [WARNING] src-resolve: Cannot resolve the name 'hr:HumanResource' to a(n) 'element declaration' component.
    line 15 of file:xsd/AssignmentRequestElement.xsd


    Generating code...

WSimport is complaining about hr:Assignment and hr:HumanResource which are referenced in the AssignmentRequestElement.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://personnel.services.com/services/2013-10"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:hr="http://ns.hr-xml.org/2007-04-15"
            targetNamespace="http://personnel.services.com/services/2013-10"
            elementFormDefault="qualified" version="2013-10">

    <xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/Assignment.xsd"/>
    <xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/HumanResource.xsd"/>

    <xsd:element name="AssignmentRequestElement">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="hr:Assignment"/>
                <xsd:element ref="hr:HumanResource" minOccurs="0"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

HumanResource looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://ns.hr-xml.org/2007-04-15"
            targetNamespace="http://ns.hr-xml.org/2007-04-15" elementFormDefault="qualified" version="2007-04-15">
    <xsd:complexType name="HumanResourceType">
        <xsd:sequence>
            <xsd:element name="HumanResourceId" type="xsd:string" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="HumanResource" type="HumanResourceType"/>
</xsd:schema>

Assignment looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://ns.hr-xml.org/2007-04-15" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.hr-xml.org/2007-04-15" elementFormDefault="qualified" version="2007-04-15">
    <xsd:complexType name="AssignmentType">
        <xsd:sequence>
            <xsd:element name="AssignmentId" type="xsd:string" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="Assignment" type="AssignmentType"/>
</xsd:schema>

For completeness, this is the WSDL itself:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://personnel.services.com/services/2013-10"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:hr="http://ns.hr-xml.org/2007-04-15" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  targetNamespace="http://personnel.services.com/services/2013-10">
    <wsdl:types>
        <xsd:schema
                    elementFormDefault="qualified">
            <xsd:import namespace="http://ns.hr-xml.org/2007-04-15"
                        schemaLocation="xsd/HR-XML-2_5/CPO/Acknowledgement.xsd"/>
            <xsd:import namespace="http://personnel.services.com/services/2013-10"
                        schemaLocation="xsd/AssignmentRequestElement.xsd"/>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="AssignmentRequest">
        <wsdl:documentation>A generic request of type Assignment (A) or Assignment+HumanResource (A+HR).
        </wsdl:documentation>
        <wsdl:part name="input" element="tns:AssignmentRequestElement"/>
    </wsdl:message>
    <wsdl:message name="Response">
        <wsdl:documentation>A generic response of type Acknowledgement.</wsdl:documentation>
        <wsdl:part name="output" element="hr:Acknowledgement"/>
    </wsdl:message>
    <wsdl:portType name="DummyService">
        <wsdl:operation name="ProcessAssignment">
            <wsdl:documentation>ProcessAssignment is used to send details of an Assignment
                The request message is an Assignment (A) or
                an Assignment+HumanResource (A+HR) message.
            </wsdl:documentation>
            <wsdl:input message="tns:AssignmentRequest"/>
            <wsdl:output message="tns:Response"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SoapServiceHttpBinding" type="tns:DummyService">
        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="ProcessAssignment">
            <wsdlsoap:operation soapAction="https://dummy.personnel.services.com/ws/DummySoapService/ProcessAssignment"
                                style="document"/>
            <wsdl:input>
                <wsdlsoap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <wsdlsoap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DummySoapService">
        <wsdl:port name="DummyServicesEndpoint" binding="tns:SoapServiceHttpBinding">
            <wsdlsoap:address location="https://dummy.personnel.services.com/ws/DummySoapService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

The WSDL and XSDs are correct according to SoapUI and XMLSpy, they validate messages correctly.

The wsdl and xsds can be downloaded here:

https://www.dropbox.com/sh/t8klaoodjfsd772/G2MBGZxLE_

Était-ce utile?

La solution

You have assigned 2 different schema-locations to the same namespaces URL. That could be the reason of this error, because now wsimport does not know where to search for hr: objects.

<xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/Assignment.xsd"/>
<xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/HumanResource.xsd"/>

Have a look at this stackoverflow question for solving this problem: SAXParseException; src-resolve: Cannot resolve the name '...' to a(n) 'type definition' component

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top