Cannot generate CXF client “Unbound PortType elements in Operation”



I have CXF service with the following WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="PropertySetterImplService" targetNamespace="http://eshopCXFService/" xmlns="http://eshopCXFService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://eshopCXFService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
  <wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema">
        <import namespace="http://eshopCXFService/" schemaLocation="propertysetterimpl_schema1.xsd"/>
    </schema>
    <xsd:schema elementFormDefault="qualified" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <xsd:element name="Security">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element minOccurs="1" maxOccurs="1" name="UsernameToken">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element minOccurs="1" maxOccurs="1" name="Username" type="xsd:string"/>
                                <xsd:element minOccurs="1" maxOccurs="1" name="Password">
                                    <xsd:complexType>
                                        <xsd:simpleContent>
                                          <xsd:extension base="xsd:string">
                                            <xsd:attribute name="Type" type="xsd:string" default="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" />
                                          </xsd:extension>
                                        </xsd:simpleContent>
                                    </xsd:complexType>
                                </xsd:element>
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="securityHeader">
    <wsdl:part name="security" element="wsse:Security">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="publishNewDescription">
    <wsdl:part name="parameters" element="tns:publishNewDescription">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="publishNewImageURLResponse">
    <wsdl:part name="parameters" element="tns:publishNewImageURLResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="publishNewPriceResponse">
    <wsdl:part name="parameters" element="tns:publishNewPriceResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="publishNewDescriptionResponse">
    <wsdl:part name="parameters" element="tns:publishNewDescriptionResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="publishNewImageURL">
    <wsdl:part name="parameters" element="tns:publishNewImageURL">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="publishNewPrice">
    <wsdl:part name="parameters" element="tns:publishNewPrice">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="PropertySetter">
    <wsdl:operation name="publishNewDescription">
      <wsdl:input name="publishNewDescription" message="tns:publishNewDescription">
    </wsdl:input>
      <wsdl:output name="publishNewDescriptionResponse" message="tns:publishNewDescriptionResponse">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="publishNewImageURL">
      <wsdl:input name="publishNewImageURL" message="tns:publishNewImageURL">
    </wsdl:input>
      <wsdl:output name="publishNewImageURLResponse" message="tns:publishNewImageURLResponse">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="publishNewPrice">
      <wsdl:input name="publishNewPrice" message="tns:publishNewPrice">
    </wsdl:input>
      <wsdl:output name="publishNewPriceResponse" message="tns:publishNewPriceResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="PropertySetterImplServiceSoapBinding" type="tns:PropertySetter">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="publishNewDescription">
         <wsdl:input>
               <soap:header message="tns:securityHeader" part="security" use="literal"/>
         </wsdl:input>
      </wsdl:operation>
      <wsdl:operation name="publishNewImageURL">
         <wsdl:input>
               <soap:header message="tns:securityHeader" part="security" use="literal"/>
         </wsdl:input>
      </wsdl:operation>
      <wsdl:operation name="publishNewPrice">
         <wsdl:input>
               <soap:header message="tns:securityHeader" part="security" use="literal"/>
         </wsdl:input>
      </wsdl:operation>
   </wsdl:binding>
  <wsdl:service name="PropertySetterImplService">
    <wsdl:port name="PropertySetterImplPort" binding="tns:PropertySetterImplServiceSoapBinding">
      <soap:address location="http://localhost:8080/eshopCXFService/services"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

And now I am trying to generate Web Service Client using CXF in Eclipse with Java 8. However instead of generated code I get an error:

WSDLToJava Error: WSI-BP-1.0 R2209 violation: Unbound PortType elements in Operation 'publishNewDescription'

org.apache.cxf.tools.common.ToolException: WSI-BP-1.0 R2209 violation: Unbound PortType elements in Operation 'publishNewDescription'
    at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:140)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:207)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:193)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:402)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:185)

Does anyone know what is wrong? I am able to connect and use the service using SoapUI (via WSDL) with no problem. Happy to send more info if needed.

Answer

Based on the error message I assume the web service you have there isn’t fully WSI compliant. See http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html, rule R2209:

A wsdl:binding in a DESCRIPTION SHOULD bind every wsdl:part of a wsdl:message in the wsdl:portType to which it refers to one of soapbind:body, soapbind:header, soapbind:fault or soapbind:headerfault.

The web service runs and you can call it with any client that can send it the expected SOAP message, it’s just that the service doesn’t respect interoperability specifications.

It’s been a while since I troubleshooted WSDLs for interoperability, but I think you need to add a <soap:body use="literal"/> to <wsdl:input> and <wsdl:output> in your <wsdl:operation>s.

If you don’t control the web service then that’s not something you can do. You might try to run WSDLToJava without the -validate flag to see if it generates the code.



Source: stackoverflow