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]> 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://thilinag.blogspot.com/                 http://www.bloglines.com/blog/Thilina              

Reply via email to