You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kazvis <va...@gmail.com> on 2016/05/19 18:31:15 UTC

How to set username password in custom SOAP header from cxf endpoint and camel route to call external webservice

Hi ,

i want to call a external SOAP service from camel route. i have imported
corresponding java objects in my project. I am using the CXF component to
call that SOAP service and need to send a username password as a custom soap
header. so give me the approach. i here by attached the soap header format.
thanks in advance.  


<soapenv:Header>
      <ns:ServiceAuthHeader>
         
         <ns:UserName>username</ns:UserName>
         
         <ns:Password>password</ns:Password>
      </ns:ServiceAuthHeader>
   </soapenv:Header>




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-set-username-password-in-custom-SOAP-header-from-cxf-endpoint-and-camel-route-to-call-externae-tp5782793.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to set username password in custom SOAP header from cxf endpoint and camel route to call external webservice

Posted by Matt Sicker <bo...@gmail.com>.
I never figured out how to do it via CXF, but I once used a workaround by
just bypassing SOAP altogether and posting the SOAP XML straight over HTTP
instead.

On 19 May 2016 at 13:31, kazvis <va...@gmail.com> wrote:

> Hi ,
>
> i want to call a external SOAP service from camel route. i have imported
> corresponding java objects in my project. I am using the CXF component to
> call that SOAP service and need to send a username password as a custom
> soap
> header. so give me the approach. i here by attached the soap header format.
> thanks in advance.
>
>
> <soapenv:Header>
>       <ns:ServiceAuthHeader>
>
>          <ns:UserName>username</ns:UserName>
>
>          <ns:Password>password</ns:Password>
>       </ns:ServiceAuthHeader>
>    </soapenv:Header>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-set-username-password-in-custom-SOAP-header-from-cxf-endpoint-and-camel-route-to-call-externae-tp5782793.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Matt Sicker <bo...@gmail.com>

Re: How to set username password in custom SOAP header from cxf endpoint and camel route to call external webservice

Posted by Joseph Kampf <jo...@gmail.com>.
Another option is to create a List of org.apache.cxf.binding.soap.SoapHeader and put it into the Camel Headers under: org.apache.cxf.headers.Header.HEADER_LIST

The Camel CXF component will add the SOAP Header to the SOAP Envelop.


Joe



On 5/24/16, 10:06 AM, "dmitriyC300" <dm...@gmail.com> wrote:

>You could do that via cxf out interceptor.  You would need to create an
>intercepter that will construct your soap header and register it with your
>client(see camel cxf docs).  When your client sends a request, interceptor
>will inject the soap header based on defined instructions.
>
>Example:
>public class YourSecurityInterceptor extends
>AbstractPhaseInterceptor<Message> {
>    public YourSecurityInterceptor() {
>        super(Phase.PRE_PROTOCOL);
>    }
>public void handleMessage(SoapMessage mc) {
>    List<Header> list = mc.getHeaders(); 
>    ServiceAuthHeader auth = new ServiceAuthHeader();
>    auth.setUserName("username");
>    auth.setPassword("password");
>    SoapHeader newHeader = new SoapHeader(new QName("namespace",
>"name"),auth, new JAXBDataBinding(ServiceAuthHeader.class));
>    newHeader.setDirection(Direction.DIRECTION_IN);
>    list.add(newHeader);
>}
>}
>
>Dmitriy
>
>
>
>--
>View this message in context: http://camel.465427.n5.nabble.com/How-to-set-username-password-in-custom-SOAP-header-from-cxf-endpoint-and-camel-route-to-call-externae-tp5782793p5783040.html
>Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to set username password in custom SOAP header from cxf endpoint and camel route to call external webservice

Posted by dmitriyC300 <dm...@gmail.com>.
You could do that via cxf out interceptor.  You would need to create an
intercepter that will construct your soap header and register it with your
client(see camel cxf docs).  When your client sends a request, interceptor
will inject the soap header based on defined instructions.

Example:
public class YourSecurityInterceptor extends
AbstractPhaseInterceptor<Message> {
    public YourSecurityInterceptor() {
        super(Phase.PRE_PROTOCOL);
    }
public void handleMessage(SoapMessage mc) {
    List<Header> list = mc.getHeaders(); 
    ServiceAuthHeader auth = new ServiceAuthHeader();
    auth.setUserName("username");
    auth.setPassword("password");
    SoapHeader newHeader = new SoapHeader(new QName("namespace",
"name"),auth, new JAXBDataBinding(ServiceAuthHeader.class));
    newHeader.setDirection(Direction.DIRECTION_IN);
    list.add(newHeader);
}
}

Dmitriy



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-set-username-password-in-custom-SOAP-header-from-cxf-endpoint-and-camel-route-to-call-externae-tp5782793p5783040.html
Sent from the Camel - Users mailing list archive at Nabble.com.