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:name>y</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
    
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());
    FileOutputStream imageOutStream = new
    FileOutputStream("/home/souillac/thinkAttachment.jpg");
    new ImageIO().saveImage("image/jpeg", image, imageOutStream);
    } catch (Exception e) {}





--
"May the SourcE be with u" http://webservices.apache.org/~thilina/ <http://webservices.apache.org/%7Ethilina/> http://thilinag.blogspot.com/ http://www.bloglines.com/blog/Thilina

Reply via email to