File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes SOAP compatibility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAP compatibility" Watch "SOAP compatibility" New topic
Author

SOAP compatibility

ayi bogan
Greenhorn

Joined: Aug 29, 2010
Posts: 7
I am new in Soap and have a question about compatibility.
I wrote a Soap with Attachment webservice with cxf and soap1.2.

The EndPoint of the WebService shows like this:


I also wrote a Java based Client:


Questions:
-Is the Parameter: DataHandler a standard for Attachments? Can other clients who are not written in Java use this EndPoint? ( I tried with the Paramter: SOAPMessage message but get a Unmarshalling Error: Unable to create an instance of javax.xml.soap.SOAPMessage ERROR)
-In WebService: data.getInputStream() is ok, dataHandler.getName() is NULL also it filled at ClientSide, anyone a idea?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
When sending files or similar with SOAP messages, you should use SOAP with Attachments.
When constructing a SOAP message with attachments using Java, you commonly use the SAAJ API.
Examples and explanation can be found in my book, which can be freely downloaded at: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
Please refer to sections: 2.3 and 5.7
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 461
    
    4
Why not using JAX-WS with @MTom feature?

SOAP Message Transmission Optimization Mechanism (MTOM) specifies an optimized method for sending binary data as part of a SOAP message.

1. JAX-WS CXF:

http://cxf.apache.org/docs/mtom.html
http://cxf.apache.org/docs/mtom-attachments-with-jaxb.html

See apache-cxf-2.4.2\samples\mtom

2. JAX-WS Metro RI:

http://metro.java.net/guide/Binary_Attachments__MTOM_.html

See xmime:expectedContentType to Java type mapping
6.2.2. Enabling MTOM on server
6.2.3. Enabling MTOM on client
ayi bogan
Greenhorn

Joined: Aug 29, 2010
Posts: 7
Thanks for reply,

If i use Soap Message like:

Client:


WebService:

i get this Exception:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: Unable to create an instance of javax.xml.soap.SOAPMessage
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at $Proxy31.create(Unknown Source)
at de.EndPointClient.main(EndPointClient.java:55)
Caused by: org.apache.cxf.binding.soap.SoapFault: Unmarshalling Error: Unable to create an instance of javax.xml.soap.SOAPMessage
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:107)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:801)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1627)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1494)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1402)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:649)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:535)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:465)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:368)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:321)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 2 more


I used the sample sites which you post, they used DataHandler as Parameter.

H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 461
    
    4
1. Developing web services, Part 3: File uploading web service built with Apache CFX
http://www.ibm.com/developerworks/webservices/library/ws-devaxis2part3/section3.html
See MTOM enabled: Listing 4. cxf.xml

OR this http://skhanzada.wordpress.com/2010/09/13/large-attachements-with-mtom-and-cxf/

2. Whichever helps. Good luck.
 
 
subject: SOAP compatibility