SOAPFaultException: Unmarshalling Error: неожиданный элемент - PullRequest
0 голосов
/ 27 сентября 2019

Я создаю клиентское приложение, которое должно вызывать веб-сервис.Я сгенерировал правильные классы, используя JAX-WS на основе доставленного мне файла WSDL.

Когда я пытаюсь выполнить запрос, возникает исключение:

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http://myUrl/xsd", local:"response"). Expected elements are <{http://myUrl/webservices}response> 
at org.apache.cxf.impl//org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195)
at org.apache.cxf.impl//org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
at com.sun.proxy.$Proxy77.performOperation(Unknown Source)
...

Здесь доставляетсямне файл WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<s0:definitions targetNamespace="http://myUrl/webservices" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://myUrl/webservices" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/">
  <s0:types>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://myUrl/webservices" xmlns:ns1="http://myUrl/webservices" xmlns:ns2="http://myUrl/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://myUrl/xsd"/>
      <xs:element name="performOperationRequest">
        <xs:complexType>
          <xs:attribute name="param1" type="xs:string" use="optional"/>
          <xs:attribute name="param2" type="xs:string" use="optional"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="performOperationResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="response" type="ns2:Response"/>
          </xs:sequence>
          <xs:attribute name="errCode" type="xs:integer" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://myUrl/xsd" xmlns:ns1="http://myUrl/webservices" xmlns:ns2="http://myUrl/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="Response">
        <xs:attribute name="someAtt" type="ns2:SomeAtt"/>
      </xs:complexType>
      <xs:simpleType name="SomeAtt">
        <xs:restriction base="xs:string">
          <xs:pattern value="[0-9]{10}"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:schema>
  </s0:types>
  <s0:message name="performOperationRequest">
    <s0:part element="s1:performOperationRequest" name="parameters"/>
  </s0:message>
  <s0:message name="performOperationResponse">
    <s0:part element="s1:performOperationResponse" name="parameters"/>
  </s0:message>
  <s0:portType name="MyServicePortType">
    <s0:operation name="performOperation">
      <s0:input message="s1:performOperationRequest"/>
      <s0:output message="s1:performOperationResponse"/>
    </s0:operation>
  </s0:portType>
  <s0:binding name="MyServiceSoapBinding" type="s1:MyServicePortType">
    <s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <s0:operation name="performOperation">
      <s2:operation soapAction="urn:performOperation" style="document"/>
      <s0:input>
        <s2:body use="literal"/>
      </s0:input>
      <s0:output>
        <s2:body use="literal"/>
      </s0:output>
    </s0:operation>
  </s0:binding>
  <s0:service name="MyService">
    <s0:port binding="s1:MyServiceSoapBinding" name="MyServiceHttpSoapEndpoint">
      <s2:address location="http://url/performOperationService"/>
    </s0:port>
  </s0:service>
</s0:definitions>

А вот моя конфигурация плагина JAX-WS Maven:

<plugin>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.3.2</version>
    <executions>
        <execution>
            <id>wsdltoJava</id>
            <goals>
                <goal>wsimport</goal>
            </goals>
            <configuration>
                <wsdlLocation>/wsdl/*</wsdlLocation>
                <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
                <wsdlFiles>
                    <wsdlFile>myWsdlFile.wsdl</wsdlFile>
                </wsdlFiles>
                <vmArgs>
                    <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                </vmArgs>
            </configuration>
        </execution>
    </executions>
</plugin>

Почему я получаю эту ошибку?Я делаю что-то неправильно?Как я могу это исправить?

...