« Return to Thread: SOAP headers

Re: SOAP headers

by bug_bug_bug :: Rate this Message:

Reply to Author | View in Thread


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>

 « Return to Thread: SOAP headers