Forums Register Login

Soap with attachments

+Pie Number of slices to send: Send
Dear All
I am able to create simple web services which takes simple datatypes as input and display a result. I have been trying to create a web service from EJB which takes a PDF file as input and store it in the server. I am using WSAD 5.1.1
I tried the following code
public String getPDF(File appFile) {

if (appFile == null) {
LOG.error("PDF File missing");
return ("Error : PDF File required");
}

String filename = "temp.pdf";

try{
DataHandler pdfHandler = new DataHandler (new ByteArrayDataSource(appFile, null));
File PDFDir = new File (SystemSetupClass.getProperty("app.pdf.path") + filename);
FileOutputStream fileOutput = null;

fileOutput = new FileOutputStream (PDFDir);
pdfHandler.writeTo (fileOutput);
}
catch (FileNotFoundException fnfe) {
LOG.error("Error opening PDF file");
return "Error opening PDF file:" + fnfe.toString ();
}
catch (IOException ioe)
{
LOG.error("Error writing PDF file");
return "Error writing PDF file:" + ioe.toString ();
}
return "Success"
}

--------
when I start the server I am getting the following error

[12/13/04 14:08:06:047 EST] 3c91c622 InternalExcep F com.ibm.ws.webservices.engine.InternalException WSWS3227E: Error: Exception:
[12/13/04 14:08:06:057 EST] 3c91c622 InternalExcep F com.ibm.ws.webservices.engine.InternalException TRAS0014I: The following exception was logged java.lang.Exception: WSWS3034E: Error: The OperationDesc for getPDF was not matched to a method of com.process.ejb.TestEJB. Debug:name: TestEJB

Help please.

regards
Siva

[ December 12, 2004: Message edited by: Good Boy ]
[ December 12, 2004: Message edited by: Siva B ]
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Thanks DV
Actually I tried that even before posting the issue in the forum. The default parm type in the mapping file was java.lang.Object and I changed it to javax.activation.DataHandler. Anyother suggestions ?

regards
Siva
+Pie Number of slices to send: Send
Hi Siva,
Sorry that article didn't help you much.
Anyway, if this is your web service method public String getPDF(File appFile), I believe you might have to use "DataHandler" istead of File in your method param because there is no direct mapping for file. So try it, it might do the trick.

I hope this helps

-DV
+Pie Number of slices to send: Send
Thanks DV
It worked. But now i got new errors in wsdl file. the errors are as follows.

error 1: src-import.0: Failed to read imported schema document 'http://xml.apache.org/xml-soap'.

error2 : src-resolve: Cannot resolve the name 'apachesoap: DataHandler' to a(n) type definition component.

error 3: The part 'parameters' has an invalid value 'getPDF' defined for its element. Element declarations must refer to valid values defined in a schema.

error 4: The part 'parameters' has an invalid value 'getPDFResponse' defined for its element. Element declarations must refer to valid values defined in a schema.

help please

regards
Siva

[ December 14, 2004: Message edited by: Siva B ]
[ December 14, 2004: Message edited by: Siva B ]
+Pie Number of slices to send: Send
What I would suggest you is do this from scratch again, then follow the article to fix the mapping for datahandler and see if it works. It seems like there is problem with schema mapping for DataHandler in your wsdl or mppaing.xml.

Check this url for mapping (make sure to check Table 3. Sending blobs: Apache SOAP type mapping

-DV
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4174 times.
Similar Threads
deployemnt ERROR,
IrixTech Mock Exam
hi kyle
How to make a WebServices call return DataHandler object within WebObjects?
About for loop of jdk1.5
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:02:40.