aspose file tools*
The moose likes Web Services and the fly likes Web Method Faults for JAX-WS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Method Faults for JAX-WS" Watch "Web Method Faults for JAX-WS" New topic
Author

Web Method Faults for JAX-WS

Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Good morning to everyone,

There are many frameworks to build Web Services, and in my case I'm trying to build one using standard JAX-WS. However I have not found the way to correctly throw an Exception and Wrap it as a Web Service Fault, or SOAPResponse (by this I mean that it has to be defined as a Fault in the WSDL).

Here are some details of what I'm trying to do:



NotFoundException defined...



To summarize, what I want to do is: When I throw the Exception inside my java-web-method it should return a SOAPResponse to the client, one in the form of the Custom Exception I defined (NotFoundException), and this Exception should appear as a type in the WSDL for this web service as well.
How can I do this ?

Well, I hope i have made what I want to do clear.
Thanks in advance, and Have a great day !

Jose
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

One of the issues I found in doing that is that my WSDL wont give that as the contract. It gave me a success message contract but the error message contract was missing from WSDL. Hence when I try to use that contract in a rules based engine eg. BPEL it wont recognize the error message since it does not exist in the contract


===Vyas Sanzgiri===
My Blog
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Hello Vyas !

You understand my problem perfectly. My intention is to build a Process, using a BPEL engine. Therefore it is of utmost importance to have Web Service Faults Correctly defined in the WSDL.
In this way, it is easier to implement the navigational cases in a BPEL-based process choreography; otherwise it becomes a nightmare to develop.

I sincerely hope somebody has solved this in the past.

Have a nice Day !

Jose

Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

I am interested in learning this case too. Just FYI - I finally ended up having a status code in my message and WSDL and the client handles this code. There is a code for error and a success. But I would like to know the "correct" way to handle this!
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
That's great Vyas !

Would you mind sharing a little bit of your implementation? Like a piece of code everybody would find useful. Personally, I'd love to see it, so that I can take it from there and see If I can figure something out during the weekend.

Anyways, I know there's gotta be a way to get this done, I have seen a framework called cxf, that generates this code for Java. so, it's obvious that it can be done using JAX-WS alone; and that's in my opinion what one's got to be learning because everything else is built on it.

Thank you very much for your response,

Sincerely,

Jose
Hung W Yee
Greenhorn

Joined: Jul 31, 2009
Posts: 1
Maybe this web article can help you:
http://www.ibm.com/developerworks/webservices/library/ws-jaxws-faults/index.html
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Hi there !

Thanks for the article, I'll read it throughly.

I wish there's an article like that one by Sun.

But that's probably just day-dreaming. Anyways, let me know If there's something else you wish to add.

Good Luck,

Jose
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Method Faults for JAX-WS
 
Similar Threads
logic:present not validating as it was supposed to. where did i got it wrong ?
throw new Exception() confusion
java.lang.Class NotFoundException
want to send pdf file to client from server. pdf is generated at server
Java & Outlook integration - how to go about it