1

Im creating a client API for a JAX-WS web service using wsimport tool(used the jaxws-maven-plugin:wsimport goal). The resulting API worked just fine. Now when security was introduced and wsimport run again on the updated WSDL file, I got an error:

[INFO] jaxws:wsimport args: [-s, C:\projects\EDMS2.0.0\docmgmt\docmgmt-client\src\main\java, -d, C:\projects\EDMS2.0.0\docmgmt\docmgmt-client\target\classes, -verbose, -p, com.abc.technology.retrieve.document.client.v1, C:\projects\EDMS\docmgmt\docmgmt-client\src\wsdl\RetrieveDocument\Technology-RetrieveDocument.wsdl]
parsing WSDL...


[ERROR] unknown required extensibility element "wsp:PolicyReference" (in namespace "http://www.w3.org/ns/ws-policy")
  line 65 of file:/C:/projects/EDMS/docmgmt/docmgmt-client/src/wsdl/RetrieveDocument/Technology-RetrieveDocument.wsdl

    Failed to parse the WSDL.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------`

WSDL file:

<?xml version='1.0' encoding='UTF-8'?>
<wsdl11:definitions xmlns:wsdl11="http://schemas.xmlsoap.org/wsdl/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:whttp="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http:/schemas.xmlsoap.org/wsdl/mime/"
   xmlns:tns="http://services.abc.com/Technology/RetrieveDocument/service/v1"
   xmlns:wsp="http://www.w3.org/ns/ws-policy" targetNamespace="http://services.abc.com/Technology/RetrieveDocument/service/v1"
   xmlns:exceptions="http://services.abc.com/exceptions" xmlns:abc="http://services.abc.com/framework/abcHeader/v2"
   xmlns:contract="http://services.abc.com/Technology/RetrieveDocument/contract/v1">  <!--BEGIN ABSTRACT DESCRIPTION-->
  <wsdl11:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:contract="http://services.abc.com/Technology/RetrieveDocument/contract/v1"
       targetNamespace="http://services.abc.com/Technology/RetrieveDocument/contract/v1">
      <xsd:include schemaLocation="RetrieveDocument_v1.xsd"/>
    </xsd:schema>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:exceptions="http://services.abc.com/exceptions"
       targetNamespace="http://services.abc.com/exceptions">
      <xsd:include schemaLocation="CnaExceptions.xsd"/>
    </xsd:schema>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abc="http://services.abc.com/framework/abcHeader/v2"
       targetNamespace="http://services.abc.com/framework/abcHeader/v2">
      <xsd:include schemaLocation="CnaHeader_v2.xsd"/>
    </xsd:schema>
  </wsdl11:types>
  <wsdl11:message name="retrieveDocument-inputHeader">
    <wsdl11:part name="To" element="abc:To"/>
    <wsdl11:part name="HeaderMetadata" element="abc:HeaderMetadata"/>
    <wsdl11:part name="ConsumerInfo" element="abc:ConsumerInfo"/>
  </wsdl11:message>
  <wsdl11:message name="retrieveDocument">
    <wsdl11:part name="body" element="contract:RetrieveDocument"/>
  </wsdl11:message>
  <wsdl11:message name="retrieveDocument-outputHeader">
    <wsdl11:part name="To" element="abc:To"/>
    <wsdl11:part name="HeaderMetadata" element="abc:HeaderMetadata"/>
    <wsdl11:part name="ConsumerInfo" element="abc:ConsumerInfo"/>
  </wsdl11:message>
  <wsdl11:message name="retrieveDocumentResponse">
    <wsdl11:part name="body" element="contract:RetrieveDocumentResponse"/>
  </wsdl11:message>
  <wsdl11:message name="abcInvalidMessageException">
    <wsdl11:part name="body" element="exceptions:CfInvalidMessageException"/>
  </wsdl11:message>
  <wsdl11:message name="abcServiceException">
    <wsdl11:part name="body" element="exceptions:CfServiceException"/>
  </wsdl11:message>
  <wsdl11:message name="abcProducerApplicationException">
    <wsdl11:part name="body" element="exceptions:CfProducerApplicationException"/>
  </wsdl11:message>
  <wsdl11:portType name="RetrieveDocument">
    <wsdl11:operation name="retrieveDocument">
      <wsdl11:input message="tns:retrieveDocument"/>
      <wsdl11:output message="tns:retrieveDocumentResponse"/>
      <wsdl11:fault message="tns:abcInvalidMessageException" name="abcInvalidMessageException"/>
      <wsdl11:fault message="tns:abcServiceException" name="abcServiceException"/>
      <wsdl11:fault message="tns:abcProducerApplicationException" name="abcProducerApplicationException"/>
    </wsdl11:operation>
  </wsdl11:portType>
  <!--END ABSTRACT DESCRIPTION-->
  <!--BEGIN BINDING DESCRIPTION-->
  <wsdl11:binding name="RetrieveDocumentSOAPBinding" type="tns:RetrieveDocument">
    <soap11:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl11:operation name="retrieveDocument">
      <soap11:operation soapAction="http://services.abc.com/Technology/RetrieveDocument/service/v1/soap11/RetrieveDocument./retrieveDocument"
           wsdl11:required="true" style="document"/>
      <wsdl11:input>
      <wsp:PolicyReference URI="abc-username-secure" wsdl11:required="true"/>
        <soap11:header use="literal" message="tns:retrieveDocument-inputHeader"
           part="To"/>
        <soap11:header use="literal" message="tns:retrieveDocument-inputHeader"
           part="HeaderMetadata"/>
        <soap11:header use="literal" message="tns:retrieveDocument-inputHeader"
           part="ConsumerInfo"/>
        <soap11:body use="literal"/>
      </wsdl11:input>
      <wsdl11:output>
        <soap11:header use="literal" message="tns:retrieveDocument-outputHeader"
           part="To"/>
        <soap11:header use="literal" message="tns:retrieveDocument-outputHeader"
           part="HeaderMetadata"/>
        <soap11:header use="literal" message="tns:retrieveDocument-outputHeader"
           part="ConsumerInfo"/>
        <soap11:body use="literal"/>
      </wsdl11:output>
      <wsdl11:fault name="abcInvalidMessageException">
        <soap11:fault name="abcInvalidMessageException" use="literal"/>
      </wsdl11:fault>
      <wsdl11:fault name="abcServiceException">
        <soap11:fault name="abcServiceException" use="literal"/>
      </wsdl11:fault>
      <wsdl11:fault name="abcProducerApplicationException">
        <soap11:fault name="abcProducerApplicationException" use="literal"/>
      </wsdl11:fault>
    </wsdl11:operation>
  </wsdl11:binding>
  <!--END BINDING DESCRIPTION-->

  <!--BEGIN SERVICE DESCRIPTION-->
  <wsdl11:service name="RetrieveDocument">
    <wsdl11:port name="RetrieveDocument" binding="tns:RetrieveDocumentSOAPBinding">
      <soap11:address location="dummy.url"/>
    </wsdl11:port>
  </wsdl11:service>

  <!--END SERVICE DESCRIPTION-->

  <wsp:Policy wsu:Id="abc-username-secure" xmlns:wsu=
     "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
      xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
      xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
    <wsp:ExactlyOne>
      <wsp:All>
        <!-- Empty <TransportBinding/> element required due to bug in CXF 2.2.6 -->
        <sp:TransportBinding/>
        <sp:SupportingTokens>
          <wsp:Policy>
            <sp:UsernameToken sp:IncludeToken=".../IncludeToken/AlwaysToRecipient"/>
          </wsp:Policy>
        </sp:SupportingTokens>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>


</wsdl11:definitions>

I did some research and tried switching on the extension switch in wsimport. After this the API was generated successfully. But after this authentication part was ignored by wsimport I think.

Please explain what the right procedure is to properly generate the client API when Web Service security is needed?

4
  • I think your plugin uses JDK's wsimport operation. But you may need CXF's wsdl2java operation. You may want to check this plugin as far as I know you can even invoke extensions.
    – bhdrkn
    Aug 6, 2015 at 13:29
  • What is the difference between the cxf and normal web service wsdl? Please forgive my limited knowledge in this matter. And im going to try and generate the pojos using cxf tool you mentioned.
    – knk
    Aug 7, 2015 at 5:30
  • I also have limited knowledge about this topic. From my perspective, they both support default wsdl to java conversion. But cxf, also support extended capabilities, like ws-securitypolicy. If you decide to use ws-security in your project you must use a more detailed tool than wsimport. And since you want to use CXF implementation it will be better to use wsdl2java tool of cxf. But before using it through maven plugin, you may want to use it from binaries which can be downloaded through this link.
    – bhdrkn
    Aug 7, 2015 at 6:44
  • Thanks :) I too figured that would be the solution. +1 to you(but I can't really :( Don't have enough points myself to be privileged)
    – knk
    Aug 9, 2015 at 16:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.