SOAP headers

View: New views
3 Messages — Rating Filter:   Alert me  

SOAP headers

by bug_bug_bug :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



I have component exposed with cxf inbound and has a cxf outbound as well.

the outbound WS requires a set of special fields in header for auth (this is provided by third party, so i cant change it) something like :

  <soapenv:Header>
  <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/secext">
    <wsse:UsernameToken>
      <wsse:Username>UserName</wsse:Username>
      <wsse:Password>319f4d26e3c536b5dd871bb2c52e3178</wsse:Password>
    </wsse:UsernameToken>
  </wsse:Security>
</soapenv:Header>


i want to add similiar thing in my request header before i send it to outbound.

Can somebody help me to achieve this please?

i am trying out "cxf:inInterceptors" and "cxf:outInterceptors" but nowhere i could get hold of the SOAPHeader.

any help would be great.

thanks in advance

Re: SOAP headers

by bug_bug_bug :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


ok, i found one solution to this after so much trial and error. again not sure whether its the right method. but its working for me. if anybody can suggest a better method, pls let me know.

First is add an interceptor in mule for cxf endpoint:

                        <cxf:outInterceptors>    
                             <spring:bean class="mulelocal.EchoInterceptor"/>
                       </cxf:outInterceptors>




inside the interceptor- handleMessage

         List l = message.getHeaders();
         Document d = DOMUtils.createDocument();
          Element  securityParent=  d.createElementNS("http://schemas.xmlsoap.org/ws/2002/secext","wsse:Security");  
          Element userNameToken = d.createElement("wsse:UserNameToken");
          securityParent.appendChild(userNameToken);
          Element userName = d.createElement("wsse:UserName");
          userName.setTextContent("S313563");
          userNameToken.appendChild(userName);
          Element password = d.createElement("wsse:Password");
          password.setTextContent("S313563-pass");
          userNameToken.appendChild(password);
          SoapHeader header = new SoapHeader (new QName("http://schemas.xmlsoap.org/ws/2002/secext", "Security" ,"wsse"),securityParent);
          l.add(header);



and the ouput trace gave soap request like this:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
      <mule:MULE_CORRELATION_ID>36bde261-3c35-11dd-baca-3180a1f23821</mule:MULE_CORRELATION_ID>
      <mule:MULE_CORRELATION_GROUP_SIZE>-1</mule:MULE_CORRELATION_GROUP_SIZE>
      <mule:MULE_CORRELATION_SEQUENCE>-1</mule:MULE_CORRELATION_SEQUENCE>
    </mule:header>
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/secext">
       <wsse:UserNameToken>
          <wsse:UserName>S313563</wsse:UserName>
          <wsse:Password>S313563-pass</wsse:Password>
       </wsse:UserNameToken>
    </wsse:Security>
  </soap:Header>
  <soap:Body>
      <ns2:echo xmlns:ns2="http://local/"><arg0>1</arg0></ns2:echo>
  </soap:Body>
</soap:Envelope>

RE: SOAP headers

by antoine.borg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

The concept of an interceptor is right but perhaps you could have obtained
the same result by using the MessageProperties Transformer
http://mule.mulesource.org/display/MULE2USER/Using+Transformers

HTH


Antoine Borg, Senior Consultant | Tel: +356 21334457 | Fax: +356 21 334156
ricston Ltd., Lincoln, 7 Ferdinand Grech Street, Lija LJA1142, MALTA
email: antoine.borg@... | blog: blog.ricston.com | web: ricston.com

-----Original Message-----
From: bug_bug_bug [mailto:S313563@...]
Sent: Tuesday, June 17, 2008 8:33 AM
To: user@...
Subject: Re: [mule-user] SOAP headers



ok, i found one solution to this after so much trial and error. again not
sure whether its the right method. but its working for me. if anybody can
suggest a better method, pls let me know.

First is add an interceptor in mule for cxf endpoint:

                        <cxf:outInterceptors>    
                             <spring:bean
class="mulelocal.EchoInterceptor"/>
                       </cxf:outInterceptors>



inside the interceptor- handleMessage

         List l = message.getHeaders();
         Document d = DOMUtils.createDocument();
          Element  securityParent=
d.createElementNS("http://schemas.xmlsoap.org/ws/2002/secext","wsse:Security
");  
          Element userNameToken = d.createElement("wsse:UserNameToken");
          securityParent.appendChild(userNameToken);
          Element userName = d.createElement("wsse:UserName");
          userName.setTextContent("S313563");
          userNameToken.appendChild(userName);
          Element password = d.createElement("wsse:Password");
          password.setTextContent("S313563-pass");
          userNameToken.appendChild(password);
          SoapHeader header = new SoapHeader (new
QName("http://schemas.xmlsoap.org/ws/2002/secext", "Security"
,"wsse"),securityParent);
          l.add(header);


and the ouput trace gave soap request like this:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
     
<mule:MULE_CORRELATION_ID>36bde261-3c35-11dd-baca-3180a1f23821</mule:MULE_CO
RRELATION_ID>
     
<mule:MULE_CORRELATION_GROUP_SIZE>-1</mule:MULE_CORRELATION_GROUP_SIZE>
      <mule:MULE_CORRELATION_SEQUENCE>-1</mule:MULE_CORRELATION_SEQUENCE>
    </mule:header>
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/secext">
       <wsse:UserNameToken>
          <wsse:UserName>S313563</wsse:UserName>
          <wsse:Password>S313563-pass</wsse:Password>
       </wsse:UserNameToken>
    </wsse:Security>
  </soap:Header>
  <soap:Body>
      <ns2:echo xmlns:ns2="http://local/"><arg0>1</arg0></ns2:echo>
  </soap:Body>
</soap:Envelope>
--
View this message in context:
http://www.nabble.com/SOAP-headers-tp17848187p17878980.html
Sent from the Mule - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email