Re: Attachment use in the WS skeleton
Could you help me ? Thanks a lot Charles Charles Souillard wrote: Hi, you can find in attachment the client, the wsdl and the skeleton files. Thanks a lot for your help. Charles Charles Souillard wrote: Hi, I have added the enable mtom property(true) I still have an error. Which code should I execute in the skeleton when this property is enabled ? With no change, the cast OMText binaryNode = (OMText) imageEl.getFirstOMChild(); fails. And with the property, the message I can catch between my client and axis is the following : Thanks for your help. POST /axis2/services/HelloWorldServiceBP HTTP/1.1 User-Agent: Axis2 SOAPAction: initiate Host: localhost:12000 Transfer-Encoding: chunked Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801; type=application/xop+xml; start=0.urn:uuid:[EMAIL PROTECTED]; start-info=text/xml; charset=UTF-8 b5d --MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801 content-type:application/xop+xml; charset=UTF-8; type=text/xml; content-transfer-encoding:binary content-id: 0.urn:uuid:[EMAIL PROTECTED] ?xml version='1.0' encoding='UTF-8'? soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/; soapenv:Header / soapenv:Body tns:initiateHelloWorld xmlns:tns=urn:helloworld:bpel:bsoap tns:image xop:Include href=cid:1.urn:uuid:[EMAIL PROTECTED] xmlns:xop=http://www.w3.org/2004/08/xop/include; / /tns:image tns:namey/tns:name /tns:initiateHelloWorld /soapenv:Body /soapenv:Envelope--MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801content-id: 1.urn:uuid:[EMAIL PROTECTED]content-type:image/jpegcontent-transfer-encoding:binary and a lot of symbols... Thilina Gunarathne wrote: May be i can give you a helping hand if you u post the generated skeleton as well... I'm not sure wat's the param0. I'm not that familiar with data bounded MTOM skeletons :(... Problem seems that you are not getting hold of the correct textNode with binary data.. Looking at the exception you are asking a DataHandler from a non-binary node.. You can use the TCPMON to see how your attachment is going... See whether it goes as a MIME part or as base64.. Thanks, ~Thilina On 5/12/06, *Charles Souillard* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi all, I am using Axis 2 1.0 on a Linux computer for 2 weeks. I am using Sun jdk1.5.0_06. I am able to call a simple Helloworld WS using xmlbeans DataBinding. I haven't modified axis2.xml configuration. Axis 2 web app is deployed into my Tomcat 5.5.15. I am now trying to add an attachment in the message I send to the WS. My problem is to access the binary data received in the skeleton. I made a test in the client to build the image with the same code I use in the skeleton and it is successfull. You can find the code I use and the exception I get below. Can you help me ? I think I have only made a copy/paste from the MTOM guide available in the axis2 documentation. Thanks a lot Regards Charles I get the following exception : ContentID is null at org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:339) at org.apache.axis2.HelloWorldServiceBPSkeleton.initiate(HelloWorldServiceBPSkeleton.java:162) at org.apache.axis2.HelloWorldServiceBPMessageReceiverInOut.invokeBusinessLogic(HelloWorldServiceBPMessageReceiverInOut.java :50) at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest (HTTPTransportUtils.java:284) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service( HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java :173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:148) at
Re: Attachment use in the WS skeleton
Hi, I can suggested three ways to access the binary content according to my choice priority. 1. I don't have a much of a knowledge in Data Bounded code. But if the data binding is properly handled for MTOM then there should be a getter for a Data Handler or a Byte[] in your helloworld.InitiateHelloWorldDocument .. 2. Regarding your server code, You can access the OMText object containing the Binary data from imageEle element by calling it's getFirstChild() method. Then you can call the getDataHandler() method of that OMText instance to get the DataHandler. This should work. 3.I don't understand why you are trying to access the attachments Map in the msgContext. This method is to use with SwA type attachments, though it should work even in this scenario(with loads of unnecessary overhead) . I noticed that you are setting the out message context in the setOperationContext method using WSDLConstants.MESSAGE_LABEL_OUT_VALUE. Try using LABEL_IN_VALUE. I personally don't recommend the 3rd method to access MTOM attachments. It's lot easier than that. :) HTH, ~Thilina for (Iterator it = payload.getChildElements();it.hasNext();) { OMElement el = (OMElement) it.next(); if (el.getLocalName().equalsIgnoreCase(image)) { imageEl = el; } else if (el.getLocalName().equalsIgnoreCase(name)) { nameEl = el; } } String out = initiateHelloWorldResponse xmlns=\urn:helloworld:bpel:bsoap\; out += result; try { OMElement xop = (OMElement)imageEl.getFirstOMChild(); OMAttribute attr = xop.getAttribute (new QName(href)); out += \nattr = +attr; String contentID = attr.getAttributeValue(); out += \ncontentID = +contentID; Attachments attachment = (Attachments) msgcts.getProperty(MTOMConstants.ATTACHMENTS); out += \nattachment = +attachment; contentID = contentID.trim (); if (contentID.substring(0, 3).equalsIgnoreCase(cid)) { contentID = contentID.substring(4); } DataHandler dataHandler = attachment.getDataHandler(contentID); out += \n dataHandler = +dataHandler; OMText textNode = new OMTextImpl(dataHandler, xop.getOMFactory()); imageEl.build(); xop.detach(); imageEl.addChild(textNode); OMText binaryNode = (OMText) xop.getFirstOMChild(); DataHandler dh = (DataHandler)binaryNode.getDataHandler(); Image image = new ImageIO().loadImage(dh.getDataSource().getInputStream()); FileOutputStream imageOutStream = new FileOutputStream(/home/souillac/thinkAttachment.jpg); new ImageIO().saveImage(image/jpeg, image, imageOutStream); } catch (Exception e) { out += \ncatch : +getExceptionAsString(e); } out += /result; out += /initiateHelloWorldResponse; retDoc = InitiateHelloWorldResponseDocument.Factory.parse (out); } catch (Exception e) { e.printStackTrace(); } return retDoc; } private String getExceptionAsString(Throwable ex) { String excep = \n+ex.getClass()+ : +ex.getMessage()+\n; while (ex != null) { StackTraceElement[] steTab = ex.getStackTrace(); for (int j=0;j steTab.length;j++) { StackTraceElement ste = steTab[j]; excep += at + ste.toString() + \n; } ex = ex.getCause (); if (ex != null) { excep += caused by \n; } } return excep; } } package helloworld; import java.awt.Image; import java.io.FileInputStream; import java.io.StringWriter; import javax.activation.DataHandler; import javax.xml.stream.XMLOutputFactory; import org.apache.axiom.attachments.utils.ImageDataSource; import org.apache.axiom.attachments.utils.ImageIO; import org.apache.axiom.om.OMAbstractFactory ; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMText; import org.apache.axiom.soap.SOAP11Constants ; import org.apache.axis2.Constants; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; public class HelloWorldClient { private static EndpointReference targetEPR = new EndpointReference(http://localhost:8080/axis2/services/HelloWorldServiceBP ); public static void main(String[] args) { System.out.println(In Axis2 HelloWorld Client...); if (args.length != 1) { System.out.println (You must specify one and only one argument); } else { try { callAXIOMWithAttachment(args[0]); } catch (Exception e) { e.printStackTrace(); } } } private static void callAXIOMWithAttachment(String name) throws Exception { OMFactory fac = OMAbstractFactory.getOMFactory (); OMNamespace omNs = fac.createOMNamespace(urn:helloworld:bpel:bsoap, tns); OMElement payload = fac.createOMElement(initiateHelloWorld, omNs); //name OMElement nameEl = fac.createOMElement(name, omNs); nameEl.addChild(fac.createOMText(nameEl, name)); //image OMElement image = fac.createOMElement(image, omNs); FileInputStream fis = new FileInputStream(/home/souillac/divers/images/think.jpg); Image expectedImage = new ImageIO().loadImage(fis); ImageDataSource dataSource = new ImageDataSource(think.jpg,expectedImage); DataHandler expectedDH = new
Re: Attachment use in the WS skeleton
Thank you !!! using LABEL_IN_VALUE is coreect !! Then in my client file, I only have to perform the following code and the image is created on my hard disk ! OMElement xop = (OMElement)imageEl.getFirstOMChild(); OMAttribute attr = xop.getAttribute(new QName(href)); String contentID = attr.getAttributeValue(); Attachments attachment = (Attachments) msgcts.getProperty(MTOMConstants.ATTACHMENTS); contentID = contentID.trim(); if (contentID.substring(0, 3).equalsIgnoreCase(cid)) { contentID = contentID.substring(4); } DataHandler dataHandler = attachment.getDataHandler(contentID); Image image = new ImageIO().loadImage(dataHandler.getDataSource().getInputStream()); FileOutputStream imageOutStream = new FileOutputStream(/home/souillac/thinkAttachment.jpg); new ImageIO().saveImage(image/jpeg, image, imageOutStream); Thanks again, Regards, Charles Thilina Gunarathne wrote: Hi, I can suggested three ways to access the binary content according to my choice priority. 1. I don't have a much of a knowledge in Data Bounded code. But if the data binding is properly handled for MTOM then there should be a getter for a Data Handler or a Byte[] in your helloworld.InitiateHelloWorldDocument .. 2. Regarding your server code, You can access the OMText object containing the Binary data from imageEle element by calling it's getFirstChild() method. Then you can call the getDataHandler() method of that OMText instance to get the DataHandler. This should work. 3.I don't understand why you are trying to access the attachments Map in the msgContext. This method is to use with SwA type attachments, though it should work even in this scenario(with loads of unnecessary overhead) . I noticed that you are setting the out message context in the setOperationContext method using WSDLConstants.MESSAGE_LABEL_OUT_VALUE. Try using LABEL_IN_VALUE. I personally don't recommend the 3rd method to access MTOM attachments. It's lot easier than that. :) HTH, ~Thilina for (Iterator it = payload.getChildElements();it.hasNext();) { OMElement el = (OMElement) it.next(); if (el.getLocalName().equalsIgnoreCase(image)) { imageEl = el; } else if (el.getLocalName().equalsIgnoreCase(name)) { nameEl = el; } } String out = initiateHelloWorldResponse xmlns=\urn:helloworld:bpel:bsoap\; out += result; try { OMElement xop = (OMElement)imageEl.getFirstOMChild(); OMAttribute attr = xop.getAttribute (new QName(href)); out += \nattr = +attr; String contentID = attr.getAttributeValue(); out += \ncontentID = +contentID; Attachments attachment = (Attachments) msgcts.getProperty(MTOMConstants.ATTACHMENTS); out += \nattachment = +attachment; contentID = contentID.trim (); if (contentID.substring(0, 3).equalsIgnoreCase(cid)) { contentID = contentID.substring(4); } DataHandler dataHandler = attachment.getDataHandler(contentID); out += \n dataHandler = +dataHandler; OMText textNode = new OMTextImpl(dataHandler, xop.getOMFactory()); imageEl.build(); xop.detach(); imageEl.addChild(textNode); OMText binaryNode = (OMText) xop.getFirstOMChild(); DataHandler dh = (DataHandler)binaryNode.getDataHandler(); Image image = new ImageIO().loadImage(dh.getDataSource().getInputStream()); FileOutputStream imageOutStream = new FileOutputStream(/home/souillac/thinkAttachment.jpg); new ImageIO().saveImage(image/jpeg, image, imageOutStream); } catch (Exception e) { out += \ncatch : +getExceptionAsString(e); } out += /result; out += /initiateHelloWorldResponse; retDoc = InitiateHelloWorldResponseDocument.Factory.parse (out); } catch (Exception e) { e.printStackTrace(); } return retDoc; } private String getExceptionAsString(Throwable ex) { String excep = \n+ex.getClass()+ : +ex.getMessage()+\n; while (ex != null) { StackTraceElement[] steTab = ex.getStackTrace();
Re: Attachment use in the WS skeleton
Hi, I have added the enable mtom property(true) I still have an error. Which code should I execute in the skeleton when this property is enabled ? With no change, the cast OMText binaryNode = (OMText) imageEl.getFirstOMChild(); fails. And with the property, the message I can catch between my client and axis is the following : Thanks for your help. POST /axis2/services/HelloWorldServiceBP HTTP/1.1 User-Agent: Axis2 SOAPAction: initiate Host: localhost:12000 Transfer-Encoding: chunked Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801; type=application/xop+xml; start=0.urn:uuid:[EMAIL PROTECTED]; start-info=text/xml; charset=UTF-8 b5d --MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801 content-type:application/xop+xml; charset=UTF-8; type=text/xml; content-transfer-encoding:binary content-id: 0.urn:uuid:[EMAIL PROTECTED] ?xml version='1.0' encoding='UTF-8'? soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/; soapenv:Header / soapenv:Body tns:initiateHelloWorld xmlns:tns=urn:helloworld:bpel:bsoap tns:image xop:Include href=cid:1.urn:uuid:[EMAIL PROTECTED] xmlns:xop=http://www.w3.org/2004/08/xop/include; / /tns:image tns:namey/tns:name /tns:initiateHelloWorld /soapenv:Body /soapenv:Envelope--MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801content-id: 1.urn:uuid:[EMAIL PROTECTED]content-type:image/jpegcontent-transfer-encoding:binary and a lot of symbols... Thilina Gunarathne wrote: May be i can give you a helping hand if you u post the generated skeleton as well... I'm not sure wat's the param0. I'm not that familiar with data bounded MTOM skeletons :(... Problem seems that you are not getting hold of the correct textNode with binary data.. Looking at the exception you are asking a DataHandler from a non-binary node.. You can use the TCPMON to see how your attachment is going... See whether it goes as a MIME part or as base64.. Thanks, ~Thilina On 5/12/06, *Charles Souillard* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi all, I am using Axis 2 1.0 on a Linux computer for 2 weeks. I am using Sun jdk1.5.0_06. I am able to call a simple Helloworld WS using xmlbeans DataBinding. I haven't modified axis2.xml configuration. Axis 2 web app is deployed into my Tomcat 5.5.15. I am now trying to add an attachment in the message I send to the WS. My problem is to access the binary data received in the skeleton. I made a test in the client to build the image with the same code I use in the skeleton and it is successfull. You can find the code I use and the exception I get below. Can you help me ? I think I have only made a copy/paste from the MTOM guide available in the axis2 documentation. Thanks a lot Regards Charles I get the following exception : ContentID is null at org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:339) at org.apache.axis2.HelloWorldServiceBPSkeleton.initiate(HelloWorldServiceBPSkeleton.java:162) at org.apache.axis2.HelloWorldServiceBPMessageReceiverInOut.invokeBusinessLogic(HelloWorldServiceBPMessageReceiverInOut.java :50) at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest (HTTPTransportUtils.java:284) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service( HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java :173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java :667) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at
Re: Attachment use in the WS skeleton
Hi, you can find in attachment the client, the wsdl and the skeleton files. Thanks a lot for your help. Charles Charles Souillard wrote: Hi, I have added the enable mtom property(true) I still have an error. Which code should I execute in the skeleton when this property is enabled ? With no change, the cast OMText binaryNode = (OMText) imageEl.getFirstOMChild(); fails. And with the property, the message I can catch between my client and axis is the following : Thanks for your help. POST /axis2/services/HelloWorldServiceBP HTTP/1.1 User-Agent: Axis2 SOAPAction: initiate Host: localhost:12000 Transfer-Encoding: chunked Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801; type=application/xop+xml; start=0.urn:uuid:[EMAIL PROTECTED]; start-info=text/xml; charset=UTF-8 b5d --MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801 content-type:application/xop+xml; charset=UTF-8; type=text/xml; content-transfer-encoding:binary content-id: 0.urn:uuid:[EMAIL PROTECTED] ?xml version='1.0' encoding='UTF-8'? soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/; soapenv:Header / soapenv:Body tns:initiateHelloWorld xmlns:tns=urn:helloworld:bpel:bsoap tns:image xop:Include href=cid:1.urn:uuid:[EMAIL PROTECTED] xmlns:xop=http://www.w3.org/2004/08/xop/include; / /tns:image tns:namey/tns:name /tns:initiateHelloWorld /soapenv:Body /soapenv:Envelope--MIMEBoundaryurn_uuid_CC9B93F1D476A848F611476788200801content-id: 1.urn:uuid:[EMAIL PROTECTED]content-type:image/jpegcontent-transfer-encoding:binary and a lot of symbols... Thilina Gunarathne wrote: May be i can give you a helping hand if you u post the generated skeleton as well... I'm not sure wat's the param0. I'm not that familiar with data bounded MTOM skeletons :(... Problem seems that you are not getting hold of the correct textNode with binary data.. Looking at the exception you are asking a DataHandler from a non-binary node.. You can use the TCPMON to see how your attachment is going... See whether it goes as a MIME part or as base64.. Thanks, ~Thilina On 5/12/06, *Charles Souillard* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi all, I am using Axis 2 1.0 on a Linux computer for 2 weeks. I am using Sun jdk1.5.0_06. I am able to call a simple Helloworld WS using xmlbeans DataBinding. I haven't modified axis2.xml configuration. Axis 2 web app is deployed into my Tomcat 5.5.15. I am now trying to add an attachment in the message I send to the WS. My problem is to access the binary data received in the skeleton. I made a test in the client to build the image with the same code I use in the skeleton and it is successfull. You can find the code I use and the exception I get below. Can you help me ? I think I have only made a copy/paste from the MTOM guide available in the axis2 documentation. Thanks a lot Regards Charles I get the following exception : ContentID is null at org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:339) at org.apache.axis2.HelloWorldServiceBPSkeleton.initiate(HelloWorldServiceBPSkeleton.java:162) at org.apache.axis2.HelloWorldServiceBPMessageReceiverInOut.invokeBusinessLogic(HelloWorldServiceBPMessageReceiverInOut.java :50) at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest (HTTPTransportUtils.java:284) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service( HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java :173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at
Re: Attachment use in the WS skeleton
May be i can give you a helping handif youu post the generated skeleton as well... I'm not sure wat's the param0. I'm not that familiar with data bounded MTOM skeletons :(... Problem seems that you are not getting hold of thecorrect textNode with binary data.. Looking at the exception you are asking a DataHandler from a non-binary node.. You can use the TCPMON to see how your attachment is going... See whether it goes as a MIME part or as base64.. Thanks, ~Thilina On 5/12/06, Charles Souillard [EMAIL PROTECTED] wrote: Hi all,I am using Axis 2 1.0 on a Linux computerfor 2 weeks. I am using Sunjdk1.5.0_06.I am able to call a simple Helloworld WS using xmlbeans DataBinding. I haven't modified axis2.xml configuration. Axis 2 web app is deployedinto my Tomcat 5.5.15.I am now trying to add an attachment in the message I send to the WS.My problem is to access the binary data received in the skeleton. I made a test in the client to build the image with the same code I usein the skeleton and it is successfull.You can find the code I use and the exception I get below.Can you help me ?I think I have only made a copy/paste from the MTOM guide available in the axis2 documentation.Thanks a lotRegardsCharlesI get the following exception :ContentID is nullatorg.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:339)at org.apache.axis2.HelloWorldServiceBPSkeleton.initiate(HelloWorldServiceBPSkeleton.java:162)atorg.apache.axis2.HelloWorldServiceBPMessageReceiverInOut.invokeBusinessLogic(HelloWorldServiceBPMessageReceiverInOut.java :50)atorg.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37)at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454)atorg.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest (HTTPTransportUtils.java:284)at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136)at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)at javax.servlet.http.HttpServlet.service( HttpServlet.java:802)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java :173)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)atorg.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:126)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)atorg.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:148)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)atorg.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java :667)atorg.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)atorg.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)atorg.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run (ThreadPool.java:684)at java.lang.Thread.run(Thread.java:595)My WSDL looks like :complexType name=initiateHelloWorldT sequence element name=name type=xsd:string / element name=image type=xsd:base64Binary / /sequence/complexTypeelement name=initiateHelloWorld type=tns:initiateHelloWorldT / My Client looks like :OMFactory fac = OMAbstractFactory.getOMFactory();OMNamespace omNs = fac.createOMNamespace(urn:helloworld:bpel:bsoap,tns);OMElement payload = fac.createOMElement (initiateHelloWorld, omNs);//nameOMElement nameEl = fac.createOMElement(name, omNs);nameEl.addChild(fac.createOMText(nameEl, name));//imageOMElement image = fac.createOMElement(image, omNs); FileInputStream fis = newFileInputStream(/home/souillac/divers/images/think.jpg);System.out.println(fis = +fis.available());Image expectedImage = new ImageIO().loadImage(fis);ImageDataSource dataSource = new ImageDataSource( think.jpg,expectedImage);DataHandler expectedDH = new DataHandler(dataSource);OMText textData = fac.createOMText(expectedDH, true);image.addChild(textData);payload.addChild(image);payload.addChild (nameEl);Options options = new Options();options.setTo(targetEPR);options.setTransportInProtocol(Constants.TRANSPORT_HTTP);options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);options.setAction (initiate);ServiceClient sender = new ServiceClient();sender.setOptions(options);OMElement result = sender.sendReceive(payload);My skeleton looks like :OMFactory fac = OMAbstractFactory.getOMFactory ();StAXOMBuilder builder = new StAXOMBuilder(fac,newStreamWrapper(param0.newXMLStreamReader())) ;OMElement payload = builder.getDocumentElement();((OMNodeEx)payload).setParent(null);OMElement imageEl = null; OMElement nameEl = null;for (Iterator it = payload.getChildElements();it.hasNext();) {OMElement el = (OMElement) it.next();if
Attachment use in the WS skeleton
Hi all, I am using Axis 2 1.0 on a Linux computer for 2 weeks. I am using Sun jdk1.5.0_06. I am able to call a simple Helloworld WS using xmlbeans DataBinding. I haven't modified axis2.xml configuration. Axis 2 web app is deployed into my Tomcat 5.5.15. I am now trying to add an attachment in the message I send to the WS. My problem is to access the binary data received in the skeleton. I made a test in the client to build the image with the same code I use in the skeleton and it is successfull. You can find the code I use and the exception I get below. Can you help me ? I think I have only made a copy/paste from the MTOM guide available in the axis2 documentation. Thanks a lot Regards Charles I get the following exception : ContentID is null at org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:339) at org.apache.axis2.HelloWorldServiceBPSkeleton.initiate(HelloWorldServiceBPSkeleton.java:162) at org.apache.axis2.HelloWorldServiceBPMessageReceiverInOut.invokeBusinessLogic(HelloWorldServiceBPMessageReceiverInOut.java:50) at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) My WSDL looks like : complexType name=initiateHelloWorldT sequence element name=name type=xsd:string / element name=image type=xsd:base64Binary / /sequence /complexType element name=initiateHelloWorld type=tns:initiateHelloWorldT / My Client looks like : OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(urn:helloworld:bpel:bsoap, tns); OMElement payload = fac.createOMElement(initiateHelloWorld, omNs); //name OMElement nameEl = fac.createOMElement(name, omNs); nameEl.addChild(fac.createOMText(nameEl, name)); //image OMElement image = fac.createOMElement(image, omNs); FileInputStream fis = new FileInputStream(/home/souillac/divers/images/think.jpg); System.out.println(fis = +fis.available()); Image expectedImage = new ImageIO().loadImage(fis); ImageDataSource dataSource = new ImageDataSource(think.jpg,expectedImage); DataHandler expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); payload.addChild(image); payload.addChild(nameEl); Options options = new Options(); options.setTo(targetEPR); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); options.setAction(initiate); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement result = sender.sendReceive(payload); My skeleton looks like : OMFactory fac = OMAbstractFactory.getOMFactory(); StAXOMBuilder builder = new StAXOMBuilder(fac,new StreamWrapper(param0.newXMLStreamReader())) ; OMElement payload = builder.getDocumentElement(); ((OMNodeEx)payload).setParent(null); OMElement imageEl = null; OMElement nameEl = null; for (Iterator it = payload.getChildElements();it.hasNext();) { OMElement el = (OMElement) it.next(); if (el.getLocalName().equalsIgnoreCase(image)) { imageEl = el; } else if (el.getLocalName().equalsIgnoreCase(name)) { nameEl = el; } } OMText binaryNode = null; try { binaryNode = (OMText) imageEl.getFirstOMChild(); DataHandler dh = (DataHandler)binaryNode.getDataHandler(); Image image = new ImageIO().loadImage(dh.getDataSource().getInputStream());