问题
I received a WSDL file from a customer describing a web service they wanted me to offer.
Using Apache CXF 3.0.4 and wsdl2java the WSDL file was translated into fully annotated Java code from which I implemented the service.
Everything went well until the customer started testing the service using the WSDL file returned from my server via a URL of the following pattern:
http://never.mind/SomeService?wsdl
When this WSDL URL is loaded in SoapUI I see request XML looking similar to this:
<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>
But when I load the original WSDL file received from the customer in SoapUI I see request XML similar to this:
<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>
The big difference is that the SomeServiceRequest
tag is wrongly prefixed with wsdl
in the first request structure whereas it is correctly prefixed with som
in the second.
Does anyone have any idea why the namespace of the SomeServiceRequest
changes?
Here is how the WSDL file I received from the customer looks (I have done a few renamings to censor out customer details):
<?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>
And this is how the WSDL I retrieve from my service looks:
<?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>
来源:https://stackoverflow.com/questions/29500064/apache-cxf-wsdl2java-wsdl-file-returned-different-from-the-original-one