Once more time with end:)
Please, can someone help me with this problem yet?:) Actually my problem is,
that in our application we need to send our clients scanned file that is pdf
type.
Here is server code:
******************************
public binary.axtypes.GetFileResponse getFile(
binary.axtypes.GetFileRequest param2) {
binary.axtypes.GetFileResponse resp = new
binary.axtypes.GetFileResponse();
String strFile = "c:\\a.pdf";
if(!param2.getFilein().equals(""))
{
strFile = param2.getFilein();
}
javax.activation.FileDataSource fds;
fds = new javax.activation.FileDataSource(strFile);
System.out.println(fds.getContentType());
DataHandler dh = new DataHandler(fds);
resp.setFileout(dh);
return resp;
//Todo fill this with the necessary business logic
//throw new java.lang.UnsupportedOperationException();
}
******************************
I dont know if already there is any problem because whe i try call
fds.getcontenttype() it returns application/octet-stream and not
application/pdf. Original pdf file on server has 1 015 808 bytes and saved
file on client has 1 356 264 bytes. When I look at what is sending from
server theres in tcp monitor this text:
--MIMEBoundaryurn_uuid_E3B926AB88EB5FDF6F11592687872843
content-type:application/xop+xml; charset=UTF-8; type="text/xml";
content-transfer-encoding:binary
content-id:<0.urn:uuid:[EMAIL PROTECTED]>
....
--MIMEBoundaryurn_uuid_E3B926AB88EB5FDF6F11592687872843--
On client I have this part:
*********************
public void testgetFile() throws java.lang.Exception {
binary.axws.BinarytestStub stub = new binary.axws.BinarytestStub();
//the default implementation should point to the right endpoint
Options options =stub._getServiceClient().getOptions();
options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
binary.axtypes.GetFileRequest param18 =
(binary.axtypes.GetFileRequest)
getTestObject(binary.axtypes.GetFileRequest.class);
param18.setFilein("c:\\a.pdf");
//BinarytestSkeleton bts = new BinarytestSkeleton();
//assertNotNull(bts.getFile(param18));
binary.axtypes.GetFileResponse resp = stub.getFile(param18);
//assertNotNull(stub.getFile(param18));
FileOutputStream fos = new FileOutputStream("c:\\a22.pdf");
resp.getFileout().writeTo(fos);
}
*********************
MTOM is enabled on server and also in client. Has anyone some idea? Thank
you very much for all ideas.
Vlada
-----Original Message-----
From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 20, 2006 3:29 PM
To: [email protected]
Subject: Re: Axis PDF trnasmission
hmmm... FileDataSource should automatically pick up the MIME type...
Please check whether the message gets delivered using MTOM (using a
MIME package) or with in line base64 string...
Check by enabling MTOM as follows, If MTOM is not enabled.
Options options =stub._getServiceClient().getOptions();
options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_MTOM,
Boolean.TRUE);
HTH,
~Thilina
On 9/20/06, VF <[EMAIL PROTECTED]> wrote:
> Hi,please I have this question. Is ti possible to transfer PDF file with
> SOAP,MTOM and ADB?
>
> I have this fragment in WSDL:
>
> <xs:element name="getFileRequest">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="filein"
>
> type="xs:base64Binary" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
>
> Axis generated this ADB binding:
>
> -------------------------------------------------
>
> /** field for Filein */
> protected javax.activation.DataHandler localFilein;
>
> /**
> * Auto generated getter method
> *
> * @return javax.activation.DataHandler
> */
> public javax.activation.DataHandler getFilein() {
> return localFilein;
> }
>
> /**
> * Auto generated setter method
> *
> * @param param Filein
> */
> public void setFilein(javax.activation.DataHandler param) {
> this.localFilein = param;
> }
>
> ----------------------------------------------------
>
>
>
> I call it in client:
>
> * Auto generated test method
> */
> public void testgetFile() throws java.lang.Exception {
> binary.axws.BinarytestStub stub = new
binary.axws.BinarytestStub();
> //the default implementation should point to the right endpoint
>
> binary.axtypes.GetFileRequest param18 =
> (binary.axtypes.GetFileRequest)
> getTestObject(binary.axtypes.GetFileRequest.class);
>
> // todo Fill in the param18 here
> DataHandler dh = new DataHandler(new FileDataSource("c:\\a.pdf"));
>
> param18.setFilein(dh);
> BinarytestSkeleton bts = new BinarytestSkeleton();
>
> assertNotNull(bts.getFile(param18));
> //assertNotNull(stub.getFile(param18));
> param18.setFilein(dh);
> }
>
>
> -------------------------------------------------------
>
> on server is this code:
>
> public binary.axtypes.GetFileResponse getFile(
> binary.axtypes.GetFileRequest param2) {
> DataHandler dh = param2.getFilein();
> binary.axtypes.GetFileResponse resp = new
> binary.axtypes.GetFileResponse();
>
> try {
> dh.writeTo(new FileOutputStream("c:\\a2.pdf"));
> resp.setFileout(dh);
> return resp;
> } catch (FileNotFoundException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> return resp;
> //Todo fill this with the necessary business logic
> //throw new java.lang.UnsupportedOperationException();
> }
>
>
> -----------------------------------------------------------
>
>
> Result:
> When I call it directly through service skeleton and save it on server it
> is ok and I can open new file, but if I use stub and send it over Axis2,
> then it s not possible to open this file. It says,that it is possible that
> it was sent as a mail attachement and it has bad encoding. How can i send
it
> with pdf mime type?
>
> Thanks a lot.
>
>
> Vlada
>
>
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]