4

We are trying to invoke Secured Webservice using Camel CXf component. WSDL has wsp:Policy defined in it and I am able to successfully invoke service from soapUI by passing username/password but facing lot of problems if i try to invoke service using Camel-Cxf component or invoke using generated stub. Any help is appreciated.

WSDL has following policy defined in it.

            <wsp:Policy wsu:Id="WSHttpBinding_ReferenceLookupLists_policy">
                    <wsp:ExactlyOne>
                        <wsp:All>
                            <http:BasicAuthentication
                                xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/>
                            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                                <wsp:Policy>
                                    <sp:TransportToken>
                                        <wsp:Policy>
                                            <sp:HttpsToken RequireClientCertificate="false"/>
                                        </wsp:Policy>
                                    </sp:TransportToken>
                                    <sp:AlgorithmSuite>
                                        <wsp:Policy>
                                            <sp:Basic256/>
                                        </wsp:Policy>
                                    </sp:AlgorithmSuite>
                                    <sp:Layout>
                                        <wsp:Policy>
                                            <sp:Strict/>
                                        </wsp:Policy>
                                    </sp:Layout>
                                </wsp:Policy>
                            </sp:TransportBinding>
                            <wsaw:UsingAddressing/>
                        </wsp:All>
                    </wsp:ExactlyOne>
                </wsp:Policy>

Cxf endpoint in blueprint file:

        <camel-cxf:cxfEndpoint id="abclookupEndpoint"
                    wsdlURL="wsdl/abclookupLists.wsdl"
                    endpointName="tns:WSHttpBinding_abclookup"
                    serviceName="tns:abclookup"
                    address="http://abc.abc/2013/12/6/abclookup.svc"
                    xmlns:tns="http://abc.abc/2013/12/6/ServiceContracts/">
                <camel-cxf:outInterceptors>
                   <ref component-id="abcOutInterceptor"/>
                </camel-cxf:outInterceptors>
                <camel-cxf:properties>
                    <entry key="dataFormat" value="PAYLOAD"/>
                </camel-cxf:properties>
            </camel-cxf:cxfEndpoint>

Route Builder class which uses above defined cxf endpoint @Override public void configure() throws Exception {

    from("direct:retrieveData").routeId(getRouteId().concat("svc.refLookupList"))
            .log(LoggingLevel.DEBUG, "Entered into direct:retrieveData route")
            .setHeader("operationName", constant("GetCustomFieldDropdownList"))
            .setHeader("SOAPAction",constant(getSoapActionHeader()))
            .bean("soapRequestBean","constructRequest")
            .to("cxf:bean:abclookupEndpoint?username=aaaaaaaa&password=bbbbbbbb")
            .log(LoggingLevel.INFO, "Service Response : ${body}")
            .end();

Tried adding AuthorizationPolicy like below but did not help Map properties = new HashMap();

            AuthorizationPolicy authPolicy = new AuthorizationPolicy();
            authPolicy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_BASIC);
            authPolicy.setUserName("aaaaaaaa");
            authPolicy.setPassword("bbbbbbbb");
            authPolicy.setAuthorization("true");

            properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy",authPolicy);
            CxfEndpoint myCxfEp = (CxfEndpoint)getContext().getEndpoint("cxf:bean:abclookupEndpoint");
            myCxfEp.setProperties(properties);*/

Exception message in logs when tried to invoke serivce:

"No assertion builder for type  http://schemas.microsoft.com/ws/06/2004/policy/http}BasicAuthentication registered. Exception in thread "main" org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives"
user2997551
  • 109
  • 1
  • 7

0 Answers0