title: CXF wsdl2java resulting in BINDING_MISSING_TYPE
body: <p>Using java 6, CXF 2.3.1 and Maven 2.</p>
  
  <p>When running CXF wsdl2java tool via the Maven plugin, I am encountering
  the following issue:</p>
  
  <blockquote>
    <p>wsdl2java -d
    C:\devel\adpoint_callback\target\generated-sources\cxf -impl -validate -verbose file:/C:/devel/adpoint_callback/src/main/resources/wsdl/foobar.wsdl
    wsdl2java - Apache CXF 2.3.1</p>
    
    <p>WSIBP Validator found &lt;binding&gt; is NOT
    a SOAP binding [DEBUG] </p>
    
    <p>org.apache.cxf.tools.common.ToolException:
    org.apache.cxf.wsdl11.WSDLRuntimeException:
    BINDING_MISSING_TYPE
            at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:279)</p>
    
    <p>... ~20 rows</p>
    
    <p>Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: BINDING_MISSING_TYPE
            at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:306)
            at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:181)</p>
  </blockquote>
  
  <p>Using the following minimal WSDL file adapted from <a href="http://www.w3schools.com/WSDL/wsdl_binding.asp" rel="nofollow">http://www.w3schools.com/WSDL/wsdl_binding.asp</a> :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wsdl:definitions name="notification"   
      targetNamespace="http://example.com/mynamespace" 
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xsd="http://example.com/mynamespace/xsd" &gt;
  
      &lt;wsdl:types&gt;
          &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
              xmlns:xsd="http://example.com/mynamespace/xsd" 
              targetNamespace="http://example.com/mynamespace/xsd" &gt;
              &lt;xs:element name="RequestType" type="xsd:content"/&gt;
              &lt;xs:element name="ResponseType" type="xsd:content"/&gt;
  
              &lt;xs:complexType name="content"&gt;
                      &lt;xs:sequence&gt;
                          &lt;xs:element name="text" type="xs:string"/&gt;
                      &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
          &lt;/xs:schema&gt;
      &lt;/wsdl:types&gt;
  
      &lt;wsdl:message name="getTermRequest"&gt;
          &lt;wsdl:part name="body" element="xsd:RequestType"/&gt;
      &lt;/wsdl:message&gt;
  
      &lt;wsdl:message name="getTermResponse"&gt;
          &lt;wsdl:part name="body" element="xsd:ResponseType"/&gt;
      &lt;/wsdl:message&gt;
  
      &lt;wsdl:portType name="glossaryTerms"&gt;
          &lt;wsdl:operation name="getTerm"&gt;
              &lt;wsdl:input message="getTermRequest"/&gt;
              &lt;wsdl:output message="getTermResponse"/&gt;
          &lt;/wsdl:operation&gt;
      &lt;/wsdl:portType&gt;
  
      &lt;wsdl:binding name="binding" type="glossaryTerms"&gt;
          &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /&gt;
          &lt;wsdl:operation name="getTerm"&gt;
              &lt;soap:operation soapAction="http://example.com/getTerm" /&gt;
              &lt;wsdl:input&gt;&lt;soap:body use="literal"/&gt;&lt;/wsdl:input&gt;
              &lt;wsdl:output&gt;&lt;soap:body use="literal"/&gt;&lt;/wsdl:output&gt;
          &lt;/wsdl:operation&gt;
      &lt;/wsdl:binding&gt;
  
      &lt;wsdl:service name="testService" &gt;
          &lt;wsdl:port name="testPort" binding="binding"&gt;
              &lt;soap:address location="http://example.com/mynamespace"/&gt;
          &lt;/wsdl:port&gt;
      &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>The service/binding usage is exactly as used in the example within the WSDL 1.1 specification document <a href="http://www.w3.org/TR/wsdl" rel="nofollow">http://www.w3.org/TR/wsdl</a></p>
  
  <p>The code generation will not work without the -validate flag either - The validation warnings just do not show up.</p>
  
  <p>Question is - of course - why the &lt;soap:binding&gt; element is not accepted as a binding type for the binding element as it should.</p>
  
  <hr>
  
  <p><strong>[ EDIT : Fix ]</strong></p>
  
  <p>If I set the default namespace to the same value as my targetNamespace, the error disappears.
  Somehow the CXF is able to handle the fact that I do not set the default namespace up until the moment it was supposed to handle the binding. At that point it throws out a misleading exception about missing binding type.</p>
  
  <p>Therefore, fixing this is as easy as changing the attributes of the wsdl:definition tag
  to define the default namespace:</p>
  
  <pre><code>&lt;wsdl:definitions name="notification"   
      targetNamespace="http://example.com/mynamespace" 
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xsd="http://example.com/mynamespace/xsd"
          xmlns="http://example.com/mynamespace" &gt;
  </code></pre>