You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Chris Nappin (JIRA)" <ax...@ws.apache.org> on 2005/08/31 17:17:35 UTC
[jira] Created: (AXIS-2203) Unable to read SOAP fault details using JAX-RPC/JAXM APIs
Unable to read SOAP fault details using JAX-RPC/JAXM APIs
---------------------------------------------------------
Key: AXIS-2203
URL: http://issues.apache.org/jira/browse/AXIS-2203
Project: Apache Axis
Type: Bug
Components: Basic Architecture
Versions: 1.2.1
Environment: WIndows XP SP1, Sun JDK 1.4.2, JBoss 4.0.2/Tomcat 5.5.9
Reporter: Chris Nappin
When receiving a custom soap fault, there is no way in Axis to extract the custom information included below the "Details" tag in the fault message. The only possible workaround is to cast the SOAPFault to a org.apache.axis.message.SOAPFault, then use the Axis-specific APIs instead.
Example code is as follows, note I have tried two ways of obtaining the "SOAPFault" object, neither of which work.
public static void main(String[] args) {
try {
// load the XML data
String xmlData = ..load the XML message to send..
// sets the Web Service endpoint url...
String endpoint = "http://localhost:7001/ws/services/MyService";
// call the web service
SOAPMessage response = sendMessage(xmlData, endpoint);
// output the response to the console
System.out.println("Got response: ");
response.writeTo(System.out);
if (response.getSOAPPart().getEnvelope().getBody().hasFault()) {
//SOAPFault fault = response.getSOAPPart().getEnvelope().getBody().getFault();
SOAPFault fault = response.getSOAPBody().getFault();
System.out.println("\nGot fault, " +
"name is " + fault.getFaultCodeAsName().getQualifiedName() +
", code is " + fault.getFaultCode() +
", actor is " + fault.getFaultActor());
Detail detail = fault.getDetail();
if (detail == null) {
System.out.println("Detail is null!");
} else {
System.out.println("\nDetail is " +
XMLUtils.toString(fault.getDetail(), true, true));
}
if (fault instanceof org.apache.axis.message.SOAPFault) {
System.out.println("\nWe have an axis SOAPFault");
AxisFault ex = ((org.apache.axis.message.SOAPFault) fault).getFault();
if (ex != null) {
System.out.println("\nGot AxisFault, " +
"string is " + ex.getFaultString() +
", code is " + ex.getFaultCode() +
", actor is " + ex.getFaultActor());
Element[] details = ex.getFaultDetails();
if (details == null || details.length == 0) {
System.out.println("Details is null/empty!");
} else {
System.out.println("\nDetail is " +
XMLUtils.toString(details[0], true, true));
}
} else {
System.out.println("AxisFault is null!");
}
}
} else {
System.out.println("\nNo fault!");
}
} catch (RemoteException ex) {
ex.printStackTrace();
System.exit(-1);
} catch (IOException ex) {
ex.printStackTrace();
System.exit(-1);
} catch (SOAPException ex) {
ex.printStackTrace();
System.exit(-1);
} catch (XMLException ex) {
ex.printStackTrace();
System.exit(-1);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira