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 Ivan Vasquez <iv...@itos.uga.edu> on 2006/07/05 16:17:25 UTC

Axis2: "ContentID is null" using MTOM

Hi, 

I'm using Axis2 to call a .Net service which returns a binary file. I've
read the documentation and followed the examples, and both parties are
using MTOM. But when my code runs:

OMElement elem = (OMElement)it.next();
...
OMText binaryNode = (OMText)elem.getFirstOMChild();
DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();

The last instruction causes:

java.lang.RuntimeException: ContentID is null
	at
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
339)
	at edu.uga.cviog.itos.ws.Client.foo(Client.java:87)
	at edu.uga.cviog.itos.ws.Client.main(Client.java:36)

>From what I see, the response message *does* have a "content-id" field
(below). Could you help me determine what's wrong? Here are the
exchanged messages:

AXIS2 Request (synchronous):

POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
User-Agent: Axis/2.0
Host: 127.0.0.1:8888
Transfer-Encoding: chunked
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
type="application/xop+xml";
start="<0....@apache.org>";
start-info="application/soap+xml";
charset=UTF-8;action="http://stockservice.contoso.com/wse/samples/2005/1
0/GetFile";

1d1
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
content-type:application/xop+xml; charset=UTF-8;
type="application/soap+xml";
content-transfer-encoding:binary
content-id:<0....@apache.org>
<?xml version='1.0' encoding='UTF-8'?>
         <soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
            <soapenv:Header />
            <soapenv:Body />
         </soapenv:Envelope> 
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491--
0

.NET Response:

HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: multipart/related; type="application/xop+xml";
boundary=--MIMEBoundary632876899223120893;
start="<0....@example.org>";
start-info="application/soap+xml; charset=utf-8"
Content-Length: 1569

----MIMEBoundary632876899223120893
content-id: <0....@example.org>
content-type: application/xop+xml; charset=utf-8;
type="application/soap+xml; charset=utf-8"
content-transfer-encoding: binary

<soap:Envelope xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
curity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
urity-utility-1.0.xsd">
         <env:Header
xmlns:env="http://www.w3.org/2003/05/soap-envelope">
 
<wsa:Action>http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
esponse</wsa:Action>
 
<wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
eID>
 
<wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate
sTo>
 
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous<
/wsa:To>
            <wsse:Security>
               <wsu:Timestamp
wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
                  <wsu:Created>2006-07-05T14:04:45Z</wsu:Created>
                  <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires>
               </wsu:Timestamp>
            </wsse:Security>
         </env:Header>
         <soap:Body>
            <GetFileResponse
xmlns="http://stockservice.contoso.com/wse/samples/2005/10">
               <getFileResponse>
                  <fileName>hola.txt</fileName>
                  <fileData>TmFocmdpcw==</fileData>
               </getFileResponse>
            </GetFileResponse>
         </soap:Body>
      </soap:Envelope>
----MIMEBoundary632876899223120893--


Thanks in advance,
Ivan

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: [Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Ivan Vasquez <iv...@itos.uga.edu>.
Sorry but I'm not. The best and only resource has been the WSE 3.0
download and samples, which will be located at:

 

<program_files>\Microsoft
WSE\v3.0\Samples\CS\QuickStart\Basic\BinaryDataMTOM

 

>From there I read and understood the service example, but there is a
client example too.

 

Ivan

 

________________________________

From: Tech Savvy [mailto:tech.savvy@gmail.com] 
Sent: Wednesday, July 05, 2006 3:14 PM
To: axis-user@ws.apache.org
Subject: Re: [Axiom]Re: Axis2: "ContentID is null" using MTOM

 

Ivan,

Thanks for your offer. Are you familiar with the .NET C# technology? I
need a jump start on how to quickly create a C# client to access a web
serivce, i.e. what to download/set up, a simple tutorial, etc...

Thanks.

Sunny *



On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote:

Sunny,

 

I will try that immediately. By the way, I have a working prototype of
MTOM from .Net to Axis2. Even though I see that you need the opposite
scenario, let me know if mine can help at all.

 

Thank you,

Ivan.

 

________________________________

From: Tech Savvy [mailto:tech.savvy@gmail.com] 
Sent: Wednesday, July 05, 2006 2:54 PM


To: axis-user@ws.apache.org

Subject: Re: [Axiom]Re: Axis2: "ContentID is null" using MTOM

 

Ivan,

In my experience, you can use OMText.isOptimized() to detect whether
MTOM is presented. If it is, it will return true. 

By the way, in the senario you describe, it seems like you shouldn't
need to worry about getting the handler and all that, if you simply want
to retrieve the binary data being sent back. The AXIS2 API will
automatically converted a MTOM soap back to standard SOAP so you client
is not affected by this underline transport technlogy. You can simply
get the OMText out and decoded with
org.apache.axis2.util.Base64.decode() to get the binary data out...

Of course if you choose, if OMText.isOptimized() returns true, you can
still get the hander to use the input stream to get the binary data out.
However this approach makes the client depends on or be awared of the
SOAP transport mechanism, which is not necessary... 

Thanks.

Sunny *

On 7/5/06, Ivan Vasquez < ivan@itos.uga.edu <ma...@itos.uga.edu> >
wrote:

Thilina,

 

In line with your comments, the .Net service seems to have a threshold.
For very small files (<700 bytes) it puts its base64 representation
inside the soap envelope. For larger files I get several MIME sections
as expected.

 

In Axis2/Axiom, is there a way to tell whether an MTOM attachment is
present?

 

Thank you!

Ivan.

 

________________________________

From: Thilina Gunarathne [mailto: csethil@gmail.com] 
Sent: Wednesday, July 05, 2006 1:43 PM
To: axis-user@ws.apache.org; commons-dev@ws.apache.org
Subject: [Axiom]Re: Axis2: "ContentID is null" using MTOM

 

Receiving binary can happen as either MTOM attachments or as Base64
encoded text. In the case of Base64 user has to explicitly specify that
the content is binary, before calling getDataHandler(),
getInputStream()....

 

As you can see in this message no MTOM attachments are present in the
response, eventhough a MIME envelope is used. Binary file is in lined
using base64 encoding.

         <fileData>TmFocmdpcw==</fileData>
 

You need to add the following before calling for getDataHandler.

             binaryNode.setOptimize(true);

 

Even though it works, IMHO above method is not the clean way to do
this.. Because of that I'm going to introduce the setBinary(boolean
value) method to OMText.. You will be able to get that method in SVN
head in couple of hours.  

 

~Thilina
    

On 7/5/06, Ivan Vasquez < ivan@itos.uga.edu <ma...@itos.uga.edu> >
wrote: 

Hi,

I'm using Axis2 to call a .Net service which returns a binary file. I've
read the documentation and followed the examples, and both parties are 
using MTOM. But when my code runs:

OMElement elem = (OMElement)it.next();
...
OMText binaryNode = (OMText)elem.getFirstOMChild();
DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();

The last instruction causes:

java.lang.RuntimeException: ContentID is null
       at
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
339)
       at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
       at edu.uga.cviog.itos.ws.Client.main(Client.java:36)

>From what I see, the response message *does* have a "content-id" field
(below). Could you help me determine what's wrong? Here are the 
exchanged messages:

AXIS2 Request (synchronous):

POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
User-Agent: Axis/2.0
Host: 127.0.0.1:8888 <http://127.0.0.1:8888/> 
Transfer-Encoding: chunked 
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
type="application/xop+xml";
start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org
<ma...@apache.org> >"; 
start-info="application/soap+xml";
charset=UTF-8;action="
http://stockservice.contoso.com/wse/samples/2005/1
<http://stockservice.contoso.com/wse/samples/2005/1> 
0/GetFile";

1d1
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
content-type:application/xop+xml; charset=UTF-8;
type="application/soap+xml"; 
content-transfer-encoding:binary 
content-id:<0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org > 
<?xml version='1.0' encoding='UTF-8'?>
        <soapenv:Envelope 
xmlns:soapenv=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> ">
           <soapenv:Header />
           <soapenv:Body />
        </soapenv:Envelope> 
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491-- 
0

.NET Response:

HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET <http://asp.net/> 

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET <http://asp.net/> 
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0 
Content-Type: multipart/related; type="application/xop+xml";
boundary=--MIMEBoundary632876899223120893;
start="< 0.632876899223120893@example.org
<ma...@example.org> >";
start-info="application/soap+xml; charset=utf-8"
Content-Length: 1569

----MIMEBoundary632876899223120893
content-id: < 0.632876899223120893@example.org
<ma...@example.org> >
content-type: application/xop+xml; charset=utf-8;
type="application/soap+xml; charset=utf-8"
content-transfer-encoding: binary

<soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
xmlns:soap=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> "
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing
<http://schemas.xmlsoap.org/ws/2004/08/addressing> "
xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse> 
curity-secext-1.0.xsd "
xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec> 
urity-utility-1.0.xsd">
        <env:Header 
xmlns:env=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> ">

<wsa:Action>
http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
<http://stockservice.contoso.com/wse/samples/2005/10/GetFileR> 
esponse</wsa:Action>

<wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
eID>

<wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate

sTo>

<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
<
/wsa:To>
           <wsse:Security> 
              <wsu:Timestamp
wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
                 <wsu:Created>2006-07-05T14:04:45Z</wsu:Created> 
                 <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires> 
              </wsu:Timestamp>
           </wsse:Security>
        </env:Header>
        <soap:Body>
           <GetFileResponse
xmlns=" http://stockservice.contoso.com/wse/samples/2005/10
<http://stockservice.contoso.com/wse/samples/2005/10> ">
              <getFileResponse>
                 <fileName>hola.txt</fileName>
                 <fileData>TmFocmdpcw==</fileData> 
              </getFileResponse> 
           </GetFileResponse>
        </soap:Body>
     </soap:Envelope>
----MIMEBoundary632876899223120893--


Thanks in advance,
Ivan

--------------------------------------------------------------------- 
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org




-- 
"May the SourcE be with u"             
http://people.apache.org/~thilina/
<http://people.apache.org/%7Ethilina/> 
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina                

 

 


Re: [Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Tech Savvy <te...@gmail.com>.
Ivan,

Thanks for your offer. Are you familiar with the .NET C# technology? I need
a jump start on how to quickly create a C# client to access a web serivce,
i.e. what to download/set up, a simple tutorial, etc...

Thanks.

Sunny *


On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote:
>
>  Sunny,
>
>
>
> I will try that immediately. By the way, I have a working prototype of
> MTOM from .Net to Axis2. Even though I see that you need the opposite
> scenario, let me know if mine can help at all.
>
>
>
> Thank you,
>
> Ivan.
>
>
>  ------------------------------
>
> *From:* Tech Savvy [mailto:tech.savvy@gmail.com]
> *Sent:* Wednesday, July 05, 2006 2:54 PM
>
> *To:* axis-user@ws.apache.org
> *Subject:* Re: [Axiom]Re: Axis2: "ContentID is null" using MTOM
>
>
>
> Ivan,
>
> In my experience, you can use OMText.isOptimized() to detect whether MTOM
> is presented. If it is, it will return true.
>
> By the way, in the senario you describe, it seems like you shouldn't need
> to worry about getting the handler and all that, if you simply want to
> retrieve the binary data being sent back. The AXIS2 API will automatically
> converted a MTOM soap back to standard SOAP so you client is not affected by
> this underline transport technlogy. You can simply get the OMText out and
> decoded with org.apache.axis2.util.Base64.decode() to get the binary data
> out...
>
> Of course if you choose, if OMText.isOptimized() returns true, you can
> still get the hander to use the input stream to get the binary data out.
> However this approach makes the client depends on or be awared of the SOAP
> transport mechanism, which is not necessary...
>
> Thanks.
>
> Sunny *
>
>  On 7/5/06, *Ivan Vasquez* <iv...@itos.uga.edu> wrote:
>
> Thilina,
>
>
>
> In line with your comments, the .Net service seems to have a threshold.
> For very small files (<700 bytes) it puts its base64 representation inside
> the soap envelope. For larger files I get several MIME sections as expected.
>
>
>
> In Axis2/Axiom, is there a way to tell whether an MTOM attachment is
> present?
>
>
>
> Thank you!
>
> Ivan.
>
>
>  ------------------------------
>
> *From:* Thilina Gunarathne [mailto:csethil@gmail.com]
> *Sent:* Wednesday, July 05, 2006 1:43 PM
> *To:* axis-user@ws.apache.org; commons-dev@ws.apache.org
> *Subject:* [Axiom]Re: Axis2: "ContentID is null" using MTOM
>
>
>
> Receiving binary can happen as either MTOM attachments or as Base64
> encoded text. In the case of Base64 user has to explicitly specify that the
> content is binary, before calling getDataHandler(), getInputStream()....
>
>
>
> As you can see in this message no MTOM attachments are present in the
> response, eventhough a MIME envelope is used. Binary file is in lined using
> base64 encoding.
>
>          <fileData>TmFocmdpcw==</fileData>
>
>
> You need to add the following before calling for getDataHandler.
>
>              binaryNode.setOptimize(true);
>
>
>
> Even though it works, IMHO above method is not the clean way to do this..
> Because of that I'm going to introduce the setBinary(boolean value) method
> to OMText.. You will be able to get that method in SVN head in couple of
> hours.
>
>
>
> ~Thilina
>
>
> On 7/5/06, *Ivan Vasquez* < ivan@itos.uga.edu> wrote:
>
> Hi,
>
> I'm using Axis2 to call a .Net service which returns a binary file. I've
> read the documentation and followed the examples, and both parties are
> using MTOM. But when my code runs:
>
> OMElement elem = (OMElement)it.next();
> ...
> OMText binaryNode = (OMText)elem.getFirstOMChild();
> DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();
>
> The last instruction causes:
>
> java.lang.RuntimeException: ContentID is null
>        at
> org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
> 339)
>        at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
>        at edu.uga.cviog.itos.ws.Client.main(Client.java:36)
>
> From what I see, the response message *does* have a "content-id" field
> (below). Could you help me determine what's wrong? Here are the
> exchanged messages:
>
> AXIS2 Request (synchronous):
>
> POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
> User-Agent: Axis/2.0
> Host: 127.0.0.1:8888
> Transfer-Encoding: chunked
> Content-Type: multipart/related;
> boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
> type="application/xop+xml";
> start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org>";
> start-info="application/soap+xml";
> charset=UTF-8;action=" http://stockservice.contoso.com/wse/samples/2005/1
> 0/GetFile";
>
> 1d1
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
> content-type:application/xop+xml; charset=UTF-8;
> type="application/soap+xml";
> content-transfer-encoding:binary
> content-id:<0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org >
> <?xml version='1.0' encoding='UTF-8'?>
>         <soapenv:Envelope
> xmlns:soapenv=" http://www.w3.org/2003/05/soap-envelope">
>            <soapenv:Header />
>            <soapenv:Body />
>         </soapenv:Envelope>
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491--
> 0
>
> .NET Response:
>
> HTTP/1.1 100 Continue
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
>
> HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
> X-AspNet-Version: 2.0.50727
> Cache-Control: private, max-age=0
> Content-Type: multipart/related; type="application/xop+xml";
> boundary=--MIMEBoundary632876899223120893;
> start="< 0.632876899223120893@example.org >";
> start-info="application/soap+xml; charset=utf-8"
> Content-Length: 1569
>
> ----MIMEBoundary632876899223120893
> content-id: < 0.632876899223120893@example.org >
> content-type: application/xop+xml; charset=utf-8;
> type="application/soap+xml; charset=utf-8"
> content-transfer-encoding: binary
>
> <soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
> xmlns:soap=" http://www.w3.org/2003/05/soap-envelope"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing"
> xmlns:wsse=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
> curity-secext-1.0.xsd "
> xmlns:wsu=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
> urity-utility-1.0.xsd">
>         <env:Header
> xmlns:env=" http://www.w3.org/2003/05/soap-envelope">
>
> <wsa:Action> http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
> esponse</wsa:Action>
>
> <wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
> eID>
>
> <wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate
> sTo>
>
> <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous <
> /wsa:To>
>            <wsse:Security>
>               <wsu:Timestamp
> wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
>                  <wsu:Created>2006-07-05T14:04:45Z</wsu:Created>
>                  <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires>
>               </wsu:Timestamp>
>            </wsse:Security>
>         </env:Header>
>         <soap:Body>
>            <GetFileResponse
> xmlns=" http://stockservice.contoso.com/wse/samples/2005/10 ">
>               <getFileResponse>
>                  <fileName>hola.txt</fileName>
>                  <fileData>TmFocmdpcw==</fileData>
>               </getFileResponse>
>            </GetFileResponse>
>         </soap:Body>
>      </soap:Envelope>
> ----MIMEBoundary632876899223120893--
>
>
> Thanks in advance,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>
> --
> "May the SourcE be with u"
> http://people.apache.org/~thilina/ <http://people.apache.org/%7Ethilina/>
> http://thilinag.blogspot.com/                 http://www.bloglines.com/blog/Thilina
>
>
>
>

RE: [Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Ivan Vasquez <iv...@itos.uga.edu>.
Sunny,

 

I will try that immediately. By the way, I have a working prototype of
MTOM from .Net to Axis2. Even though I see that you need the opposite
scenario, let me know if mine can help at all.

 

Thank you,

Ivan.

 

________________________________

From: Tech Savvy [mailto:tech.savvy@gmail.com] 
Sent: Wednesday, July 05, 2006 2:54 PM
To: axis-user@ws.apache.org
Subject: Re: [Axiom]Re: Axis2: "ContentID is null" using MTOM

 

Ivan,

In my experience, you can use OMText.isOptimized() to detect whether
MTOM is presented. If it is, it will return true. 

By the way, in the senario you describe, it seems like you shouldn't
need to worry about getting the handler and all that, if you simply want
to retrieve the binary data being sent back. The AXIS2 API will
automatically converted a MTOM soap back to standard SOAP so you client
is not affected by this underline transport technlogy. You can simply
get the OMText out and decoded with
org.apache.axis2.util.Base64.decode() to get the binary data out...

Of course if you choose, if OMText.isOptimized() returns true, you can
still get the hander to use the input stream to get the binary data out.
However this approach makes the client depends on or be awared of the
SOAP transport mechanism, which is not necessary... 

Thanks.

Sunny *



On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote:

Thilina,

 

In line with your comments, the .Net service seems to have a threshold.
For very small files (<700 bytes) it puts its base64 representation
inside the soap envelope. For larger files I get several MIME sections
as expected.

 

In Axis2/Axiom, is there a way to tell whether an MTOM attachment is
present?

 

Thank you!

Ivan.

 

________________________________

From: Thilina Gunarathne [mailto:csethil@gmail.com] 
Sent: Wednesday, July 05, 2006 1:43 PM
To: axis-user@ws.apache.org; commons-dev@ws.apache.org
Subject: [Axiom]Re: Axis2: "ContentID is null" using MTOM

 

Receiving binary can happen as either MTOM attachments or as Base64
encoded text. In the case of Base64 user has to explicitly specify that
the content is binary, before calling getDataHandler(),
getInputStream()....

 

As you can see in this message no MTOM attachments are present in the
response, eventhough a MIME envelope is used. Binary file is in lined
using base64 encoding.

         <fileData>TmFocmdpcw==</fileData>
 

You need to add the following before calling for getDataHandler.

             binaryNode.setOptimize(true);

 

Even though it works, IMHO above method is not the clean way to do
this.. Because of that I'm going to introduce the setBinary(boolean
value) method to OMText.. You will be able to get that method in SVN
head in couple of hours.  

 

~Thilina
    

On 7/5/06, Ivan Vasquez < ivan@itos.uga.edu <ma...@itos.uga.edu> >
wrote: 

Hi,

I'm using Axis2 to call a .Net service which returns a binary file. I've
read the documentation and followed the examples, and both parties are 
using MTOM. But when my code runs:

OMElement elem = (OMElement)it.next();
...
OMText binaryNode = (OMText)elem.getFirstOMChild();
DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();

The last instruction causes:

java.lang.RuntimeException: ContentID is null
       at
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
339)
       at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
       at edu.uga.cviog.itos.ws.Client.main(Client.java:36)

>From what I see, the response message *does* have a "content-id" field
(below). Could you help me determine what's wrong? Here are the 
exchanged messages:

AXIS2 Request (synchronous):

POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
User-Agent: Axis/2.0
Host: 127.0.0.1:8888 <http://127.0.0.1:8888/> 
Transfer-Encoding: chunked 
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
type="application/xop+xml";
start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org
<ma...@apache.org> >"; 
start-info="application/soap+xml";
charset=UTF-8;action="
http://stockservice.contoso.com/wse/samples/2005/1
<http://stockservice.contoso.com/wse/samples/2005/1> 
0/GetFile";

1d1
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
content-type:application/xop+xml; charset=UTF-8;
type="application/soap+xml"; 
content-transfer-encoding:binary 
content-id:<0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org > 
<?xml version='1.0' encoding='UTF-8'?>
        <soapenv:Envelope 
xmlns:soapenv=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> ">
           <soapenv:Header />
           <soapenv:Body />
        </soapenv:Envelope> 
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491-- 
0

.NET Response:

HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET <http://asp.net/> 

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET <http://asp.net/> 
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0 
Content-Type: multipart/related; type="application/xop+xml";
boundary=--MIMEBoundary632876899223120893;
start="< 0.632876899223120893@example.org
<ma...@example.org> >";
start-info="application/soap+xml; charset=utf-8"
Content-Length: 1569

----MIMEBoundary632876899223120893
content-id: < 0.632876899223120893@example.org
<ma...@example.org> >
content-type: application/xop+xml; charset=utf-8;
type="application/soap+xml; charset=utf-8"
content-transfer-encoding: binary

<soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
xmlns:soap=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> "
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing
<http://schemas.xmlsoap.org/ws/2004/08/addressing> "
xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse> 
curity-secext-1.0.xsd "
xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec> 
urity-utility-1.0.xsd">
        <env:Header 
xmlns:env=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> ">

<wsa:Action>
http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
<http://stockservice.contoso.com/wse/samples/2005/10/GetFileR> 
esponse</wsa:Action>

<wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
eID>

<wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate

sTo>

<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
<
/wsa:To>
           <wsse:Security> 
              <wsu:Timestamp
wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
                 <wsu:Created>2006-07-05T14:04:45Z</wsu:Created> 
                 <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires> 
              </wsu:Timestamp>
           </wsse:Security>
        </env:Header>
        <soap:Body>
           <GetFileResponse
xmlns=" http://stockservice.contoso.com/wse/samples/2005/10
<http://stockservice.contoso.com/wse/samples/2005/10> ">
              <getFileResponse>
                 <fileName>hola.txt</fileName>
                 <fileData>TmFocmdpcw==</fileData> 
              </getFileResponse> 
           </GetFileResponse>
        </soap:Body>
     </soap:Envelope>
----MIMEBoundary632876899223120893--


Thanks in advance,
Ivan

--------------------------------------------------------------------- 
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org




-- 
"May the SourcE be with u"             
http://people.apache.org/~thilina/
<http://people.apache.org/%7Ethilina/> 
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina                

 


Re: [Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Tech Savvy <te...@gmail.com>.
Ivan,

In my experience, you can use OMText.isOptimized() to detect whether MTOM is
presented. If it is, it will return true.

By the way, in the senario you describe, it seems like you shouldn't need to
worry about getting the handler and all that, if you simply want to retrieve
the binary data being sent back. The AXIS2 API will automatically converted
a MTOM soap back to standard SOAP so you client is not affected by this
underline transport technlogy. You can simply get the OMText out and decoded
with org.apache.axis2.util.Base64.decode() to get the binary data out...

Of course if you choose, if OMText.isOptimized() returns true, you can still
get the hander to use the input stream to get the binary data out. However
this approach makes the client depends on or be awared of the SOAP transport
mechanism, which is not necessary...

Thanks.

Sunny *


On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote:
>
>  Thilina,
>
>
>
> In line with your comments, the .Net service seems to have a threshold.
> For very small files (<700 bytes) it puts its base64 representation inside
> the soap envelope. For larger files I get several MIME sections as expected.
>
>
>
> In Axis2/Axiom, is there a way to tell whether an MTOM attachment is
> present?
>
>
>
> Thank you!
>
> Ivan.
>
>
>  ------------------------------
>
> *From:* Thilina Gunarathne [mailto:csethil@gmail.com]
> *Sent:* Wednesday, July 05, 2006 1:43 PM
> *To:* axis-user@ws.apache.org; commons-dev@ws.apache.org
> *Subject:* [Axiom]Re: Axis2: "ContentID is null" using MTOM
>
>
>
> Receiving binary can happen as either MTOM attachments or as Base64
> encoded text. In the case of Base64 user has to explicitly specify that the
> content is binary, before calling getDataHandler(), getInputStream()....
>
>
>
> As you can see in this message no MTOM attachments are present in the
> response, eventhough a MIME envelope is used. Binary file is in lined using
> base64 encoding.
>
>          <fileData>TmFocmdpcw==</fileData>
>
>
> You need to add the following before calling for getDataHandler.
>
>              binaryNode.setOptimize(true);
>
>
>
> Even though it works, IMHO above method is not the clean way to do this..
> Because of that I'm going to introduce the setBinary(boolean value) method
> to OMText.. You will be able to get that method in SVN head in couple of
> hours.
>
>
>
> ~Thilina
>
>
> On 7/5/06, *Ivan Vasquez* <iv...@itos.uga.edu> wrote:
>
> Hi,
>
> I'm using Axis2 to call a .Net service which returns a binary file. I've
> read the documentation and followed the examples, and both parties are
> using MTOM. But when my code runs:
>
> OMElement elem = (OMElement)it.next();
> ...
> OMText binaryNode = (OMText)elem.getFirstOMChild();
> DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();
>
> The last instruction causes:
>
> java.lang.RuntimeException: ContentID is null
>        at
> org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
> 339)
>        at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
>        at edu.uga.cviog.itos.ws.Client.main(Client.java:36)
>
> From what I see, the response message *does* have a "content-id" field
> (below). Could you help me determine what's wrong? Here are the
> exchanged messages:
>
> AXIS2 Request (synchronous):
>
> POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
> User-Agent: Axis/2.0
> Host: 127.0.0.1:8888
> Transfer-Encoding: chunked
> Content-Type: multipart/related;
> boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
> type="application/xop+xml";
> start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org>";
> start-info="application/soap+xml";
> charset=UTF-8;action=" http://stockservice.contoso.com/wse/samples/2005/1
> 0/GetFile";
>
> 1d1
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
> content-type:application/xop+xml; charset=UTF-8;
> type="application/soap+xml";
> content-transfer-encoding:binary
> content-id:<0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org >
> <?xml version='1.0' encoding='UTF-8'?>
>         <soapenv:Envelope
> xmlns:soapenv=" http://www.w3.org/2003/05/soap-envelope">
>            <soapenv:Header />
>            <soapenv:Body />
>         </soapenv:Envelope>
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491--
> 0
>
> .NET Response:
>
> HTTP/1.1 100 Continue
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
>
> HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
> X-AspNet-Version: 2.0.50727
> Cache-Control: private, max-age=0
> Content-Type: multipart/related; type="application/xop+xml";
> boundary=--MIMEBoundary632876899223120893;
> start="< 0.632876899223120893@example.org >";
> start-info="application/soap+xml; charset=utf-8"
> Content-Length: 1569
>
> ----MIMEBoundary632876899223120893
> content-id: < 0.632876899223120893@example.org >
> content-type: application/xop+xml; charset=utf-8;
> type="application/soap+xml; charset=utf-8"
> content-transfer-encoding: binary
>
> <soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
> xmlns:soap=" http://www.w3.org/2003/05/soap-envelope"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing"
> xmlns:wsse=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
> curity-secext-1.0.xsd "
> xmlns:wsu=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
> urity-utility-1.0.xsd">
>         <env:Header
> xmlns:env=" http://www.w3.org/2003/05/soap-envelope">
>
> <wsa:Action> http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
> esponse</wsa:Action>
>
> <wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
> eID>
>
> <wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate
> sTo>
>
> <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous <
> /wsa:To>
>            <wsse:Security>
>               <wsu:Timestamp
> wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
>                  <wsu:Created>2006-07-05T14:04:45Z</wsu:Created>
>                  <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires>
>               </wsu:Timestamp>
>            </wsse:Security>
>         </env:Header>
>         <soap:Body>
>            <GetFileResponse
> xmlns=" http://stockservice.contoso.com/wse/samples/2005/10 ">
>               <getFileResponse>
>                  <fileName>hola.txt</fileName>
>                  <fileData>TmFocmdpcw==</fileData>
>               </getFileResponse>
>            </GetFileResponse>
>         </soap:Body>
>      </soap:Envelope>
> ----MIMEBoundary632876899223120893--
>
>
> Thanks in advance,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>
> --
> "May the SourcE be with u"
> http://people.apache.org/~thilina/ <http://people.apache.org/%7Ethilina/>
> http://thilinag.blogspot.com/                 http://www.bloglines.com/blog/Thilina
>
>

RE: [Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Ivan Vasquez <iv...@itos.uga.edu>.
Thilina,

 

In line with your comments, the .Net service seems to have a threshold.
For very small files (<700 bytes) it puts its base64 representation
inside the soap envelope. For larger files I get several MIME sections
as expected.

 

In Axis2/Axiom, is there a way to tell whether an MTOM attachment is
present?

 

Thank you!

Ivan.

 

________________________________

From: Thilina Gunarathne [mailto:csethil@gmail.com] 
Sent: Wednesday, July 05, 2006 1:43 PM
To: axis-user@ws.apache.org; commons-dev@ws.apache.org
Subject: [Axiom]Re: Axis2: "ContentID is null" using MTOM

 

Receiving binary can happen as either MTOM attachments or as Base64
encoded text. In the case of Base64 user has to explicitly specify that
the content is binary, before calling getDataHandler(),
getInputStream()....

 

As you can see in this message no MTOM attachments are present in the
response, eventhough a MIME envelope is used. Binary file is in lined
using base64 encoding.

         <fileData>TmFocmdpcw==</fileData>
 

You need to add the following before calling for getDataHandler.

             binaryNode.setOptimize(true);

 

Even though it works, IMHO above method is not the clean way to do
this.. Because of that I'm going to introduce the setBinary(boolean
value) method to OMText.. You will be able to get that method in SVN
head in couple of hours.  

 

~Thilina
    

On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote: 

Hi,

I'm using Axis2 to call a .Net service which returns a binary file. I've
read the documentation and followed the examples, and both parties are 
using MTOM. But when my code runs:

OMElement elem = (OMElement)it.next();
...
OMText binaryNode = (OMText)elem.getFirstOMChild();
DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();

The last instruction causes:

java.lang.RuntimeException: ContentID is null
       at
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
339)
       at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
       at edu.uga.cviog.itos.ws.Client.main(Client.java:36)

>From what I see, the response message *does* have a "content-id" field
(below). Could you help me determine what's wrong? Here are the 
exchanged messages:

AXIS2 Request (synchronous):

POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
User-Agent: Axis/2.0
Host: 127.0.0.1:8888 <http://127.0.0.1:8888/> 
Transfer-Encoding: chunked 
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
type="application/xop+xml";
start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org
<ma...@apache.org> >";
start-info="application/soap+xml";
charset=UTF-8;action="
http://stockservice.contoso.com/wse/samples/2005/1
<http://stockservice.contoso.com/wse/samples/2005/1> 
0/GetFile";

1d1
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
content-type:application/xop+xml; charset=UTF-8;
type="application/soap+xml"; 
content-transfer-encoding:binary 
content-id:<0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org >
<?xml version='1.0' encoding='UTF-8'?>
        <soapenv:Envelope 
xmlns:soapenv=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> ">
           <soapenv:Header />
           <soapenv:Body />
        </soapenv:Envelope> 
--MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491-- 
0

.NET Response:

HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET <http://asp.net/> 

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 05 Jul 2006 13:52:02 GMT
X-Powered-By: ASP.NET <http://asp.net/> 
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0 
Content-Type: multipart/related; type="application/xop+xml";
boundary=--MIMEBoundary632876899223120893;
start="< 0.632876899223120893@example.org
<ma...@example.org> >";
start-info="application/soap+xml; charset=utf-8"
Content-Length: 1569

----MIMEBoundary632876899223120893
content-id: < 0.632876899223120893@example.org
<ma...@example.org> >
content-type: application/xop+xml; charset=utf-8;
type="application/soap+xml; charset=utf-8"
content-transfer-encoding: binary

<soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
xmlns:soap=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> "
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> "
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing
<http://schemas.xmlsoap.org/ws/2004/08/addressing> "
xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse> 
curity-secext-1.0.xsd "
xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec> 
urity-utility-1.0.xsd">
        <env:Header 
xmlns:env=" http://www.w3.org/2003/05/soap-envelope
<http://www.w3.org/2003/05/soap-envelope> ">

<wsa:Action>
http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
<http://stockservice.contoso.com/wse/samples/2005/10/GetFileR> 
esponse</wsa:Action>

<wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
eID>

<wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate

sTo>

<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
<
/wsa:To>
           <wsse:Security> 
              <wsu:Timestamp
wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
                 <wsu:Created>2006-07-05T14:04:45Z</wsu:Created> 
                 <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires> 
              </wsu:Timestamp>
           </wsse:Security>
        </env:Header>
        <soap:Body>
           <GetFileResponse
xmlns=" http://stockservice.contoso.com/wse/samples/2005/10
<http://stockservice.contoso.com/wse/samples/2005/10> ">
              <getFileResponse>
                 <fileName>hola.txt</fileName>
                 <fileData>TmFocmdpcw==</fileData> 
              </getFileResponse> 
           </GetFileResponse>
        </soap:Body>
     </soap:Envelope>
----MIMEBoundary632876899223120893--


Thanks in advance,
Ivan

--------------------------------------------------------------------- 
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org




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


[Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Thilina Gunarathne <cs...@gmail.com>.
Receiving binary can happen as either MTOM attachments or as Base64 encoded
text. In the case of Base64 user has to explicitly specify that the content
is binary, before calling getDataHandler(), getInputStream()....

As you can see in this message no MTOM attachments are present in the
response, eventhough a MIME envelope is used. Binary file is in lined using
base64 encoding.
         <fileData>TmFocmdpcw==</fileData>

You need to add the following before calling for getDataHandler.
             binaryNode.setOptimize(true);

Even though it works, IMHO above method is not the clean way to do this..
Because of that I'm going to introduce the setBinary(boolean value) method
to OMText.. You will be able to get that method in SVN head in couple of
hours.

~Thilina

On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote:
>
> Hi,
>
> I'm using Axis2 to call a .Net service which returns a binary file. I've
> read the documentation and followed the examples, and both parties are
> using MTOM. But when my code runs:
>
> OMElement elem = (OMElement)it.next();
> ...
> OMText binaryNode = (OMText)elem.getFirstOMChild();
> DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();
>
> The last instruction causes:
>
> java.lang.RuntimeException: ContentID is null
>        at
> org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
> 339)
>        at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
>        at edu.uga.cviog.itos.ws.Client.main(Client.java:36)
>
> From what I see, the response message *does* have a "content-id" field
> (below). Could you help me determine what's wrong? Here are the
> exchanged messages:
>
> AXIS2 Request (synchronous):
>
> POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
> User-Agent: Axis/2.0
> Host: 127.0.0.1:8888
> Transfer-Encoding: chunked
> Content-Type: multipart/related;
> boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
> type="application/xop+xml";
> start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org>";
> start-info="application/soap+xml";
> charset=UTF-8;action="http://stockservice.contoso.com/wse/samples/2005/1
> 0/GetFile";
>
> 1d1
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
> content-type:application/xop+xml; charset=UTF-8;
> type="application/soap+xml";
> content-transfer-encoding:binary
> content-id:<0....@apache.org>
> <?xml version='1.0' encoding='UTF-8'?>
>         <soapenv:Envelope
> xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>            <soapenv:Header />
>            <soapenv:Body />
>         </soapenv:Envelope>
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491--
> 0
>
> .NET Response:
>
> HTTP/1.1 100 Continue
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
>
> HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
> X-AspNet-Version: 2.0.50727
> Cache-Control: private, max-age=0
> Content-Type: multipart/related; type="application/xop+xml";
> boundary=--MIMEBoundary632876899223120893;
> start="<0.632876899223120893@example.org >";
> start-info="application/soap+xml; charset=utf-8"
> Content-Length: 1569
>
> ----MIMEBoundary632876899223120893
> content-id: <0.632876899223120893@example.org >
> content-type: application/xop+xml; charset=utf-8;
> type="application/soap+xml; charset=utf-8"
> content-transfer-encoding: binary
>
> <soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
> xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing"
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
> curity-secext-1.0.xsd "
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
> urity-utility-1.0.xsd">
>         <env:Header
> xmlns:env="http://www.w3.org/2003/05/soap-envelope">
>
> <wsa:Action>http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
> esponse</wsa:Action>
>
> <wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
> eID>
>
> <wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate
> sTo>
>
> <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous<
> /wsa:To>
>            <wsse:Security>
>               <wsu:Timestamp
> wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
>                  <wsu:Created>2006-07-05T14:04:45Z</wsu:Created>
>                  <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires>
>               </wsu:Timestamp>
>            </wsse:Security>
>         </env:Header>
>         <soap:Body>
>            <GetFileResponse
> xmlns=" http://stockservice.contoso.com/wse/samples/2005/10">
>               <getFileResponse>
>                  <fileName>hola.txt</fileName>
>                  <fileData>TmFocmdpcw==</fileData>
>               </getFileResponse>
>            </GetFileResponse>
>         </soap:Body>
>      </soap:Envelope>
> ----MIMEBoundary632876899223120893--
>
>
> Thanks in advance,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


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

[Axiom]Re: Axis2: "ContentID is null" using MTOM

Posted by Thilina Gunarathne <cs...@gmail.com>.
Receiving binary can happen as either MTOM attachments or as Base64 encoded
text. In the case of Base64 user has to explicitly specify that the content
is binary, before calling getDataHandler(), getInputStream()....

As you can see in this message no MTOM attachments are present in the
response, eventhough a MIME envelope is used. Binary file is in lined using
base64 encoding.
         <fileData>TmFocmdpcw==</fileData>

You need to add the following before calling for getDataHandler.
             binaryNode.setOptimize(true);

Even though it works, IMHO above method is not the clean way to do this..
Because of that I'm going to introduce the setBinary(boolean value) method
to OMText.. You will be able to get that method in SVN head in couple of
hours.

~Thilina

On 7/5/06, Ivan Vasquez <iv...@itos.uga.edu> wrote:
>
> Hi,
>
> I'm using Axis2 to call a .Net service which returns a binary file. I've
> read the documentation and followed the examples, and both parties are
> using MTOM. But when my code runs:
>
> OMElement elem = (OMElement)it.next();
> ...
> OMText binaryNode = (OMText)elem.getFirstOMChild();
> DataHandler actualDH = (DataHandler)binaryNode.getDataHandler();
>
> The last instruction causes:
>
> java.lang.RuntimeException: ContentID is null
>        at
> org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:
> 339)
>        at edu.uga.cviog.itos.ws.Client.foo (Client.java:87)
>        at edu.uga.cviog.itos.ws.Client.main(Client.java:36)
>
> From what I see, the response message *does* have a "content-id" field
> (below). Could you help me determine what's wrong? Here are the
> exchanged messages:
>
> AXIS2 Request (synchronous):
>
> POST /Interop/BinaryDataMTOMService.asmx HTTP/1.1
> User-Agent: Axis/2.0
> Host: 127.0.0.1:8888
> Transfer-Encoding: chunked
> Content-Type: multipart/related;
> boundary=MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491;
> type="application/xop+xml";
> start="< 0.urn:uuid:D2233EEE05CE572BC211521075222492@apache.org>";
> start-info="application/soap+xml";
> charset=UTF-8;action="http://stockservice.contoso.com/wse/samples/2005/1
> 0/GetFile";
>
> 1d1
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491
> content-type:application/xop+xml; charset=UTF-8;
> type="application/soap+xml";
> content-transfer-encoding:binary
> content-id:<0....@apache.org>
> <?xml version='1.0' encoding='UTF-8'?>
>         <soapenv:Envelope
> xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>            <soapenv:Header />
>            <soapenv:Body />
>         </soapenv:Envelope>
> --MIMEBoundaryurn_uuid_D2233EEE05CE572BC211521075222491--
> 0
>
> .NET Response:
>
> HTTP/1.1 100 Continue
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
>
> HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Date: Wed, 05 Jul 2006 13:52:02 GMT
> X-Powered-By: ASP.NET <http://asp.net/>
> X-AspNet-Version: 2.0.50727
> Cache-Control: private, max-age=0
> Content-Type: multipart/related; type="application/xop+xml";
> boundary=--MIMEBoundary632876899223120893;
> start="<0.632876899223120893@example.org >";
> start-info="application/soap+xml; charset=utf-8"
> Content-Length: 1569
>
> ----MIMEBoundary632876899223120893
> content-id: <0.632876899223120893@example.org >
> content-type: application/xop+xml; charset=utf-8;
> type="application/soap+xml; charset=utf-8"
> content-transfer-encoding: binary
>
> <soap:Envelope xmlns:xop=" http://www.w3.org/2004/08/xop/include"
> xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsa=" http://schemas.xmlsoap.org/ws/2004/08/addressing"
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wsse
> curity-secext-1.0.xsd "
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
> urity-utility-1.0.xsd">
>         <env:Header
> xmlns:env="http://www.w3.org/2003/05/soap-envelope">
>
> <wsa:Action>http://stockservice.contoso.com/wse/samples/2005/10/GetFileR
> esponse</wsa:Action>
>
> <wsa:MessageID>urn:uuid:d4be97db-bdaa-428a-87cd-554aa2192a75</wsa:Messag
> eID>
>
> <wsa:RelatesTo>urn:uuid:850f1505-4dcb-475a-93b7-8bc5e274cea5</wsa:Relate
> sTo>
>
> <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous<
> /wsa:To>
>            <wsse:Security>
>               <wsu:Timestamp
> wsu:Id="Timestamp-39117870-658a-4e5a-b3aa-d149240a1cbb">
>                  <wsu:Created>2006-07-05T14:04:45Z</wsu:Created>
>                  <wsu:Expires>2006-07-05T14:09:45Z</wsu:Expires>
>               </wsu:Timestamp>
>            </wsse:Security>
>         </env:Header>
>         <soap:Body>
>            <GetFileResponse
> xmlns=" http://stockservice.contoso.com/wse/samples/2005/10">
>               <getFileResponse>
>                  <fileName>hola.txt</fileName>
>                  <fileData>TmFocmdpcw==</fileData>
>               </getFileResponse>
>            </GetFileResponse>
>         </soap:Body>
>      </soap:Envelope>
> ----MIMEBoundary632876899223120893--
>
>
> Thanks in advance,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


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