This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes jax ws provider return a soap fault Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "jax ws provider return a soap fault" Watch "jax ws provider return a soap fault" New topic
Author

jax ws provider return a soap fault

Jim Akmer
Ranch Hand

Joined: Jul 06, 2010
Posts: 104
Hi,

I have asked this elsewhere but got no answer, so I will try again here.
When using a JAX-WS provider in payload mode
E.g.


how can I return a SOAP fault if the processing fails? Is it possible to do it when working directly on the xml payload?
If I was working in Message level (SOAP envelope) I know how to do it. I am not sure when I work on
I understand that if I throw an exception it will be mapped to a 500 Internal Error but what about faultstring, detail etc? How are they populated? How can I do it in xml level?

Thanks!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you tried the following approach:
1. Look at a fault message from some other web service.
2. Use some Java API to create an appropriate fault message (for example, DOM or JAXB).
3. From the method in the web service endpoint implementation class, return an object implementing the javax.xml.transform.Source interface (see API documentation) to which the fault message has been "written".
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Jim,
Ivan proposed an easy approach of doing this which we were doing in our previous projects when working on MDBs. But, can I ask you what you get if you generate WSDL from an interface throwing your business exception? I think if WSDL is correctly mapped, I'm sure you'd get corresponding SOAPFault when business exception is thrown.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jax ws provider return a soap fault
 
Similar Threads
How to get SOAP response as XML in Client Struts or Servlet. ?
how we can access to soap fault when having soapMessage?
Any feedback for SCDJWS Beta?
Webservice implementing Provider<Source>: no difference with service mode MESSAGE or PAYLOAD
Regarding javax.xml.ws.Provider interface