title: Apache CXF wsdl2java: WSDL file returned different from the original one
body: <p>I received a WSDL file from a customer describing a web service they wanted me to offer.</p>
  
  <p>Using <strong>Apache CXF 3.0.4</strong> and <strong>wsdl2java</strong> the WSDL file was translated into fully annotated Java code from which I implemented the service.</p>
  
  <p>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:</p>
  
  <pre><code>http://never.mind/SomeService?wsdl
  </code></pre>
  
  <p>When this WSDL URL is loaded in SoapUI I see request XML looking similar to this:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://wsdl.customer.stuff" xmlns:som="http://other.customer.stuff/xsd/SomeServiceRequest"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;wsdl:SomeService&gt;
           &lt;wsdl:SomeServiceRequest&gt;
              &lt;som:user&gt;?&lt;/som:user&gt;
              &lt;som:pw&gt;?&lt;/som:pw&gt;
              &lt;!--Optional:--&gt;
              &lt;som:phone&gt;?&lt;/som:phone&gt;
              &lt;!--Optional:--&gt;
              &lt;som:start&gt;?&lt;/som:start&gt;
              &lt;!--Optional:--&gt;
              &lt;som:end&gt;?&lt;/som:end&gt;
              &lt;som:trans&gt;?&lt;/som:trans&gt;
              &lt;!--Optional:--&gt;
              &lt;som:protocol&gt;?&lt;/som:protocol&gt;
           &lt;/wsdl:SomeServiceRequest&gt;
        &lt;/wsdl:SomeService&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>But when I load the original WSDL file received from the customer in SoapUI I see request XML similar to this:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://wsdl.customer.stuff" xmlns:som="http://other.customer.stuff/xsd/SomeServiceRequest"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;wsdl:SomeService&gt;
           &lt;som:SomeServiceRequest&gt;
              &lt;som:user&gt;?&lt;/som:user&gt;
              &lt;som:pw&gt;?&lt;/som:pw&gt;
              &lt;!--Optional:--&gt;
              &lt;som:phone&gt;?&lt;/som:phone&gt;
              &lt;!--Optional:--&gt;
              &lt;som:start&gt;?&lt;/som:start&gt;
              &lt;!--Optional:--&gt;
              &lt;som:end&gt;?&lt;/som:end&gt;
              &lt;som:trans&gt;?&lt;/som:trans&gt;
              &lt;!--Optional:--&gt;
              &lt;som:protocol&gt;?&lt;/som:protocol&gt;
           &lt;/som:SomeServiceRequest&gt;
        &lt;/wsdl:SomeService&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>The big difference is that the <code>SomeServiceRequest</code> tag is wrongly prefixed with <code>wsdl</code> in the first request structure whereas it is correctly prefixed with <code>som</code> in the second.</p>
  
  <p>Does anyone have any idea why the namespace of the <code>SomeServiceRequest</code> changes?</p>
  
  <hr>
  
  <p>Here is how the WSDL file I received from the customer looks (I have done a few renamings to censor out customer details):</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;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/"&gt;
    &lt;s0:types&gt;
      &lt;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"&gt;
        &lt;xs:element name="SomeServiceRequest" type="SomeServiceRequestType" /&gt;
        &lt;xs:complexType name="SomeServiceRequestType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element maxOccurs="1" minOccurs="1" name="user" type="xs:string" /&gt;
            &lt;xs:element maxOccurs="1" minOccurs="1" name="pw" type="xs:string" /&gt;
            &lt;xs:element maxOccurs="1" minOccurs="0" name="phone" type="xs:string" /&gt;
            &lt;xs:element maxOccurs="1" minOccurs="0" name="start" type="xs:long" /&gt;
            &lt;xs:element maxOccurs="1" minOccurs="0" name="end" type="xs:long" /&gt;
            &lt;xs:element maxOccurs="1" minOccurs="1" name="trans" type="xs:string" /&gt;
            &lt;xs:element maxOccurs="1" minOccurs="0" name="protocol" type="xs:string" /&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:schema&gt;
      &lt;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"&gt;
        &lt;xsd:element name="ResponseControl" type="well:ResponseControlType" /&gt;
        &lt;xsd:complexType name="SomeServiceDataType"&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="serviceId" type="xsd:int" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="serviceName" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="0" name="tariff" type="xsd:int" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="0" name="status" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="activation" type="xsd:long" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="0" name="cancellation" type="xsd:long" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="type" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="0" name="protocol" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="0" name="provider" type="xsd:string" /&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:complexType&gt;
        &lt;xsd:complexType name="ResponseControlType"&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="code" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="reason" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="detail" type="xsd:string" /&gt;
            &lt;xsd:element maxOccurs="1" minOccurs="1" name="trans" type="xsd:string" /&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:complexType&gt;
      &lt;/xsd:schema&gt;
      &lt;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"&gt;
        &lt;xs:import namespace="http://other.customer.stuff/soap/well" /&gt;
        &lt;xs:element name="SomeServiceResponse" type="SomeServiceResponseType" /&gt;
        &lt;xs:complexType name="SomeServiceResponseType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name="responseControl" type="ctrl:ResponseControlType" /&gt;
            &lt;xs:element maxOccurs="unbounded" minOccurs="0" name="SomeServiceData" type="ctrl:SomeServiceDataType" /&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:schema&gt;
      &lt;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"&gt;
        &lt;xs:import namespace="http://other.customer.stuff/xsd/SomeServiceRequest" /&gt;
        &lt;xs:import namespace="http://other.customer.stuff/xsd/SomeServiceResponse" /&gt;
        &lt;xs:element name="SomeService"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element ref="env:SomeServiceRequest" xmlns:env="http://other.customer.stuff/xsd/SomeServiceRequest" /&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="SomeServiceResponse"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element ref="env:SomeServiceResponse" xmlns:env="http://other.customer.stuff/xsd/SomeServiceResponse" /&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:schema&gt;
    &lt;/s0:types&gt;
    &lt;s0:message name="SomeService"&gt;
      &lt;s0:part element="s1:SomeService" name="parameters" /&gt;
    &lt;/s0:message&gt;
    &lt;s0:message name="SomeServiceResponse"&gt;
      &lt;s0:part element="s1:SomeServiceResponse" name="parameters" /&gt;
    &lt;/s0:message&gt;
    &lt;s0:portType name="SomeServiceWs"&gt;
      &lt;s0:operation name="SomeService" parameterOrder="parameters"&gt;
        &lt;s0:input message="s1:SomeService" /&gt;
        &lt;s0:output message="s1:SomeServiceResponse" /&gt;
      &lt;/s0:operation&gt;
    &lt;/s0:portType&gt;
    &lt;s0:binding name="SomeServiceWsSoapBinding" type="s1:SomeServiceWs"&gt;
      &lt;s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /&gt;
      &lt;s0:operation name="SomeService"&gt;
        &lt;s2:operation soapAction="" style="document" /&gt;
        &lt;s0:input&gt;
          &lt;s2:body parts="parameters" use="literal" /&gt;
        &lt;/s0:input&gt;
        &lt;s0:output&gt;
          &lt;s2:body parts="parameters" use="literal" /&gt;
        &lt;/s0:output&gt;
      &lt;/s0:operation&gt;
    &lt;/s0:binding&gt;
    &lt;s0:service name="SomeServiceWs"&gt;
      &lt;s0:port binding="s1:SomeServiceWsSoapBinding" name="SomeService"&gt;
        &lt;s2:address location="http://never.mind/SomeService" /&gt;
      &lt;/s0:port&gt;
    &lt;/s0:service&gt;
  &lt;/s0:definitions&gt;
  </code></pre>
  
  
  
  <hr>
  
  <p>And this is how the WSDL I retrieve from my service looks:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://wsdl.customer.stuff" name="SomeServiceWs" targetNamespace="http://wsdl.customer.stuff"&gt;
    &lt;wsdl:types&gt;
      &lt;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"&gt;
        &lt;xs:import namespace="http://other.customer.stuff/xsd/SomeServiceRequest" /&gt;
        &lt;xs:import namespace="http://other.customer.stuff/soap/well" /&gt;
        &lt;xs:import namespace="http://other.customer.stuff/xsd/SomeServiceResponse" /&gt;
        &lt;xs:element name="SomeService"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element name="SomeServiceRequest" type="ns1:SomeServiceRequestType" /&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="SomeServiceResponse"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element name="SomeServiceResponse" type="ns3:SomeServiceResponseType" /&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:schema&gt;
      &lt;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"&gt;
        &lt;xs:import namespace="http://other.customer.stuff/soap/well" /&gt;
        &lt;xs:element name="SomeServiceResponse" type="tns:SomeServiceResponseType" /&gt;
        &lt;xs:complexType name="SomeServiceResponseType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name="responseControl" type="ns1:ResponseControlType" /&gt;
            &lt;xs:element maxOccurs="unbounded" minOccurs="0" name="SomeServiceData" type="ns1:SomeServiceDataType" /&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:schema&gt;
      &lt;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"&gt;
        &lt;xs:element name="SomeServiceRequest" type="tns:SomeServiceRequestType" /&gt;
        &lt;xs:complexType name="SomeServiceRequestType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name="user" type="xs:string" /&gt;
            &lt;xs:element name="pw" type="xs:string" /&gt;
            &lt;xs:element minOccurs="0" name="phone" type="xs:string" /&gt;
            &lt;xs:element minOccurs="0" name="start" type="xs:long" /&gt;
            &lt;xs:element minOccurs="0" name="end" type="xs:long" /&gt;
            &lt;xs:element name="trans" type="xs:string" /&gt;
            &lt;xs:element minOccurs="0" name="protocol" type="xs:string" /&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:schema&gt;
      &lt;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"&gt;
        &lt;xs:element name="ResponseControl" type="tns:ResponseControlType" /&gt;
        &lt;xs:complexType name="ResponseControlType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name="code" type="xs:string" /&gt;
            &lt;xs:element name="reason" type="xs:string" /&gt;
            &lt;xs:element name="detail" type="xs:string" /&gt;
            &lt;xs:element name="trans" type="xs:string" /&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
        &lt;xs:complexType name="SomeServiceDataType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name="serviceId" type="xs:int" /&gt;
            &lt;xs:element name="serviceName" type="xs:string" /&gt;
            &lt;xs:element minOccurs="0" name="tariff" type="xs:int" /&gt;
            &lt;xs:element minOccurs="0" name="status" type="xs:string" /&gt;
            &lt;xs:element name="activation" type="xs:long" /&gt;
            &lt;xs:element minOccurs="0" name="cancellation" type="xs:long" /&gt;
            &lt;xs:element name="type" type="xs:string" /&gt;
            &lt;xs:element minOccurs="0" name="protocol" type="xs:string" /&gt;
            &lt;xs:element minOccurs="0" name="provider" type="xs:string" /&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:schema&gt;
    &lt;/wsdl:types&gt;
    &lt;wsdl:message name="SomeService"&gt;
      &lt;wsdl:part element="ns1:SomeService" name="parameters"&gt;
      &lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:message name="SomeServiceResponse"&gt;
      &lt;wsdl:part element="ns1:SomeServiceResponse" name="parameters"&gt;
      &lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:portType name="SomeServiceWs"&gt;
      &lt;wsdl:operation name="SomeService"&gt;
        &lt;wsdl:input message="ns1:SomeService" name="SomeService"&gt;
        &lt;/wsdl:input&gt;
        &lt;wsdl:output message="ns1:SomeServiceResponse" name="SomeServiceResponse"&gt;
        &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
    &lt;/wsdl:portType&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>