This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Soap with attachments  RSS feed

 
Siva Balasundaram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dharamvir (DV) Punia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This article should help you in resolving your problem:
Web Services application fails to start - non-standard MIME Types should be mapped to javax.activation.DataHandler

-DV
 
Siva Balasundaram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dharamvir (DV) Punia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Siva Balasundaram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dharamvir (DV) Punia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!