use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class WsaTestImpl method echo.
public String echo(String param) {
System.out.println(NAME + ".echo: " + param);
String message = null;
if (param.equals(""))
message = "The echo string was empty";
if (param.startsWith("fault"))
message = "\"" + param + "\" triggered the fault";
if (message != null)
throw new SOAPFaultException(createSOAPFault(message));
return param;
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testInvalidReplyTo.
public void testInvalidReplyTo() throws Exception {
try {
SOAPMessage response = WsaUtils.invoke(createDispatchWithoutWSDL(), WsaUtils.INVALID_REPLY_TO_MESSAGE, WsaUtils.S11_NS, WsaUtils.W3C_WSA_NS, getAddress(), "WRONG", W3CAddressingConstants.WSA_ANONYMOUS_ADDRESS, CORRECT_ACTION);
fail("SOAPFaultException must be thrown");
} catch (SOAPFaultException sfe) {
assertTrue("Got SOAPFaultException", true);
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class WsaTestImpl method echo.
public String echo(String param) {
System.out.println(NAME + ".echo: " + param);
String message = null;
if (param.equals(""))
message = "The echo string was empty";
if (param.startsWith("fault"))
message = "\"" + param + "\" triggered the fault";
if (message != null)
throw new SOAPFaultException(createSOAPFault(message));
return param;
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class MUTest method testMU_SOAP11.
public void testMU_SOAP11() throws Exception {
QName portQName = new QName("http://server.mu_header_fault.server/", "TestEndpointPort");
Dispatch<SOAPMessage> dispatch = new TestEndpointService().createDispatch(portQName, SOAPMessage.class, Service.Mode.MESSAGE);
SOAPMessage message = getSOAPMessage(makeStreamSource(s11_request));
try {
Object result = dispatch.invoke(message);
} catch (SOAPFaultException e) {
SOAPFault sf = e.getFault();
assertTrue(sf.getFaultCode().endsWith(":MustUnderstand"));
NodeList nl = ((Element) sf).getChildNodes();
int codeIndex = indexOf(new QName("", "faultcode"), nl);
int reasonIndex = indexOf(new QName("", "faultstring"), nl);
assertTrue("<faultcode> and <faultstring> are not in proper order", codeIndex < reasonIndex);
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class HandlerUtil method throwSOAPFaultException.
boolean throwSOAPFaultException(MessageContext context, String name, String direction) {
Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if ((outbound == Boolean.TRUE && direction.equals(INBOUND)) || (outbound == Boolean.FALSE && direction.equals(OUTBOUND))) {
// not the direction we want
return true;
}
// random info in soap fault
try {
QName faultCode = new QName("uri", "local", "prefix");
String faultString = "fault";
String faultActor = "faultActor";
SOAPFault sf = SOAPFactory.newInstance().createFault(faultString, faultCode);
sf.setFaultActor(faultActor);
Detail detail = sf.addDetail();
Name entryName = SOAPFactory.newInstance().createName("someFaultEntry");
detail.addDetailEntry(entryName);
throw new SOAPFaultException(sf);
} catch (SOAPException e) {
throw new RuntimeException("Couldn't create SOAPFaultException " + e);
}
}
Aggregations