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

begin:vcard
fn:Sean McCarthy
n:McCarthy;Sean
org:Integra Soluciones Avanzadas, S.L.
adr;quoted-printable:Urb. El Sebadal;;Juan Dominguez Perez, 28;Las Palmas de Gran Canaria;Las Palmas;35008;Espa=C3=B1a
email;internet:[EMAIL PROTECTED]
tel;work:+34928465203
x-mozilla-html:FALSE
url:http://www.IntegraAS.com
version:2.1
end:vcard


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to