Hi Colm,
I recently tried to modify the soap prefixes using an interceptor and a
setcontent method for message. I thought this will update the message but it
appears that it is not doing that.Take a look at the code you can try this
interceptor on any client request.
I choose this phase as at PRE-STREAM I get encrypted message.if you have
any examples that show how to modify the message (raw) that would be
Great!.Thanks for all your help.
/*---------------------------PrintOutMsg
.java-------------------------------- */
package com.trails.ws;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.xml.soap.SOAPMessage;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
public class PrintOutMsg extends AbstractSoapInterceptor {
public PrintOutMsg() {
super(Phase.USER_PROTOCOL);
}
public void handleMessage(SoapMessage message) throws Fault {
SOAPMessage sm = message.getContent(SOAPMessage.class);
try {
//String values = sm.getSOAPBody().getTextContent();
// System.out.println("Included values:" + values);
ByteArrayOutputStream out = new ByteArrayOutputStream();
sm.writeTo(out);
String mysoapMessage = new String(out.toByteArray());
System.out.println("------Soap Message START -------\n");
System.out.println(mysoapMessage);
System.out.println("------Soap Message END -------\n");
System.out.println("------Soap Message ALTER START -------\n");
mysoapMessage=mysoapMessage.replaceAll("soap:","s:");
mysoapMessage=mysoapMessage.replaceAll("soap=","s=");
System.out.println(mysoapMessage);
System.out.println("------Soap Message ALTER END -------\n");
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
out2.write(mysoapMessage.getBytes("UTF-8"));
message.setContent(String.class,mysoapMessage);
// message.setContent(InputStream.class,new
ByteArrayInputStream(mysoapMessage.getBytes()));
//message.setContent(OutputStream.class, out2);
SOAPMessage sm2 = message.getContent(SOAPMessage.class);
sm2.writeTo(System.out);
//System.out.println("---UNENCRYPTED OUT MESSAGE START----\n");
//sm.writeTo(System.out);
//System.out.println("\n---UNENCRYPTED OUT MESSAGE END----\n");
} catch (Exception e) {
throw new Fault(e);
}
}
}
//-----------------------End ------------------------------------------
Thank You
Mahesh
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-2-4-1-Client-is-giving-the-signature-or-decryption-was-invalid-tp4507027p4557345.html
Sent from the cxf-user mailing list archive at Nabble.com.