Apache CXF wsdl2java:返回的WSDL文件与原始文件不同

时间:2015-04-07 19:49:39

标签: java apache cxf soapui wsdl2java

我收到了客户的WSDL文件,描述了他们希望我提供的网络服务。

使用 Apache CXF 3.0.4 wsdl2java ,WSDL文件被转换为完全带注释的Java代码,我从中实现了该服务。

一切顺利,直到客户开始使用我的服务器通过以下模式的URL返回的WSDL文件测试服务:

http://never.mind/SomeService?wsdl

当在SoapUI中加载此WSDL URL时,我看到请求XML看起来与此类似:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://wsdl.customer.stuff" xmlns:som="http://other.customer.stuff/xsd/SomeServiceRequest">
   <soapenv:Header/>
   <soapenv:Body>
      <wsdl:SomeService>
         <wsdl:SomeServiceRequest>
            <som:user>?</som:user>
            <som:pw>?</som:pw>
            <!--Optional:-->
            <som:phone>?</som:phone>
            <!--Optional:-->
            <som:start>?</som:start>
            <!--Optional:-->
            <som:end>?</som:end>
            <som:trans>?</som:trans>
            <!--Optional:-->
            <som:protocol>?</som:protocol>
         </wsdl:SomeServiceRequest>
      </wsdl:SomeService>
   </soapenv:Body>
</soapenv:Envelope>

但是当我在SoapUI中加载从客户收到的原始WSDL文件时,我看到请求XML类似于:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://wsdl.customer.stuff" xmlns:som="http://other.customer.stuff/xsd/SomeServiceRequest">
   <soapenv:Header/>
   <soapenv:Body>
      <wsdl:SomeService>
         <som:SomeServiceRequest>
            <som:user>?</som:user>
            <som:pw>?</som:pw>
            <!--Optional:-->
            <som:phone>?</som:phone>
            <!--Optional:-->
            <som:start>?</som:start>
            <!--Optional:-->
            <som:end>?</som:end>
            <som:trans>?</som:trans>
            <!--Optional:-->
            <som:protocol>?</som:protocol>
         </som:SomeServiceRequest>
      </wsdl:SomeService>
   </soapenv:Body>
</soapenv:Envelope>

最大的区别是SomeServiceRequest标记在第一个请求结构中错误地以wsdl为前缀,而在第二个请求结构中正确地以som为前缀。

有没有人知道为什么SomeServiceRequest的命名空间会发生变化?


以下是我从客户收到的WSDL文件的外观(我已经做了一些重新命名以审查客户详细信息):

<?xml version="1.0" encoding="UTF-8" ?>
<s0:definitions name="SomeServiceWsDefinitions" targetNamespace="http://wsdl.customer.stuff" xmlns="" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://wsdl.customer.stuff" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/">
  <s0:types>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://other.customer.stuff/xsd/SomeServiceRequest" xmlns="http://other.customer.stuff/xsd/SomeServiceRequest" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://wsdl.customer.stuff"
    xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="SomeServiceRequest" type="SomeServiceRequestType" />
      <xs:complexType name="SomeServiceRequestType">
        <xs:sequence>
          <xs:element maxOccurs="1" minOccurs="1" name="user" type="xs:string" />
          <xs:element maxOccurs="1" minOccurs="1" name="pw" type="xs:string" />
          <xs:element maxOccurs="1" minOccurs="0" name="phone" type="xs:string" />
          <xs:element maxOccurs="1" minOccurs="0" name="start" type="xs:long" />
          <xs:element maxOccurs="1" minOccurs="0" name="end" type="xs:long" />
          <xs:element maxOccurs="1" minOccurs="1" name="trans" type="xs:string" />
          <xs:element maxOccurs="1" minOccurs="0" name="protocol" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    <xsd:schema elementFormDefault="qualified" targetNamespace="http://other.customer.stuff/soap/well" xmlns:well="http://other.customer.stuff/soap/well" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://wsdl.customer.stuff" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="ResponseControl" type="well:ResponseControlType" />
      <xsd:complexType name="SomeServiceDataType">
        <xsd:sequence>
          <xsd:element maxOccurs="1" minOccurs="1" name="serviceId" type="xsd:int" />
          <xsd:element maxOccurs="1" minOccurs="1" name="serviceName" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="0" name="tariff" type="xsd:int" />
          <xsd:element maxOccurs="1" minOccurs="0" name="status" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="1" name="activation" type="xsd:long" />
          <xsd:element maxOccurs="1" minOccurs="0" name="cancellation" type="xsd:long" />
          <xsd:element maxOccurs="1" minOccurs="1" name="type" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="0" name="protocol" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="0" name="provider" type="xsd:string" />
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ResponseControlType">
        <xsd:sequence>
          <xsd:element maxOccurs="1" minOccurs="1" name="code" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="1" name="reason" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="1" name="detail" type="xsd:string" />
          <xsd:element maxOccurs="1" minOccurs="1" name="trans" type="xsd:string" />
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://other.customer.stuff/xsd/SomeServiceResponse" xmlns="http://other.customer.stuff/xsd/SomeServiceResponse" xmlns:ctrl="http://other.customer.stuff/soap/well" xmlns:s0="http://schemas.xmlsoap.org/wsdl/"
    xmlns:s1="http://wsdl.customer.stuff" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://other.customer.stuff/soap/well" />
      <xs:element name="SomeServiceResponse" type="SomeServiceResponseType" />
      <xs:complexType name="SomeServiceResponseType">
        <xs:sequence>
          <xs:element name="responseControl" type="ctrl:ResponseControlType" />
          <xs:element maxOccurs="unbounded" minOccurs="0" name="SomeServiceData" type="ctrl:SomeServiceDataType" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://wsdl.customer.stuff" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://wsdl.customer.stuff" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://other.customer.stuff/xsd/SomeServiceRequest" />
      <xs:import namespace="http://other.customer.stuff/xsd/SomeServiceResponse" />
      <xs:element name="SomeService">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="env:SomeServiceRequest" xmlns:env="http://other.customer.stuff/xsd/SomeServiceRequest" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="SomeServiceResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="env:SomeServiceResponse" xmlns:env="http://other.customer.stuff/xsd/SomeServiceResponse" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
  </s0:types>
  <s0:message name="SomeService">
    <s0:part element="s1:SomeService" name="parameters" />
  </s0:message>
  <s0:message name="SomeServiceResponse">
    <s0:part element="s1:SomeServiceResponse" name="parameters" />
  </s0:message>
  <s0:portType name="SomeServiceWs">
    <s0:operation name="SomeService" parameterOrder="parameters">
      <s0:input message="s1:SomeService" />
      <s0:output message="s1:SomeServiceResponse" />
    </s0:operation>
  </s0:portType>
  <s0:binding name="SomeServiceWsSoapBinding" type="s1:SomeServiceWs">
    <s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <s0:operation name="SomeService">
      <s2:operation soapAction="" style="document" />
      <s0:input>
        <s2:body parts="parameters" use="literal" />
      </s0:input>
      <s0:output>
        <s2:body parts="parameters" use="literal" />
      </s0:output>
    </s0:operation>
  </s0:binding>
  <s0:service name="SomeServiceWs">
    <s0:port binding="s1:SomeServiceWsSoapBinding" name="SomeService">
      <s2:address location="http://never.mind/SomeService" />
    </s0:port>
  </s0:service>
</s0:definitions>

这就是我从服务中检索的WSDL的外观:

<?xml version='1.0' encoding='UTF-8' ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://wsdl.customer.stuff" name="SomeServiceWs" targetNamespace="http://wsdl.customer.stuff">
  <wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns3="http://other.customer.stuff/xsd/SomeServiceResponse" xmlns:ns1="http://other.customer.stuff/xsd/SomeServiceRequest" elementFormDefault="qualified" targetNamespace="http://wsdl.customer.stuff"
    version="1.0">
      <xs:import namespace="http://other.customer.stuff/xsd/SomeServiceRequest" />
      <xs:import namespace="http://other.customer.stuff/soap/well" />
      <xs:import namespace="http://other.customer.stuff/xsd/SomeServiceResponse" />
      <xs:element name="SomeService">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="SomeServiceRequest" type="ns1:SomeServiceRequestType" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="SomeServiceResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="SomeServiceResponse" type="ns3:SomeServiceResponseType" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://other.customer.stuff/xsd/SomeServiceResponse" xmlns:ns1="http://other.customer.stuff/soap/well" elementFormDefault="qualified" targetNamespace="http://other.customer.stuff/xsd/SomeServiceResponse"
    version="1.0">
      <xs:import namespace="http://other.customer.stuff/soap/well" />
      <xs:element name="SomeServiceResponse" type="tns:SomeServiceResponseType" />
      <xs:complexType name="SomeServiceResponseType">
        <xs:sequence>
          <xs:element name="responseControl" type="ns1:ResponseControlType" />
          <xs:element maxOccurs="unbounded" minOccurs="0" name="SomeServiceData" type="ns1:SomeServiceDataType" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://other.customer.stuff/xsd/SomeServiceRequest" elementFormDefault="qualified" targetNamespace="http://other.customer.stuff/xsd/SomeServiceRequest" version="1.0">
      <xs:element name="SomeServiceRequest" type="tns:SomeServiceRequestType" />
      <xs:complexType name="SomeServiceRequestType">
        <xs:sequence>
          <xs:element name="user" type="xs:string" />
          <xs:element name="pw" type="xs:string" />
          <xs:element minOccurs="0" name="phone" type="xs:string" />
          <xs:element minOccurs="0" name="start" type="xs:long" />
          <xs:element minOccurs="0" name="end" type="xs:long" />
          <xs:element name="trans" type="xs:string" />
          <xs:element minOccurs="0" name="protocol" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://other.customer.stuff/soap/well" elementFormDefault="qualified" targetNamespace="http://other.customer.stuff/soap/well" version="1.0">
      <xs:element name="ResponseControl" type="tns:ResponseControlType" />
      <xs:complexType name="ResponseControlType">
        <xs:sequence>
          <xs:element name="code" type="xs:string" />
          <xs:element name="reason" type="xs:string" />
          <xs:element name="detail" type="xs:string" />
          <xs:element name="trans" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="SomeServiceDataType">
        <xs:sequence>
          <xs:element name="serviceId" type="xs:int" />
          <xs:element name="serviceName" type="xs:string" />
          <xs:element minOccurs="0" name="tariff" type="xs:int" />
          <xs:element minOccurs="0" name="status" type="xs:string" />
          <xs:element name="activation" type="xs:long" />
          <xs:element minOccurs="0" name="cancellation" type="xs:long" />
          <xs:element name="type" type="xs:string" />
          <xs:element minOccurs="0" name="protocol" type="xs:string" />
          <xs:element minOccurs="0" name="provider" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="SomeService">
    <wsdl:part element="ns1:SomeService" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="SomeServiceResponse">
    <wsdl:part element="ns1:SomeServiceResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="SomeServiceWs">
    <wsdl:operation name="SomeService">
      <wsdl:input message="ns1:SomeService" name="SomeService">
      </wsdl:input>
      <wsdl:output message="ns1:SomeServiceResponse" name="SomeServiceResponse">
      </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
</wsdl:definitions>

0 个答案:

没有答案