You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Forum User <te...@gmail.com> on 2013/03/29 06:50:30 UTC

Provider with MTOM Stream

Hi,

We have a web service provider and its role is to modify some elements in
the soap payload and redirect (dispatch) the request to another  web
service (different machine). In most cases MTOM attachments are sent to the
provider.

My issue is, when a large attachment is sent (lets say 300MB), i don't want
to cache the attachment and then dispatch it. I want the stream sent to the
final web service with out first caching (storing) it in the Provider
layer.

How to accomplish this?

Setup.

Client (MTOM Enabled) ----------> WebServiceProvider (acting as proxy)
---------->WebService(MTOM Enabled)

Please advice.
Thanks,
Sam

Re: Provider with MTOM Stream

Posted by "sam.tech" <te...@gmail.com>.
Any suggestions???
On Mar 29, 2013 12:16 PM, "sam.tech [via CXF]" <
ml-node+s547215n5725610h84@n5.nabble.com> wrote:

> One additional piece of info. I am using Message Mode.
> I tried the stream mode and that did not dispatch attachments.
>
> @WebServiceProvider(portName = "ProxyProviderPort", serviceName =
> "ProxyProviderService", targetNamespace = "http://sandbox.aaa.com/proxy")
> @ServiceMode(Mode.MESSAGE)
> @MTOM
> public class MyProxyServiceProvider implements Provider<SOAPMessage> {
>         @Override
>         public SOAPMessage invoke(SOAPMessage request) {
>
>                   Dispatch<SOAPMessage> disp = service.createDispatch(xxx,
>                                         SOAPMessage.class,
> Service.Mode.MESSAGE,
>                                         new MTOMFeature(4000));
>                         return disp.invoke(request);
>        }
> }
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725610.html
>  To unsubscribe from Provider with MTOM Stream, click here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5725571&code=dGVjaGFjY3QxMjNAZ21haWwuY29tfDU3MjU1NzF8LTE4MzI4NzMyNg==>
> .
> NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725633.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Provider with MTOM Stream

Posted by Daniel Kulp <dk...@apache.org>.
On Apr 2, 2013, at 1:09 PM, "sam.tech" <te...@gmail.com> wrote:

> Thanks Daniel.
> Perfect. In PAYLOAD mode, and Source, the attachments are not saved on the
> proxy server and are streamed to the end service.
> What am i loosing/gaining by using Payload mode compared to Message mode? 

The main thing would be any SOAP Headers in the SOAP message.   Those would not be copied across.  (however, you could do something similar by grabbing the list of headers from the incoming message and set them on the request context of the dispatch.)   You'd have to decide if that's important or not for your situation.

Dan

> Thanks,
> Sam
> 
> 
> 
> On Mon, Apr 1, 2013 at 9:56 AM, Daniel Kulp [via CXF] <
> ml-node+s547215n5725641h45@n5.nabble.com> wrote:
> 
>> 
>> On Mar 29, 2013, at 3:16 PM, sam.tech <[hidden email]<http://user/SendEmail.jtp?type=node&node=5725641&i=0>>
>> wrote:
>> 
>>> One additional piece of info. I am using Message Mode.
>> 
>> That would likely be the issue.  With the SAAJ model, we have to fill in
>> the attachment collection of the SOAPMessage which would cause this
>> caching.
>> 
>> My SUGGESTION (and I'm not 100% sure this would work, please try and
>> report back) would be PAYLOAD mode using Source, but you would need to copy
>> the attachment collection yourself.   Using pure JAX-WS API's, you could
>> have the WebServiceContext injected (via an @Resource) and grab the
>> MessageContext.INBOUND_MESSAGE_ATTACHMENTS which would be a Map<String,
>> DataHandler> and then set that into the request context of the dispatch
>> object you are creating.
>> 
>> HOWEVER, you'd likely be better off dropping out of pure JAX-WS and doing:
>> 
>> Collection<Attachment> attachments =
>> PhaseInterceptorChain.getCurrentMessage().get(Message.ATTACHMENTS);
>> 
>> and then setting that onto the Dispay request context using the
>> Message.ATTACHMENTS key.
>> 
>> 
>> Dan
>> 
>> 
>>> I tried the stream mode and that did not dispatch attachments.
>>> 
>>> @WebServiceProvider(portName = "ProxyProviderPort", serviceName =
>>> "ProxyProviderService", targetNamespace = "http://sandbox.aaa.com/proxy")
>> 
>>> @ServiceMode(Mode.MESSAGE)
>>> @MTOM
>>> public class MyProxyServiceProvider implements Provider<SOAPMessage> {
>>> @Override
>>> public SOAPMessage invoke(SOAPMessage request) {
>>> 
>>>                 Dispatch<SOAPMessage> disp =
>> service.createDispatch(xxx,
>>> SOAPMessage.class, Service.Mode.MESSAGE,
>>> new MTOMFeature(4000));
>>> return disp.invoke(request);
>>>      }
>>> }
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>> http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725610.html
>> 
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
>> --
>> Daniel Kulp
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=5725641&i=1> -
>> http://dankulp.com/blog
>> 
>> Talend Community Coder - http://coders.talend.com
>> 
>> 
>> 
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> 
>> http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725641.html
>> To unsubscribe from Provider with MTOM Stream, click here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5725571&code=dGVjaGFjY3QxMjNAZ21haWwuY29tfDU3MjU1NzF8LTE4MzI4NzMyNg==>
>> .
>> NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>> 
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725697.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Provider with MTOM Stream

Posted by "sam.tech" <te...@gmail.com>.
Thanks Daniel.
Perfect. In PAYLOAD mode, and Source, the attachments are not saved on the
proxy server and are streamed to the end service.
What am i loosing/gaining by using Payload mode compared to Message mode?

Thanks,
Sam



On Mon, Apr 1, 2013 at 9:56 AM, Daniel Kulp [via CXF] <
ml-node+s547215n5725641h45@n5.nabble.com> wrote:

>
> On Mar 29, 2013, at 3:16 PM, sam.tech <[hidden email]<http://user/SendEmail.jtp?type=node&node=5725641&i=0>>
> wrote:
>
> > One additional piece of info. I am using Message Mode.
>
> That would likely be the issue.  With the SAAJ model, we have to fill in
> the attachment collection of the SOAPMessage which would cause this
> caching.
>
> My SUGGESTION (and I'm not 100% sure this would work, please try and
> report back) would be PAYLOAD mode using Source, but you would need to copy
> the attachment collection yourself.   Using pure JAX-WS API's, you could
> have the WebServiceContext injected (via an @Resource) and grab the
> MessageContext.INBOUND_MESSAGE_ATTACHMENTS which would be a Map<String,
> DataHandler> and then set that into the request context of the dispatch
> object you are creating.
>
> HOWEVER, you'd likely be better off dropping out of pure JAX-WS and doing:
>
> Collection<Attachment> attachments =
> PhaseInterceptorChain.getCurrentMessage().get(Message.ATTACHMENTS);
>
> and then setting that onto the Dispay request context using the
> Message.ATTACHMENTS key.
>
>
> Dan
>
>
> > I tried the stream mode and that did not dispatch attachments.
> >
> > @WebServiceProvider(portName = "ProxyProviderPort", serviceName =
> > "ProxyProviderService", targetNamespace = "http://sandbox.aaa.com/proxy")
>
> > @ServiceMode(Mode.MESSAGE)
> > @MTOM
> > public class MyProxyServiceProvider implements Provider<SOAPMessage> {
> > @Override
> > public SOAPMessage invoke(SOAPMessage request) {
> >
> >                  Dispatch<SOAPMessage> disp =
> service.createDispatch(xxx,
> > SOAPMessage.class, Service.Mode.MESSAGE,
> > new MTOMFeature(4000));
> > return disp.invoke(request);
> >       }
> > }
> >
> >
> >
> > --
> > View this message in context:
> http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725610.html
>
> > Sent from the cxf-user mailing list archive at Nabble.com.
>
> --
> Daniel Kulp
> [hidden email] <http://user/SendEmail.jtp?type=node&node=5725641&i=1> -
> http://dankulp.com/blog
>
> Talend Community Coder - http://coders.talend.com
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725641.html
>  To unsubscribe from Provider with MTOM Stream, click here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5725571&code=dGVjaGFjY3QxMjNAZ21haWwuY29tfDU3MjU1NzF8LTE4MzI4NzMyNg==>
> .
> NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725697.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Provider with MTOM Stream

Posted by Daniel Kulp <dk...@apache.org>.
On Mar 29, 2013, at 3:16 PM, sam.tech <te...@gmail.com> wrote:

> One additional piece of info. I am using Message Mode. 

That would likely be the issue.  With the SAAJ model, we have to fill in the attachment collection of the SOAPMessage which would cause this caching.

My SUGGESTION (and I'm not 100% sure this would work, please try and report back) would be PAYLOAD mode using Source, but you would need to copy the attachment collection yourself.   Using pure JAX-WS API's, you could have the WebServiceContext injected (via an @Resource) and grab the MessageContext.INBOUND_MESSAGE_ATTACHMENTS which would be a Map<String, DataHandler> and then set that into the request context of the dispatch object you are creating.

HOWEVER, you'd likely be better off dropping out of pure JAX-WS and doing:

Collection<Attachment> attachments = PhaseInterceptorChain.getCurrentMessage().get(Message.ATTACHMENTS);

and then setting that onto the Dispay request context using the Message.ATTACHMENTS key.  


Dan


> I tried the stream mode and that did not dispatch attachments. 
> 
> @WebServiceProvider(portName = "ProxyProviderPort", serviceName =
> "ProxyProviderService", targetNamespace = "http://sandbox.aaa.com/proxy")
> @ServiceMode(Mode.MESSAGE)
> @MTOM
> public class MyProxyServiceProvider implements Provider<SOAPMessage> {
> 	@Override
> 	public SOAPMessage invoke(SOAPMessage request) {
> 	
>                  Dispatch<SOAPMessage> disp = service.createDispatch(xxx, 
> 					SOAPMessage.class, Service.Mode.MESSAGE, 
> 					new MTOMFeature(4000));
> 			return disp.invoke(request);
>       }
> }
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725610.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Provider with MTOM Stream

Posted by "sam.tech" <te...@gmail.com>.
One additional piece of info. I am using Message Mode. 
I tried the stream mode and that did not dispatch attachments. 

@WebServiceProvider(portName = "ProxyProviderPort", serviceName =
"ProxyProviderService", targetNamespace = "http://sandbox.aaa.com/proxy")
@ServiceMode(Mode.MESSAGE)
@MTOM
public class MyProxyServiceProvider implements Provider<SOAPMessage> {
	@Override
	public SOAPMessage invoke(SOAPMessage request) {
	
                  Dispatch<SOAPMessage> disp = service.createDispatch(xxx, 
					SOAPMessage.class, Service.Mode.MESSAGE, 
					new MTOMFeature(4000));
			return disp.invoke(request);
       }
}



--
View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725610.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Provider with MTOM Stream

Posted by "sam.tech" <te...@gmail.com>.
Hi Freeman,
Is there a special setting/property for activating delegate?

When I define my endpoint as below, the temp directory in tomcat is where
CXF is caching the files before its sending to the final webService. No
different than what i had before, except the files are cached in a different
directory

 <jaxws:endpoint id="myProxy"
                implementor="com.aaa.test.ProxyServiceProvider"
                address="/myProxy" >
                <jaxws:properties>
                        <entry key="mtom-enabled" value="true" />
                </jaxws:properties>
</jaxws:endpoint>

Any SUggestions?

Thanks,
Sam




--
View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725609.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Provider with MTOM Stream

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

I believe the stream way is already how it works by default
If your incoming message only have one attachment, this attachment won't be cached by default, it's just in underlying transport input stream, you can dispatch it to any target webservice using stream way(which means no cache in your proxy).

Here is a blog[1] about how CXF mtom works,  you may wanna take a look.

[1]http://ext2xhb.wordpress.com/2011/06/08/using-cxf-attachment-safely/
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

On 2013-3-29, at 下午1:55, sam.tech wrote:

> Please Advice
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725572.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: Provider with MTOM Stream

Posted by "sam.tech" <te...@gmail.com>.
Please Advice



--
View this message in context: http://cxf.547215.n5.nabble.com/Provider-with-MTOM-Stream-tp5725571p5725572.html
Sent from the cxf-user mailing list archive at Nabble.com.