use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class EchoImpl method createSOAPFaultException.
private SOAPFaultException createSOAPFaultException() {
try {
String namespace = "http://example.com/auctiontraq/schemas/doclit";
SOAPFactory soapFactory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
Name name = soapFactory.createName("MySOAPFault", "ns0", namespace);
Detail detail = soapFactory.createDetail();
DetailEntry entry = detail.addDetailEntry(name);
entry.addNamespaceDeclaration("data", namespace);
Name attrName1 = soapFactory.createName("myAttr", "data", namespace);
entry.addAttribute(attrName1, "myvalue");
SOAPElement child = entry.addChildElement("message");
child.addTextNode("Server Exception");
Name name2 = soapFactory.createName("ExtraInformation", "ns0", namespace);
DetailEntry entry2 = detail.addDetailEntry(name2);
SOAPElement child2 = entry2.addChildElement("Reason");
child2.addTextNode("Address Not Found");
QName qname = new QName("http://www.w3.org/2003/05/soap-envelope", "Receiver");
SOAPFault sf = soapFactory.createFault("SOAP Fault Exception:Address Not Found", qname);
org.w3c.dom.Node n = sf.getOwnerDocument().importNode(detail, true);
sf.appendChild(n);
return new SOAPFaultException(sf);
// printDetail(detail);
// return new SOAPFaultException(qname,
// "SOAP Fault Exception:Address Not Found", null, detail);
} catch (SOAPException e) {
e.printStackTrace();
// QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/", "client");
throw new WebServiceException("Exception While Creating SOAP Fault Exception", e);
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testMissingActionWithWSDL.
public void testMissingActionWithWSDL() throws Exception {
try {
WebServiceFeature[] features = new WebServiceFeature[] { new AddressingFeature(false) };
Dispatch dispatch = createDispatchWithWSDL(features);
BindingImpl binding = (BindingImpl) dispatch.getBinding();
AddressingVersion addressingVersion = AddressingVersion.fromBinding(binding);
System.out.println("Addressing version is " + addressingVersion);
assertFalse(AddressingVersion.isEnabled(binding));
WsaUtils.invoke(dispatch, WsaUtils.MISSING_ACTION_MESSAGE, WsaUtils.S11_NS, WsaUtils.W3C_WSA_NS, getAddress(), W3CAddressingConstants.WSA_ANONYMOUS_ADDRESS);
fail("SOAPFaultException must be thrown");
} catch (SOAPFaultException sfe) {
assertFault(sfe, W3CAddressingConstants.MAP_REQUIRED_QNAME);
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class SoapMuHeaderTest method testMUHeaderNotInWSDL.
public void testMUHeaderNotInWSDL() {
Hello_Service service = new Hello_Service();
Hello port = service.getHelloPort();
Holder<String> extra = new Holder<String>();
try {
port.hello("extraMU", extra);
fail("MU Exception expected");
} catch (SOAPFaultException e) {
assertTrue(e.getFault().getFaultCode().endsWith(":MustUnderstand"));
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testClientOutboundProtocolException2.
/*
* Same as testClientOutboundProtocolException1 except that
* it uses the first soap handler in the chain to make sure
* it skips to the logical handlers without an array index error.
*/
public void testClientOutboundProtocolException2() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
reportStub.clearHandlerTracker();
tracker.clearAll();
for (int i = 0; i < numTotalHandlers; i++) {
tracker.setHandlerAction(CLIENT_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
tracker.setHandlerAction(CLIENT_PREFIX + 4, HA_THROW_PROTOCOL_EXCEPTION_OUTBOUND);
try {
testStub.testInt(42);
fail("did not receive an exception");
} catch (SOAPFaultException e) {
assertTrue(true);
}
// check result
String[] called = { "0", "1", "3", "4", "3_FAULT", "1_FAULT", "0_FAULT" };
int[] closed = { 4, 3, 1, 0 };
List<String> calledHandlers = tracker.getCalledHandlers();
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + called[i], calledHandlers.get(i));
}
List<String> closedHandlers = tracker.getClosedHandlers();
assertEquals("Did not get proper number of closed handlers", closed.length, closedHandlers.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], closedHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = tracker.getDestroyedHandlers();
assertTrue("Should be 0 destroyed handlers", destroyedHandlers.isEmpty());
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testServerInboundProtocolException1.
/*
* Have one of the server handlers throw a simple protocol
* exception and check that the proper methods are called.
*
* This test checks the fault code as well -- related to
* bug 6350633.
*/
public void testServerInboundProtocolException1() throws Exception {
// the expected fault code local part
String server = "Server";
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
// these lines make calls to the server
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_PROTOCOL_EXCEPTION_INBOUND);
// so we clear out the client handlers afterwards
tracker.clearAll();
try {
testStub.testInt(3);
fail("did not receive exception");
} catch (SOAPFaultException e) {
SOAPFault fault = e.getFault();
String faultCode = fault.getFaultCode();
assertTrue("fault code should end with \"" + server + "\": " + faultCode, faultCode.endsWith(server));
}
// check result
String[] called = { "4", "2", "4_FAULT" };
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", SERVER_PREFIX + called[i], calledHandlers.get(i));
}
// too many closes to check them all
// should be no destroyed handlers
List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
assertEquals("Should be 0 destroyed handlers", 0, destroyedHandlers.size());
}
Aggregations