You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ychawla <pr...@yahoo.com> on 2012/08/29 00:05:59 UTC

Re: WS-Addressing and One Way

Hello All,
I am currently using cxf 2.4.x and locked into ServiceMix 4.4.1.  I am
having issues with .NET integration because a one way operation is sending
back a WS-Addressing message.  I realize that an upgrade to CXF 2.5.x will
solve this problem.  However I don't have this option now.

Can I somehow handle this in an interceptor?  I would like to change the
HTTP status to 202 and remove the soap message.

I tried something like this, but I don't think I quite know how to modify
the message:


public class RemoveSoapMessageForOneWayResponse extends
AbstractSoapInterceptor {

    public RemoveSoapMessageForOneWayResponse() {
        super(Phase.PRE_STREAM);
        addBefore(Arrays.asList(StaxOutInterceptor.class.getName(),
AttachmentOutInterceptor.class.getName()));
    }

    @Override
    public void handleMessage(SoapMessage message) throws Fault {

         message.setContent(String.class, "");
    }

    protected <T> T createSoapMessage(Class<T> messageType) {
        // create your message
        return null;
    }

}

I was also thinking of using the transformation capabilities:
http://cxf.apache.org/docs/transformationfeature.html

However, I couldn't see how to limit this to a single CXF endpoint.  My
application currently has many CXF endpoints.

Any ideas on what to try next?

Thanks,
Yogesh



--
View this message in context: http://cxf.547215.n5.nabble.com/WS-Addressing-and-One-Way-tp5646635p5713278.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WS-Addressing and One Way

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

To configure transformation feature per each cxf endpoint, you can do something like
   <jaxws:endpoint ...>
      <jaxws:features>
       <bean class="org.apache.cxf.feature.StaxTransformFeature"/>
      </jaxws:features>
    </jaxws:endpoint>

Also, if you want to use CXF 2.5.x in OSGi container, you can start from Karaf easily, add cxf features.xml to Karaf and install cxf feature there.
Another option is use FUSE ESB 7.x which support CXF 2.5.x OOTB.

Freeman
-------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-8-29, at 上午6:05, ychawla wrote:

> Hello All,
> I am currently using cxf 2.4.x and locked into ServiceMix 4.4.1.  I am
> having issues with .NET integration because a one way operation is sending
> back a WS-Addressing message.  I realize that an upgrade to CXF 2.5.x will
> solve this problem.  However I don't have this option now.
> 
> Can I somehow handle this in an interceptor?  I would like to change the
> HTTP status to 202 and remove the soap message.
> 
> I tried something like this, but I don't think I quite know how to modify
> the message:
> 
> 
> public class RemoveSoapMessageForOneWayResponse extends
> AbstractSoapInterceptor {
> 
>    public RemoveSoapMessageForOneWayResponse() {
>        super(Phase.PRE_STREAM);
>        addBefore(Arrays.asList(StaxOutInterceptor.class.getName(),
> AttachmentOutInterceptor.class.getName()));
>    }
> 
>    @Override
>    public void handleMessage(SoapMessage message) throws Fault {
> 
>         message.setContent(String.class, "");
>    }
> 
>    protected <T> T createSoapMessage(Class<T> messageType) {
>        // create your message
>        return null;
>    }
> 
> }
> 
> I was also thinking of using the transformation capabilities:
> http://cxf.apache.org/docs/transformationfeature.html
> 
> However, I couldn't see how to limit this to a single CXF endpoint.  My
> application currently has many CXF endpoints.
> 
> Any ideas on what to try next?
> 
> Thanks,
> Yogesh
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WS-Addressing-and-One-Way-tp5646635p5713278.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: WS-Addressing and One Way

Posted by siddharthrajjain <si...@yahoo.com>.
How do we support the scenario where client are expecting 200 in
response(basically the old behavior) and service has moved to 2.5 and above
version ?



--
View this message in context: http://cxf.547215.n5.nabble.com/WS-Addressing-and-One-Way-tp5646635p5738633.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WS-Addressing and One Way

Posted by ychawla <pr...@yahoo.com>.
Hi Aki and Freeman,
Thanks for the help.  The transform didn't work out for me.  It would remove
elements but still leave empty elements like <>.  I don't think it was
designed to strip out an entire response message.  However, I am glad I got
to learn about the transformer.  It is a really great addition to CXF.

I updated my customer interceptor to set a 202 and empty outputstream (this
is based on the TransformOutInterceptor).  In case anyone is interested,
here it is:

public class RemoveSoapMessageForOneWayResponse extends
AbstractSoapInterceptor {

    private static final String OUTPUT_STREAM_HOLDER = 
        TransformOutInterceptor.class.getName() + ".outputstream";
	
    public RemoveSoapMessageForOneWayResponse() {
        super(Phase.PRE_STREAM);
        addBefore(Arrays.asList(StaxOutInterceptor.class.getName(),
AttachmentOutInterceptor.class.getName()));
    }

    @Override
    public void handleMessage(SoapMessage message) throws Fault {
                
        if (null != message.getContent(Exception.class)) {
            return;
        }
        
        OutputStream os = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
        
        os = convertStringtoStream("");
        
        if (os != null) {
            message.setContent(OutputStream.class, os);
        }

        message.put(Message.RESPONSE_CODE, 202); 
    }

    private static OutputStream convertStringtoStream(String string) {
        byte[] stringByte = string.getBytes();
        ByteArrayOutputStream bos = new
ByteArrayOutputStream(string.length());
        try {
			bos.write(stringByte);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return bos;
    }



--
View this message in context: http://cxf.547215.n5.nabble.com/WS-Addressing-and-One-Way-tp5646635p5713326.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WS-Addressing and One Way

Posted by Aki Yoshida <el...@gmail.com>.
Hi,
I don't think the transform feature will help you here because it
can't be used to empty the content or set the status code.

What might work in CXF 2.4 is to set the http status code in the
message through your interceptor that is invoked for the partial
response (the empty response to your oneway request) that is sent back
to the servlet entry during the oneway processing.

you can set the status of this message

message.put(Message.RESPONSE_CODE, 202);

regards, aki

2012/8/29 ychawla <pr...@yahoo.com>:
> Hello All,
> I am currently using cxf 2.4.x and locked into ServiceMix 4.4.1.  I am
> having issues with .NET integration because a one way operation is sending
> back a WS-Addressing message.  I realize that an upgrade to CXF 2.5.x will
> solve this problem.  However I don't have this option now.
>
> Can I somehow handle this in an interceptor?  I would like to change the
> HTTP status to 202 and remove the soap message.
>
> I tried something like this, but I don't think I quite know how to modify
> the message:
>
>
> public class RemoveSoapMessageForOneWayResponse extends
> AbstractSoapInterceptor {
>
>     public RemoveSoapMessageForOneWayResponse() {
>         super(Phase.PRE_STREAM);
>         addBefore(Arrays.asList(StaxOutInterceptor.class.getName(),
> AttachmentOutInterceptor.class.getName()));
>     }
>
>     @Override
>     public void handleMessage(SoapMessage message) throws Fault {
>
>          message.setContent(String.class, "");
>     }
>
>     protected <T> T createSoapMessage(Class<T> messageType) {
>         // create your message
>         return null;
>     }
>
> }
>
> I was also thinking of using the transformation capabilities:
> http://cxf.apache.org/docs/transformationfeature.html
>
> However, I couldn't see how to limit this to a single CXF endpoint.  My
> application currently has many CXF endpoints.
>
> Any ideas on what to try next?
>
> Thanks,
> Yogesh
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WS-Addressing-and-One-Way-tp5646635p5713278.html
> Sent from the cxf-user mailing list archive at Nabble.com.