aspose file tools*
The moose likes Web Services and the fly likes Using SOAP fault messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Using SOAP fault messages" Watch "Using SOAP fault messages" New topic
Author

Using SOAP fault messages

vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
how to use the SOAP fault messages in Axis Java Webservices.

Any example?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
This article may get you going.
vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
how to configure the fault elements in server-conf.wsdd file
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
SOAP faults are not something you configure. The web service may generate faults, and those faults need to be declared in the WSDL that describes the service, so that the client can handle them appropriately.

Did you take a look at that article?
vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
but my wsdl generated automatically by axis according
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
In that case you can't take advantage of the automatic mapping between Java exception and SOAP faults. But you can still generate the faults on the server; it's just that the client then needs to specifically check for SOAP faults. You can write a client-side handler that uses the handleFault method to implement this. This page has various bits and pieces of information how to write that method.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
You can also take a look at the "faults" sample code that comes with Axis. It shows how to write and deploy your code in a way that SOAPFaults are used, and the WSDL is automatically generated correctly, including the wsdl:fault information.
vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
if throw SOAPFaultException the parser is returning error.
vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
if we use the CustomException those are not getting parsed.
vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
if use the CustomException i'm getting following error.

xception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: com.mc.MyException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:atlanta

com.mc.MyException
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2765)
at org.apache.axis.client.Call.invoke(Call.java:2748)
at org.apache.axis.client.Call.invoke(Call.java:2424)
at org.apache.axis.client.Call.invoke(Call.java:2347)
at org.apache.axis.client.Call.invoke(Call.java:1804)
at org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:163)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
If SOAPFaultException is thrown, you can add a client-side handler that examines the body of the response for faults, and acts accordingly. You still need to catch the exception in your client code, though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using SOAP fault messages