Kamo Maputle
Kamo Maputle

Reputation: 1

How call wsdl with ws security apache camel

Am trying to call wsdl service which has ws security from apache camel without using apache cxf as an endpoint.

How is this done?

Thanks in advance.

Upvotes: 0

Views: 1006

Answers (1)

gusto2
gusto2

Reputation: 12075

from apache camel without using apache cxf

Camel is an integration framework (passing messages between endpoints). Camel itelf is not able to call any external service without the Camel endpoint (which is piece of logic knowing how to call specific service/technology)

So - if you want to call a web service with security, you need some framework which would sign or validate the Soap messages (you really don't want to do that yourself)

Example how to do that with Camel and CXF: https://pastebin.com/ALcnzfVf ( this example is for exposing service, not consuming/calling, but the principle is the same and configuration very similar)

 <camelcxf:cxfEndpoint id="egovAddressEndpoint"
                     address="/egov/api/external/AddressService"
                     xmlns:addr="http://address.ws.egov.xxx.com/v1_0/ws"
                     serviceName="addr:eGovAddressService"
                     endpointName="addr:AddressServicePortBinding" 
serviceClass="com.xxx.egov.ws.address.v1_0.ws.EGovAddressService">
    <!--        wsdlURL="classpath:com/xxx/egov/ws/address/v1_0/AddressService.wsdl"-->
    <camelcxf:properties>
        <entry key="dataFormat" value="PAYLOAD" />
<!-- maybe one of these is enough, I put both directives to be sure.
The intention is not to provide a password callback, but let the CXF
use an underlaying security context to authenticate and authorize users -->
        <entry key="ws-security.ut.no-callbacks" value="true"/>
        <entry key="ws-security.validate.token" value="false"/>
    </camelcxf:properties>
    <camelcxf:outInterceptors>
        <!--<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>-->
    </camelcxf:outInterceptors>
    <camelcxf:inInterceptors>
        <!--<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>-->
        <ref component-id="wsSecInterceptor" />
        <ref component-id="authenticationInterceptor"/>  
        <ref component-id="authorizationInterceptor" />          
    </camelcxf:inInterceptors>
</camelcxf:cxfEndpoint>

<bean id="wsSecInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
    <argument>
        <map>
            <entry key="action" value="UsernameToken"/>
            <entry key="passwordType" value="PasswordText"/>
        </map>
    </argument>
</bean>    

Upvotes: 1

Related Questions