[Axiom]Re: Axis2: "ContentID is null" using MTOM
"Thilina Gunarathne" <[email protected]>
| Newsgroups | gmane.text.xml.axis.user,gmane.text.xml.commons.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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:[email protected]>";
> 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:[email protected]>
> <?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="<[email protected] >";
> start-info="application/soap+xml; charset=utf-8"
> Content-Length: 1569
>
> ----MIMEBoundary632876899223120893
> content-id: <[email protected] >
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
"May the SourcE be with u"
http://people.apache.org/~thilina/
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina