I want to extract the soap body or input xml and appended a new tag to XML I
have tried the interceptor to implement it but have no much success.Find
below my code 

public class AddPolicyNodeInterceptor extends AbstractSoapInterceptor {
        private SAAJInInterceptor saajIn = new SAAJInInterceptor();
        String samlAssertion;

        AddPolicyNodeInterceptor() {

                super(Phase.POST_PROTOCOL);
                public void handleMessage(SoapMessage message) {

                SOAPMessage saaj = message.getContent(SOAPMessage.class);
                if (saaj == null) {
                        saajIn.handleMessage(message);
                        saaj = message.getContent(SOAPMessage.class);

                }

                Document document = saaj.getSOAPPart();

                NodeList nodes = document.getElementsByTagName("storePolicy");

                if (nodes.getLength() == 1) {

                        Node wsseSecurityNode = nodes.item(0);
                        XPath xpath = XPathFactory.newInstance().newXPath();
                        Node samlAssertionNode;
                        try {
                                samlAssertionNode = (Node) xpath.evaluate("//*",
                                                new InputSource(new 
StringReader(samlAssertion)),
                                                XPathConstants.NODE);
                                
wsseSecurityNode.appendChild(document.importNode(
                                                samlAssertionNode, true));

                        } catch (XPathExpressionException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }

                }
        }

}       }

CXF.xml


<jaxws:inInterceptors>                  
                
               <bean id="saajInInterceptor" 
                        
class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/> 
        <ref bean="sampleInterceptor"/> 
                   <bean 
class="com.agcs.fo.interceptor.AddPolicyNodeInterceptor"/>
              <ref bean="sample"/> 
             
</jaxws:inInterceptors> 



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Interceptor-to-add-new-tag-to-request-xml-tp5749130.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Reply via email to