wood burning stoves 2.0*
The moose likes Web Services and the fly likes Extracting SOAP Attachments!! Help!!  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Extracting SOAP Attachments!! Help!!  " Watch "Extracting SOAP Attachments!! Help!!  " New topic
Author

Extracting SOAP Attachments!! Help!!

onder sezgin
Greenhorn

Joined: Apr 11, 2009
Posts: 2
Hello all,

I have written a web service receiving soap message with attachments.
message is like below. I also written a message handler at the service side to extract attachments.

and its invoke method is like this.

public void invoke(MessageContext arg0) throws AxisFault {
SOAPMessage soapMessage = arg0.getMessage();
Iterator attachments = soapMessage.getAttachments();
while(attachments.hasNext()){
AttachmentPart attachment = (AttachmentPart)attachments.next();

System.out.println("ATTACHMENT CONTENT ID=" + attachment.getContentId());
System.out.println("ATTACHMENT CONTENT LOCATION="+ attachment.getContentLocation());
System.out.println("ATTACHMENT CONTENT TYPE="+ attachment.getContentType());

DataHandler dh = attachment.getDataHandler();
String attachmentContent = CfDataSourceReader.convertToString(dh.getDataSource());
System.out.println("ATTACHMENT CONTTENT BODY=" + attachmentContent);
}
}

i get one attachment and print it like this, although i have two attachment.

------=_Part_34_14069871.1239527371546
Content-Type: multipart/mixed; boundary="----=_Part_38987_26662994.1239527475525"
Content-Transfer-Encoding: binary
Content-Id: <82EBE43CF308A233A1F44B98520D944D>

------=_Part_38987_26662994.1239527475525
Content-Type: application/smil; filename=p.smil; name=p.smil; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-ID: <d6T40>
Content-Location: p.smil
Content-Disposition: Attachment ;Filename="p.smil"

<smil>
<head>
<layout>
<root-layout width="115" height="122" />
<region id="Image" width="100%" height="100%" left="0%" top="0%" fit="meet" />
</layout>
</head>
<body>
<par dur="6000ms">

</par>
</body>
</smil>

------=_Part_38987_26662994.1239527475525
Content-Type: image/jpeg; filename=XXXXXXXXXXXXX.jpg; name=XXXXXXXXXXXXXXXX.jpg
Content-Transfer-Encoding: base64
Content-Location: XXXXXXXXXXXXXX.jpg
Content-Disposition: Attachment ;Filename="XXXXXXXXXXXXX.jpg"
Content-ID: <31loDbypsW>

//////////////BNARYY CONTENT ///////////////////

------=_Part_38987_26662994.1239527475525--

* How can i get those two attachment file contents ?? PLEASE HELP!!! *

------=_Part_34_14069871.1239527371546
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <A58B5257C0B0A1A6C8C8DAC18A19B75D>

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header>
<mm7:TransactionID SOAP-ENV:mustUnderstand="1" xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">XXXXXXXXXXXXXXXXXXXXXXXXXXXX</mm7:TransactionID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<mm7eliverReq xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">
<MM7Version>5.3.0</MM7Version>
<LinkedID>XXXXXXXXXXXXXXXXXXXXXXXXXXXX</LinkedID>
<Subject></Subject>
<Sender>
<Number>XXXXXXXXXXXXXXXXX</Number>
</Sender>
<Recipients><To><Number>3300</Number></To></Recipients>
<TimeStamp>2009-04-12T12:11:14Z</TimeStamp>
<Priority>Normal</Priority>
</mm7eliverReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

------=_Part_34_14069871.1239527371546
Content-Type: multipart/mixed; boundary="----=_Part_38987_26662994.1239527475525"
Content-Transfer-Encoding: binary
Content-Id: <82EBE43CF308A233A1F44B98520D944D>

------=_Part_38987_26662994.1239527475525
Content-Type: application/smil; filename=p.smil; name=p.smil; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-ID: <d6T40>
Content-Location: p.smil
Content-Disposition: Attachment ;Filename="p.smil"

<smil>
<head>
<layout>
<root-layout width="115" height="122" />
<region id="Image" width="100%" height="100%" left="0%" top="0%" fit="meet" />
</layout>
</head>
<body>
<par dur="6000ms">

</par>
</body>
</smil>

------=_Part_38987_26662994.1239527475525
Content-Type: image/jpeg; filename=XXXXXXXXXXXXX.jpg; name=XXXXXXXXXXXXXXXX.jpg
Content-Transfer-Encoding: base64
Content-Location: XXXXXXXXXXXXXX.jpg
Content-Disposition: Attachment ;Filename="XXXXXXXXXXXXX.jpg"
Content-ID: <31loDbypsW>
//////////////BNARYY CONTENT ///////////////////
------=_Part_38987_26662994.1239527475525--

------=_Part_34_14069871.1239527371546--
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extracting SOAP Attachments!! Help!!
 
Similar Threads
adding SOAP attachment
Parsing SOAP Information
Parsing POST Information
MMSC test
How to get SOAP attachment