Problem with SAAJ Client for Webservice that receives attach
romeufigueira Nov 3, 2006 5:35 AMHi there, I've implemented a webservice (JSR-109) that receives two parameters and one attachment. It's working fine, testing with soapui 1.6 beta2 showed that my service could receive and store attachments without a problem.
Now I wanted to create a SAAJ client to make contact with such webservice. I have previous experience developing clients without the attachment part, but in this one I'm having problems.
I've based my client on this one http://labs.jboss.com/portal/jbossws/user-guide/en/html/attachments.html
but when interacting with the webservice, I keep on getting this message:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Header/> <env:Body> <env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <faultcode>env:Client</faultcode> <faultstring>multipart/related type specified a root type other than the one that was found.</faultstring> </env:Fault> </env:Body> </env:Envelope>
This is my request message via soapUI
------=_Part_1_20574010.1162549201841 Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-ID: <rootpart@soapui.org> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:.mediation"> <soapenv:Header/> <soapenv:Body> <urn:depositAttach> <id_lote>5</id_lote> <file_name>text</file_name> </urn:depositAttach> </soapenv:Body> </soapenv:Envelope> ------=_Part_1_20574010.1162549201841 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-ID: <mimepart=1788743063992@soapui.org> Text message here ------=_Part_1_20574010.1162549201841--
And this is my message via my SAAJ client
------=_Part_0_12285029.1162549416820 Content-Type: text/xml; charset=utf-8 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:mediation"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <urn:depositAttach> <id_lote>1</id_lote> <file_name>text</file_name> </urn:depositAttach> </SOAP-ENV:Body> </SOAP-ENV:Envelope> ------=_Part_0_12285029.1162549416820 Content-Type: multipart/mixed; boundary="----=_Part_0_28470003.1162549416710" Content-ID: <mimepart=1876756521231@example.com> ------=_Part_0_28470003.1162549416710 Content-Type: text/plain Text message here ------=_Part_0_28470003.1162549416710-- ------=_Part_0_12285029.1162549416820--
Additionaly, here is the header of the SOAP transmission from soapUI
SOAPAction: "" Content-Type: multipart/related; type="text/xml"; start="<rootpart@soapui.org>"; boundary="----=_Part_1_20574010.1162549201841 MIME-Version: 1.0 User-Agent: Jakarta Commons-HttpClient/3.0.1 Host: localhost:8080 Content-Length: 697
Now, here's my problem, I know that the messages are correct, as you can also see, but there must be something wrong with my definiton of attachment. I cannot reproduce the part highlighted in the soapui message, and think that is where my problem lays. Somewere in server process, when the message goes through my client, it can't split the message into two, the Body Part and the Attachment part, and complains when it finds a "text/plain" instead of "text/xml".
Can you help me here?