Hi Thomas, The WSDL seems to be incorrect, as it does not contain any references to the "mime" in the wsdl-binding. If you use attachments then your wsdl binding should look something like this: (In this sample both requests and response uses attachments) <binding name="EchoMIMEPortBinding" type="tns:EchoMIMEPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="echoMIMEString"> <soap:operation soapAction="urn:EchoMIMEService/echoMIMEString" style="rpc"/> <input name="echoMIMEString"> <mime:multipartRelated> <mime:part name="part1"> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:EchoMIMEService" use="encoded"/> </mime:part> <mime:part name="part2"> <mime:content part="input" type="text/plain"/> </mime:part> </mime:multipartRelated> </input> <output name="echoMIMEStringResponse"> <mime:multipartRelated> <mime:part name="part1"> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:AttachmentService" use="encoded"/> </mime:part> <mime:part name="part2"> <mime:content part="output" type="text/plain"/> </mime:part> </mime:multipartRelated> </output> </operation> </binding>
If you are sending the attachments and not receiving them, then your <output> should use <mime:multipartRelated> to describe how attachments will be sent. Hope this helps. Good luck. Shrikant Wagh HPP/eProfile QA Lead. HP For those who are interested in Web Services testing: ----------------------------------------------------- I found that WebServiceTester from Optimyz software is a very good tool for testing any types of web services, and I'm great fan of this tool. It supports all types of web services, and all simple and complex types and it very usable than any other tool in the market I ever used/evaluated. It automatically generates the SOAP requests and invokes the intended web services. It can perform functional, regression and load testing of web services. Result analysis and status reporting is just wonderful. I'll highly recommend this tool for testing web services, saves lots of time and efforts in testing web services. For more information visit http://www.optimyz.com. DISCLAIMER ================================================================ THESE ARE MY PERSONAL VIEWS/OPINIONS AND DOES NOT REPRESENT HP, AND THE INFORMATION PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE I/HP BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS INFORMATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================= -----Original Message----- From: Thomas Dorner [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 5:50 AM To: [EMAIL PROTECTED] Subject: SOAP with Attachment (SwA) Dummy need Help! pls :) Hello all, I have a problem - i cant find a explanation for the implementation of SOAP with Attachment. I read all the Mail in the Mailinglist but cant find a good explanation. There are always snippets of code. Can we solve this Problem all the time? So I will tell my solution and hope some clever programmers will correct it and explain the right way to do it. The point is: We want to send multiple attachments from Service to client side. The attachments can become a size of more then 100 MB. The attachments come from a Database. Test: Therefore we send the path of a file to the Service, get the file and send it back to the Client (for test reasons). So we will generate an Interface like this: (for multiple attachments = DataHandler[])??? ********************************************************************** public interface AttachmentService { public DataHandler getFileAsAttachment(String filename); } ********************************************************************** This Interface will return a DataHandler (only one attachment!). --> I dont know if this is the right solution (DataHandler?)??? We use Java2WSDL to generate the WSDL from the Interface! The WSDL looks like this: ********************************************************************** <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="services:AttachmentService" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="services:AttachmentService" xmlns:intf="services:AttachmentService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:message name="getFileAsAttachmentResponse"> <wsdl:part name="getFileAsAttachmentReturn" type="apachesoap:DataHandler"/> </wsdl:message> <wsdl:message name="getFileAsAttachmentRequest"> <wsdl:part name="in0" type="xsd:string"/> </wsdl:message> <wsdl:portType name="AttachmentService"> <wsdl:operation name="getFileAsAttachment" parameterOrder="in0"> <wsdl:input message="impl:getFileAsAttachmentRequest" name="getFileAsAttachmentRequest"/> <wsdl:output message="impl:getFileAsAttachmentResponse" name="getFileAsAttachmentResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="AttachmentService_ServiceSoapBinding" type="impl:AttachmentService"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getFileAsAttachment"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getFileAsAttachmentRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="services:AttachmentService" use="encoded"/> </wsdl:input> <wsdl:output name="getFileAsAttachmentResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="services:AttachmentService" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="AttachmentServiceService"> <wsdl:port binding="impl:AttachmentService_ServiceSoapBinding" name="AttachmentService_Service"> <wsdlsoap:address location="http://localhost:8080/axis/services/AttachmentService_Service"/> </wsdl:port> </wsdl:service> </wsdl:definitions> ********************************************************************** So my problem is, i think there is something missing in this WSDL!? I dont see anything about "MIME" and so on!!! Can someone tell me whats wrong here???? Now we use WSDL to Java to generate the Classes (Stub, Skeleton, and so on ...) Then we deploy the Service with the genareted deploy.wsdd from the WSDL2Java Looks like this: ********************************************************************** <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <!-- Services from AttachmentServiceService WSDL service --> <service name="AttachmentService_Service" provider="java:RPC" style="rpc" use="encoded"> <parameter name="wsdlTargetNamespace" value="services:AttachmentService"/> <parameter name="wsdlServiceElement" value="AttachmentServiceService"/> <parameter name="wsdlServicePort" value="AttachmentService_Service"/> <parameter name="className" value="webService.attachment.AttachmentService_wsdl.AttachmentService_ServiceSoapBindingSkeleton"/> <parameter name="wsdlPortType" value="AttachmentService"/> <parameter name="allowedMethods" value="*"/> <parameter name="scope" value="Application"/> </service> </deployment> ********************************************************************** and Implement the ServiceImpl, like this: ********************************************************************** public javax.activation.DataHandler getFileAsAttachment(String filename) throws java.rmi.RemoteException { DataHandler dataHandler = null; try{ FileDataSource dataSource = new FileDataSource(filename); dataHandler = new DataHandler(dataSource); }catch(Exception e){} return dataHandler; } ********************************************************************** we start to call the Service from our test client, looks like this: ********************************************************************** public static void main(String[] args) { String filename = "H:\\Tomcat\\webapps\\axis\\WEB-INF\\web.xml"; String path = "H:\\Tomcat\\webapps\\axis\\WEB-INF\\web1.xml"; try { /* Verbindung zum Web Service aufbauen * => über den ZeitansageServiceLocator */ AttachmentServiceLocator serviceLocator = new AttachmentServiceLocator (); AttachmentService service = (AttachmentService) serviceLocator.getAttachmentService_Service (); /* Casten auf den von WSDL2Java generierten * Stub: */ AttachmentService_ServiceSoapBindingStub soapService = (AttachmentService_ServiceSoapBindingStub) service; DataHandler data = soapService.getFileAsAttachment(filename); OutputStream outstream = data.getOutputStream(); ByteArrayOutputStream outBytes =(ByteArrayOutputStream)outstream; FileOutputStream out = new FileOutputStream(path); out.write(outBytes.toByteArray(), 0, outBytes.size()); } catch ( Exception e ) { System.out.println ( "Es ist folgender Fehler aufgetreten: " + e ); } } ********************************************************************** The SOAP message look nice but i think not right for a attachment! The mesage looks like this - Request: ********************************************************************** <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:getFileAsAttachment soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="services:AttachmentService"> <in0 xsi:type="xsd:string">H:\Tomcat\webapps\axis\WEB-INF\web.xml</in0> </ns1:getFileAsAttachment> </soapenv:Body> </soapenv:Envelope> ********************************************************************** And the Response like this: ********************************************************************** <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:getFileAsAttachmentResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="services:AttachmentService"> <getFileAsAttachmentReturn href="cid:9BE1C0F08C13A905FB7123C8BB0458FF" xmlns:ns2="http://xml.apache.org/xml-soap"/> </ns1:getFileAsAttachmentResponse> </soapenv:Body> </soapenv:Envelope> ------=_Part_1_31361704.1075294386156 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-Id: <9BE1C0F08C13A905FB7123C8BB0458FF> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd"> <web-app> <display-name>Apache-Axis</display-name> <servlet> <servlet-name>AxisServlet</servlet-name> <display-name>Apache-Axis Servlet</display-name> <servlet-class> org.apache.axis.transport.http.AxisServlet </servlet-class> </servlet> .... </web-app> ------=_Part_1_31361704.1075294386156-- ********************************************************************** Is it the right way we solve the Problem, or there other ways - better ways??? I cant get something out the DataHandler of the client side!? why? How can i use MIME as the Protocol for sending my attachment?