Hi Sean, I do not understand your use case.. We normally use MTOM or SwA to avoid the overhead of base64 conversion and to avoid the bloating of data by base64 conversion. They are the mechanisms introduced in order to enable the sending of raw binary data with SOAP.
In the case of MTOM/SwA attachments will contain whatever the bytes(binary) you provided as it is. In the MTOM case you need to enableMTOM[1] in order for your binary data to be transferred as an Attachment. I personally recommend the use of MTOM for transferring binary data, unless you are communicating with an legacy server or client. If you really really need is to send binary as *base64* then the best way is to send them in line inside the elements. See here [2] for more info.. ~Thilina [1] http://www.wso2.net/kb/264 [2] http://ws.apache.org/axis2/1_1/mtom-guide.html On 11/20/06, Sean McCarthy <[EMAIL PROTECTED]> wrote:
Hi All, I'm trying to create a client for a web service, and I'm having problems with attachments. First, I don't have the wsdl for the service, but the XSD, so I am creating the WS client from scratch using the OM api. I couldn't figure out how MTOM API exactly works from. What I am supposed to get, is something like: --------------------------------------------------------------------------- POST /soap/SOAPSERVICE HTTP/1.1 Content-Type: multipart/related; boundary="SOAPTestBoundary" Host: 192.168.1.40:10100 Content-Length: 3311 --SOAPTestBoundary Content-Type: text/xml <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:Header> HEADER elements go here </soap-env:Header> <soap-env:Body> Body elements go here <attachment href="cid:image.gif"> </soap-env:Body> </soap-env:Envelope> --SOAPTestBoundary Content-Type: image/gif Content-Transfer-Encoding: base64 Content-Id: image.gif R0lGODlh (encoded base64 data goes on) --SOAPTestBoundary-- --------------------------------- --------------------------------------------------------------------------- But what I get is: --------------------------------------------------------------------------- POST /soap/SOAPSERVICE HTTP/1.1 SOAPAction: "urn:anonOutInOp" User-Agent: Axis2 Host: 192.168.1.40:10100 Content-Length: 2870 Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_BC683E392CA0BE689211639827237863; type="text/xml"; start="<0.urn:uuid:[EMAIL PROTECTED]>"; charset=UTF-8 --MIMEBoundaryurn_uuid_BC683E392CA0BE689211639827236611 content-type: text/xml; charset=UTF-8 content-transfer-encoding: 8bit content-id: <0.urn:uuid:[EMAIL PROTECTED]> <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> Header Stuff </soapenv:Header> <soapenv:Body> Body stuff </soapenv:Body> </soapenv:Envelope> --MIMEBoundaryurn_uuid_BC683E392CA0BE689211639827236611 content-type: image/gif content-transfer-encoding: binary content-id: <image.gif> GIF89ad (raw data goes on) --MIMEBoundaryurn_uuid_BC683E392CA0BE689211639827236611-- --------------------------------- --------------------------------------------------------------------------- What I can't figure out is how do I encode the attachment in base64. If I enable MTOM it attaches the content as a BASE64 BUT inside the element. And if I just do SwA I get the raw binary. Following the tutorial: MessageContext context = new MessageContext(); FileDataSource fileDS = new FileDataSource("tests/data/image.gif"); DataHandler handler = new DataHandler("image.gif", fileDS); // Create Envelope SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); env.getHeader().addChild(vodHeader); env.getBody().addChild(vodBody) // ADD Attachment context.addAttachment("image.gif", handler); But i get: content-type: image/gif content-transfer-encoding: binary content-id: <image.gif> Is there any way to tell the DataHandler or Axis to encode before attaching or should I supply the base64 encoded data? And if I do supply the encoded data, how do I supply the content-type? Thanks, Sean C. McCarthy --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- http://webservices.apache.org/~thilina/ http://thilinag.blogspot.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
