You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Brian Shields <br...@geminga.it.nuigalway.ie> on 2006/03/12 16:06:44 UTC

axis2 and mtom

Hi all,
I am having some trouble sending attachments with axis2 messages. Until 
now I have been sending a large xml string as a parameter of a web 
service call. I recently applied security to this and I am getting a lot 
of errors when the string parameter goes beyond a certain size. What I 
am exploring as a work around is sending the xml file as an attachment 
using MTOM. From some v quick research i think this is the best approach 
when security is involved.
My problem is on the parsing of this message. I am getting a "ContentID 
is null" message. Is this because I have not specified the MIME type in 
the Client? My client code looks like...

OMElement value = fac.createOMElement("Text", omNs);
DataHandler dh = new DataHandler(new ByteArrayDataSource(s.getBytes()));
OMText text = fac.createText(dh, true);
value.addChild(text);
where s is a String.

The server code to parse this looks like...
OMElement binaryElement = element.getFirstElement();
OMText binaryNode = (OMText) binaryElement.getFirstOMChild();
DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();

Anybody see any problems in this?
Regards,
Brian.

-- 
Brian Shields BSc. MSc.,
PhD Candidate,
Department of Information Technology,
National University of Ireland,
Galway,
Ireland.

Re: axis2 and mtom

Posted by Brian Shields <br...@geminga.it.nuigalway.ie>.
Thanks Thilina,
MTOM was obviously not switched by default in my deployment.
I will explore Secure MTOM, it seems perfect for my needs.
Regards,
Brian.

Thilina Gunarathne wrote:

> Hi Brian,
> See my comments below...
>  
> On 3/12/06, *Brian Shields* <brian.shields@geminga.it.nuigalway.ie 
> <ma...@geminga.it.nuigalway.ie>> wrote:
>
>     Hi all,
>     I am having some trouble sending attachments with axis2 messages.
>     Until
>     now I have been sending a large xml string as a parameter of a web
>     service call. I recently applied security to this and I am getting
>     a lot
>     of errors when the string parameter goes beyond a certain size. What I
>     am exploring as a work around is sending the xml file as an
>     attachment
>     using MTOM. From some v quick research i think this is the best
>     approach
>     when security is involved.
>
>  
> You can also consider using Secure MTOM directly if you r going for 
> encryption... An encrypted payload(cipher value) is a binary content. 
> Normally in the context of web services people encode the 
> payloadcipher value using base64 and send it..Now with MTOM we can 
> directly send the encrypted payload as an binary attachment. Axis2 
> provides secure MTOM support...
>
>     My problem is on the parsing of this message. I am getting a
>     "ContentID
>     is null" message. Is this because I have not specified the MIME
>     type in
>     the Client? 
>
>  
> AFAIK this does not matter a lot when using data handlers...
>
>     My client code looks like...
>
>     OMElement value = fac.createOMElement("Text", omNs);
>     DataHandler dh = new DataHandler(new ByteArrayDataSource(
>     s.getBytes()));
>     OMText text = fac.createText(dh, true);
>     value.addChild(text);
>     where s is a String.
>
>     The server code to parse this looks like...
>     OMElement binaryElement = element.getFirstElement();
>     OMText binaryNode = (OMText) binaryElement.getFirstOMChild();
>
>  
> >>> binaryNode.setOptimize(true);
>
>     DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();
>
>  
> Do u have MTOM enabled in the client side. MTOM is switched ON by 
> default , but it's worth checking... You can use HttpTracer (aka 
> TCPMON) to see the wire level message. For me it seems ur message 
> still transmits without MTOM optimisation.
>  
> You can try doing a hack by adding this line in between the 3d and 4th 
> lines in the above given server code...
> binaryNode.setOptimize(true);
>  
> I don't recomend this usage in the long run.. But give it a try.. If 
> it does not give the same error, then it means ur message was not 
> optimized earlier...
>  
>  
> ~Thilina
>
>
> -- 
> "May the SourcE be with u"            
> http://webservices.apache.org/~thilina/ 
> <http://webservices.apache.org/%7Ethilina/>
> http://thilinag.blogspot.com/                 
> http://www.bloglines.com/blog/Thilina              


-- 
Brian Shields BSc. MSc.,
PhD Candidate,
Department of Information Technology,
National University of Ireland,
Galway,
Ireland.

Re: axis2 and mtom

Posted by Thilina Gunarathne <cs...@gmail.com>.
Hi Brian,
See my comments below...

On 3/12/06, Brian Shields <br...@geminga.it.nuigalway.ie> wrote:
>
> Hi all,
> I am having some trouble sending attachments with axis2 messages. Until
> now I have been sending a large xml string as a parameter of a web
> service call. I recently applied security to this and I am getting a lot
> of errors when the string parameter goes beyond a certain size. What I
> am exploring as a work around is sending the xml file as an attachment
> using MTOM. From some v quick research i think this is the best approach
> when security is involved.


You can also consider using Secure MTOM directly if you r going for
encryption... An encrypted payload(cipher value) is a binary content.
Normally in the context of web services people encode the payloadcipher
value using base64 and send it..Now with MTOM we can directly send the
encrypted payload as an binary attachment. Axis2 provides secure MTOM
support...

My problem is on the parsing of this message. I am getting a "ContentID
> is null" message. Is this because I have not specified the MIME type in
> the Client?


AFAIK this does not matter a lot when using data handlers...

My client code looks like...
>
> OMElement value = fac.createOMElement("Text", omNs);
> DataHandler dh = new DataHandler(new ByteArrayDataSource(s.getBytes()));
> OMText text = fac.createText(dh, true);
> value.addChild(text);
> where s is a String.
>
> The server code to parse this looks like...
> OMElement binaryElement = element.getFirstElement();
> OMText binaryNode = (OMText) binaryElement.getFirstOMChild();


>>> binaryNode.setOptimize(true);

DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();


Do u have MTOM enabled in the client side. MTOM is switched ON by default ,
but it's worth checking... You can use HttpTracer (aka TCPMON) to see the
wire level message. For me it seems ur message still transmits without MTOM
optimisation.

You can try doing a hack by adding this line in between the 3d and 4th lines
in the above given server code...
binaryNode.setOptimize(true);

I don't recomend this usage in the long run.. But give it a try.. If it does
not give the same error, then it means ur message was not optimized
earlier...


~Thilina


--
"May the SourcE be with u"
http://webservices.apache.org/~thilina/
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina