You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Rajneesh Kapur <ka...@gmail.com> on 2009/09/03 01:50:57 UTC

how to change content of outbound message...

Hi All,

I am unable to set content on the outbound message (from client)
OutputStream -- basically even though I do
message.setContent(OutputStream.class, myNewOutputStreamObject) - it does
not send this to server. It just sits and waits eventually timeout.


Also if I comment out this line ----> factory.getOutInterceptors().add(new
MessageOutInterceptor());
then client code send the request and server receives it.

(Also I want to do is change some content in message as the very last step
before it goes out to the server.)

Please point me to right direction.

*Here is the code on client:*

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getOutInterceptors().add(new MessageOutInterceptor());
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://192.168.134.24:9000/HelloWorld");
HelloWorld client = (HelloWorld) factory.create();

System.out.println("going to send message to service.");

client.echo(pixRequest);
System.out.println("message sent to service.");

*MessageOutInterceptor Class:*

public class MessageOutInterceptor extends
AbstractPhaseInterceptor<SoapMessage> {

public MessageOutInterceptor() {
        super(Phase.SEND);
    }

public void handleMessage(SoapMessage message) {

   message.removeContent(OutputStream.class);

    CachedOutputStream cos2 = new CachedOutputStream();
    cos2.write("test".getBytes());
    message.setContent(OutputStream.class, cos2);
}

}


Thanks a lot,
-rishi