Which two code fragments retrieve the faultcode, faultstring, and faultactor from the message?

Click the Exhibit button.
***MISSING EXHIBIT***
<SOAP-ENV:Envelope xmlns:SOAPENV=" http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>
Invalid Message
</faultstring>
<faultactor>http://flashnsizzle.com/order</faultactor>
<detail>
<PO:order xmlns:PO="http://flashnsizzle.com/orders/">
Incomplete order
</PO:order>
<PO:confirmation xmlns:PO="http://flashnsizzle.com/confirm">
Invalid address
</PO:confirmation>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
A developer is implementing a Java client for a Web service. Occasionally the Web service call fails unexpectedly, so the developer wants to print out the error messages being returned from the call. Which two code fragments retrieve the faultcode, faultstring, and faultactor from the message? (Choose two.)
A. try {

// business logic to access a Web service method …
} catch (SOAPFaultException sfe) {
SOAPFault fault = sfe.getFault();
System.out.println("An error occurred:");
System.out.println("actor:"+fault.getFaultActor()); System.out.println("code:"+fault.getFaultCode()); System.out.println
("message:"+fault.getFaultString()); } catch (Exception ex) { ex.printStackTrace();
}
B. try {

// business logic to access a Web service method …
} catch (SOAPFaultException sfe) {
SOAPFault fault = sfe.getFault();
FaultElement code = fault.getElementsByTagName("faultcode"); FaultElement string = fault.getElementsByTagName("faultstring"); FaultElement actor = fault.getElementsByTagName("faultactor"); System.out.println("An error occurred:"); System.out.println("actor:"+actor.getValue());
System.out.println("code:"+code.getValue());
System.out.println("message:"+actor.getValue()); } catch (Exception ex) { ex.printStackTrace();
}
C. try {

// business logic to access a Web service method …
} catch (SOAPFaultException sfe) {
SOAPFault fault = sfe.getFault();
NodeList code = fault.getElementsByTagName("faultcode"); NodeList string = fault.getElementsByTagName("faultstring"); NodeList actor = fault.getElementsByTagName("faultactor"); System.out.println("An error occurred:");
System.out.println("actor:"+ actor.item(0).getNodeValue()); System.out.println("code:"+ code.item(0).getNodeValue()); System.out.println
("message:"+ string.item(0).getNodeValue()); } catch (Exception ex) { ex.printStackTrace();
}
D. try {

// business logic to access a Web service method …
} catch (SOAPFaultException sfe) {
SOAPFault fault = sfe.getFault();
Node code = fault.getElementsByTagName("faultcode"); Node string = fault.getElementsByTagName("faultstring"); Node actor = fault.getElementsByTagName("faultactor"); System.out.println("An error occurred:");
System.out.println("actor:"+actor.getNodeValue()); System.out.println("code:"+code.getNodeValue()); System.out.println("message:"+ string.getNodeValue()); } catch (Exception ex) { ex.printStackTrace();
}
E. try {

// business logic to access a Web service method …
} catch (SOAPFaultException sfe) {
SOAPFault fault = sfe.getFault();
System.out.println("An error occurred:");
System.out.println("actor:"+fault.getSOAPFaultActor()); System.out.println("code:"+fault.getSOAPFaultCode()); System.out.println
("message:"+fault.getSOAPFaultString()); } catch (Exception ex) {
ex.printStackTrace();
}

Download Printable PDF. VALID exam to help you PASS.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.