Hi Thilina,
This is my server side web service code to create the attachment.
Public GetApplicationAttachmentResponse getApplicationAttachment()
{
FileDataSource dataSource1 = new
FileDataSource("C:\\temp\\images\\images1.jpg");
DataHandler fileDataHandler1 = new DataHandler(dataSource1);
FileNameType fileNameType = new FileNameType();
fileNameType.setFileNameType("My Pic File");
FileDescriptionType fileDescriptionType = new FileDescriptionType();
fileDescriptionType.setFileDescriptionType("This is my file");
FileRawDataType fileRawDataType = new FileRawDataType();
fileRawDataType.setFileRawDataType(fileDataHandler1);
FileAttachmentType fileAttachmentType = new FileAttachmentType();
fileAttachmentType.setFileName(fileNameType);
fileAttachmentType.setFileDescription(fileDescriptionType);
fileAttachmentType.setFileFormat(FileFormatEnumType.GIF);
fileAttachmentType.setFileRawData(fileRawDataType);
GetApplicationAttachmentResponseType getApplicationAttachmentResponseType
= new GetApplicationAttachmentResponseType();
getApplicationAttachmentResponseType.setOperationResult(OperationResultEnumType.SUCCESS);
getApplicationAttachmentResponseType.setResponseTimestamp(Calendar.getInstance());
getApplicationAttachmentResponseType.setApplicationAttachment(fileAttachmentType);
GetApplicationAttachmentResponse getApplicationAttachmentResponse = new
GetApplicationAttachmentResponse();
getApplicationAttachmentResponse.setGetApplicationAttachmentResponse(getApplicationAttachmentResponseType);
return getApplicationAttachmentResponse;
}
All those classes are generated from wsdl2java using ADB. No use of rampart as
far as I know.
I wonder why the attachment is still inside the soap envelop.
Please send me your suggestion.
Regards,
Shehan
From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]
Sent: Sunday, 13 July 2008 5:08 PM
To: Shehan Simen
Cc: [email protected]
Subject: Re: MTOM axis1.4 OutOfMemory for large file transfer
hmmm... Interesting.. .How are you creating the attachment in the server side..
Are you using ADB code generation... Also is there any other modules engaged to
the service (eg: rampart),,,
thanks,
Thilina
On Wed, Jul 9, 2008 at 8:29 PM, Shehan Simen <[EMAIL PROTECTED]<mailto:[EMAIL
PROTECTED]>> wrote:
Hi Thilina,
Thank you for your reply.
I have already enabled the mtom in server side and client side as mentioned.
Here is my soap request. (using tcpmon):
POST /Schemes_WSDL_v1/services/Schemes HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "getApplicationAttachment"
User-Agent: Axis2
Host: localhost:7000
Transfer-Encoding: chunked
28c
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:getApplicationAttachmentRequest
xmlns:ns1="http://www.itree.com.au/schemas/iroad/schemes/2008-03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns1:GetApplicationAttachmentRequestType"><ns1:requestIdentifier>0001</ns1:requestIdentifier><ns1:documentIdentifier>DOC7777</ns1:documentIdentifier><ns1:requestTimestamp>2008-07-10T13:22:17.651+10:00</ns1:requestTimestamp><ns1:attachmentIdentifier>file000001</ns1:attachmentIdentifier></ns1:getApplicationAttachmentRequest></soapenv:Body></soapenv:Envelope>
0
And here is the response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_72BA218269813E64EB1215660138103;
type="application/xop+xml"; start="<0.urn:uuid:[EMAIL PROTECTED]<mailto:[EMAIL
PROTECTED]>>"; start-info="text/xml"
Transfer-Encoding: chunked
Date: Thu, 10 Jul 2008 03:22:18 GMT
2000
--MIMEBoundaryurn_uuid_72BA218269813E64EB1215660138103
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:getApplicationAttachmentResponse
xmlns:ns1="http://www.itree.com.au/schemas/iroad/schemes/2008-03"><ns1:operationResult>SUCCESS</ns1:operationResult><ns1:responseTimestamp>2008-07-10T13:22:18.041+10:00</ns1:responseTimestamp><ns1:applicationAttachment><ns1:fileName>My
Pic File</ns1:fileName><ns1:fileDescription>This is my
file</ns1:fileDescription><ns1:fileFormat>GIF</ns1:fileFormat><ns1:fileRawData>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5Ojf/2wBDAQoKCg0MDRoPDxo3JR8lNzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzf/wAARCACEAH0DA..............................
</ns1:fileRawData></ns1:applicationAttachment></ns1:getApplicationAttachmentResponse></soapenv:Body></soapenv:Envelope>
38
--MIMEBoundaryurn_uuid_72BA218269813E64EB1215660138103
2
--
0
See, the binary data is still inside the soap envelop. It is not a real
attachment, which should be outside the soap envelop.
I am using axis2 1.4 and wsdl2java tools, deployed in tomcat.
Is something wrong with the classes generated by wsdl2java?
Why still the MTOM binary data inside the soap envelop?
Hope you can help me.
Thx,
Regards,
Shehan
From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>]
Sent: Thursday, 10 July 2008 1:29 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: MTOM axis1.4 OutOfMemory for large file transfer
Looks like you are trying to receive a file from a web service and that web
service is sending the binary data inside the SOAP envelope as base64binary..
Get your web service to send binary data as an attachment by enabling MTOM at
the server side for that service. Then you can enable filecaching at the client
side, if you are thinking of receiving very large attachments.
http://wso2.org/library/264
thanks,
Thilina
On Wed, Jul 9, 2008 at 12:18 AM, Shehan Simen <[EMAIL PROTECTED]<mailto:[EMAIL
PROTECTED]>> wrote:
This is axis2 version1.4, if I confused you.
Will be glad if someone can help me.
From: Shehan Simen [mailto:[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>]
Sent: Wednesday, 9 July 2008 5:07 PM
To: [email protected]<mailto:[email protected]>
Subject: MTOM axis1.4 OutOfMemory for large file transfer
Hi,
I have OutofMemory exception problem with axis1.4, when I try to receive files.
Were you able to resolve it?
It is working fine with small attachments around 2MB.
I checked the soap message in tcpMon, but still I see the file binary data
inside the soap message. (not out side envelope).
I am using the datahandler type, which is used for base64binary attachment
My client code is as follows.
FileOutputStream os = new FileOutputStream("C:\\temp\\images\\iiad.zip");
FileRawDataType fileRawDataType = fileAttachmentType.getFileRawData();
DataHandler dataHandler = fileRawDataType.getFileRawDataType();
dataHandler.writeTo(os);
os.flush();
os.close();
fileRawDataType is a class defined by me for dataHandler type.
I enabled the file caching in the axis2.xml, also the MTOM.
Do you have any idea?
Thankx.
Regards,
Shehan
--
Thilina Gunarathne - http://thilinag.blogspot.com
--
Thilina Gunarathne - http://thilinag.blogspot.com