public void testWriteFault_dom() throws Exception { SOAPMessage soapMessage = writeFault(); Element envelope = writeAndRead(soapMessage); Element body = XmlUtil.getElement(envelope, SOAPConstants.URI_NS_SOAP_ENVELOPE, "Body"); Element fault = XmlUtil.getElement(body, SOAPConstants.URI_NS_SOAP_ENVELOPE, "Fault"); Element faultcode = XmlUtil.getElement(fault, "faultcode"); assertEquals( XmlUtil.getPrefix(SoapBindConstants.CLIENT_FAULTCODE.getNamespaceURI(), faultcode) + ':' + SoapBindConstants.CLIENT_FAULTCODE.getLocalPart(), DatatypeUtil.toString(faultcode)); Element faultstring = XmlUtil.getElement(fault, "faultstring"); assertEquals(SoapBindConstants.BUSINESS_FAULTSTRING, DatatypeUtil.toString(faultstring)); Element detail = XmlUtil.getElement(fault, "detail"); Element faultElement = XmlUtil.getElement(detail, BpelConstants.NS_EXAMPLES, "faultElement"); Element code = XmlUtil.getElement(faultElement, "code"); assertEquals("100", DatatypeUtil.toString(code)); Element description = XmlUtil.getElement(faultElement, "description"); assertEquals("unknown problem", DatatypeUtil.toString(description)); }
private static void testFaultCode(SOAPElement fault) { SOAPElement faultcodeElem = SoapUtil.getElement(fault, "faultcode"); String codeNamespace = SoapBindConstants.CLIENT_FAULTCODE.getNamespaceURI(); assertEquals( SoapUtil.getPrefix(codeNamespace, faultcodeElem) + ':' + SoapBindConstants.CLIENT_FAULTCODE.getLocalPart(), faultcodeElem.getValue()); }