Question

Am pretty new to web services and have been trying to implement Soap Faults. I used Apache Axis2 to generate webservice in the following manner.

public interface XYZ{
public String myMethod(User[] user)
}

Here I have created a User class with some variables so that I can generate User object at .Net environment to pass User[] of objects.

Public class Webservice implements XYZ
{
Public String myMethod(User[] user){
//My implementation
}
}

Now, I created a dynamic project using Eclipse and with the help of Axis2 plugin I created webservice for my "Webservice" class which generates wsdl file. I deployed the webcontent in the Tomcat folder and able to access the WSDL file in the .Net environment. I am able to pass array of objects (User[]) from .Net to Java and able to do my task. Now, I need to implement Soap Faults in Java which I am not sure how to implement.

Can anyone help me with an example or tutorial ?

Was it helpful?

Solution

Your best bet is to Google for something like "jax-ws faults". For example:

http://www.ibm.com/developerworks/webservices/library/ws-jaxws-faults/index.html

You can also implement an error handler, as discussed under "Using handlers in JAX-WS Web services" here:

http://axis.apache.org/axis2/java/core/docs/jaxws-guide.html#BottomUpService

OTHER TIPS

Most frameworks will trigger a SOAP fault when you throw an Exception in the method implementing your operation. That will not give you much control on the SOAP fault content though.

See here for some details on Axis

Generally, You don't need any specific coding for implementing SOAP fault.. Whenever there is any exception thrown by the method (here myMethod in your example.), axis will automatically generate SOAPFault element in the resulting response. The exception is actually wrapped into AxisFault exception and sent to the client.

See here a i.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top