You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by El...@lionbridge.com on 2001/11/05 13:59:28 UTC
send an SOAP error
hi all,
i'm making a WebService. As i have in house learned java, i'd like to know
:
the client part of the webservice calls a method (the which one i declared
in my DeploymentDescriptor) and pass some parameters. Then i'd like to
make a test in this method and send back a SOAP error in some cases. What
kind of code should i use to send a SOAP error to the client ?
regards,
Elise
--------------------------------------------
Lionbridge Technologies - France
www.lionbridge.com
Re: send an SOAP error
Posted by Nicholas Quaine <nq...@soapuser.com>.
Elise,
You should be able to throw a SOAPException from within your method
//here's how to throw a SOAPException on the server side
throw new SOAPException ( "My Fault Code", "My Message" );
When you throw the exception, the server sends a SOAP response to the client indicating an error occured on the server side and the fault code and message are contained within that response and can be extracted on the client side as shown below (I assume you are using Apache SOAP for Java on the client side)...
//here's how to setup and invoke a call on the client side, checking for soap exceptions
Call call = new Call();
call.setSOAPMappingRegistry(mySmr);
call.setTargetObjectURI(myServiceName);
call.setMethodName(myMethodName);
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setParams(myParams);
Response resp = call.invoke(new URL(myServletURLName), "");
if (resp.generatedFault())
{
String faultCode = resp.getFault().getFaultCode();
String faultMsg = resp.getFault().getFaultString();
//do something with these...
}
hope that helps
regards,
Nicholas Quaine
Visit http://www.soapuser.com/
nquaine@soapuser.com
----- Original Message -----
From: Elise_Dupont@lionbridge.com
To: soap-user@xml.apache.org
Sent: Monday, November 05, 2001 1:59 PM
Subject: send an SOAP error
hi all,
i'm making a WebService. As i have in house learned java, i'd like to know :
the client part of the webservice calls a method (the which one i declared in my DeploymentDescriptor) and pass some parameters. Then i'd like to make a test in this method and send back a SOAP error in some cases. What kind of code should i use to send a SOAP error to the client ?
regards,
Elise
--------------------------------------------
Lionbridge Technologies - France
www.lionbridge.com
Re: send an SOAP error
Posted by Nicholas Quaine <nq...@soapuser.com>.
Elise,
You should be able to throw a SOAPException from within your method
//here's how to throw a SOAPException on the server side
throw new SOAPException ( "My Fault Code", "My Message" );
When you throw the exception, the server sends a SOAP response to the client indicating an error occured on the server side and the fault code and message are contained within that response and can be extracted on the client side as shown below (I assume you are using Apache SOAP for Java on the client side)...
//here's how to setup and invoke a call on the client side, checking for soap exceptions
Call call = new Call();
call.setSOAPMappingRegistry(mySmr);
call.setTargetObjectURI(myServiceName);
call.setMethodName(myMethodName);
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setParams(myParams);
Response resp = call.invoke(new URL(myServletURLName), "");
if (resp.generatedFault())
{
String faultCode = resp.getFault().getFaultCode();
String faultMsg = resp.getFault().getFaultString();
//do something with these...
}
hope that helps
regards,
Nicholas Quaine
Visit http://www.soapuser.com/
nquaine@soapuser.com
----- Original Message -----
From: Elise_Dupont@lionbridge.com
To: soap-user@xml.apache.org
Sent: Monday, November 05, 2001 1:59 PM
Subject: send an SOAP error
hi all,
i'm making a WebService. As i have in house learned java, i'd like to know :
the client part of the webservice calls a method (the which one i declared in my DeploymentDescriptor) and pass some parameters. Then i'd like to make a test in this method and send back a SOAP error in some cases. What kind of code should i use to send a SOAP error to the client ?
regards,
Elise
--------------------------------------------
Lionbridge Technologies - France
www.lionbridge.com