use of javax.xml.soap.SOAPFault in project camel by apache.
the class CxfConsumerPayloadFaultCauseEnabledTest method testInvokingFromCxfClient.
@Test
public void testInvokingFromCxfClient() throws Exception {
this.getCamelContextService();
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
Holder<String> personId = new Holder<String>();
personId.value = "";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
try {
client.getPerson(personId, ssn, name);
fail("SOAPFault expected!");
} catch (Exception e) {
assertTrue(e instanceof SOAPFaultException);
SOAPFault fault = ((SOAPFaultException) e).getFault();
assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
}
}
use of javax.xml.soap.SOAPFault in project quickstarts by jboss-switchyard.
the class ReverseService method reverse.
@POST
@Path("/")
@WebMethod(action = "urn:switchyard-quickstart:camel-soap-proxy:1.0")
@WebResult(name = "text")
public String reverse(@WebParam(name = "text") String text) throws Exception {
if (text.equals("fault")) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault sf = factory.createFault("myfaultstring", new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"));
sf.setFaultActor("myFaultActor");
Detail d = sf.addDetail();
QName entryName = new QName("urn:switchyard-quickstart:camel-soap-proxy:1.0", "order", "PO");
DetailEntry entry = d.addDetailEntry(entryName);
QName name = new QName("urn:switchyard-quickstart:camel-soap-proxy:1.0", "symbol");
SOAPElement symbol = entry.addChildElement(name);
symbol.addTextNode("SUNW");
throw new SOAPFaultException(sf);
}
return new StringBuilder(text).reverse().toString();
}
use of javax.xml.soap.SOAPFault in project OpenAM by OpenRock.
the class SOAPCommunicator method createSOAPFault.
/**
* Forms a SOAP Fault and puts it in the SOAP Message Body.
*
* @param faultCode Fault code.
* @param faultString Fault string.
* @param detail Fault details.
* @return SOAP Fault in the SOAP Message Body or null if unable to generate the message.
*/
public SOAPMessage createSOAPFault(final String faultCode, final String faultString, final String detail) {
try {
SOAPMessage message = messageFactory.createMessage();
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
SOAPFault fault = envelope.getBody().addFault();
fault.setFaultCode(envelope.createName(faultCode, null, SOAPConstants.URI_NS_SOAP_ENVELOPE));
fault.setFaultString(SAML2Utils.bundle.getString(faultString));
if (StringUtils.isNotEmpty(detail)) {
Detail faultDetail = fault.addDetail();
SOAPElement faultDetailEntry = (SOAPElement) faultDetail.addDetailEntry(envelope.createName("Problem"));
faultDetailEntry.addAttribute(envelope.createName("details"), SAML2Utils.bundle.getString(detail));
}
return message;
} catch (SOAPException e) {
debug.error("createSOAPFault:", e);
return null;
}
}
use of javax.xml.soap.SOAPFault in project wildfly by wildfly.
the class PojoEndpoint method helloError.
public String helloError(String input) {
try {
SOAPFault fault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createFault(input, SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
fault.setFaultActor("mr.actor");
fault.addDetail().addChildElement("test");
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException"));
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "OperatorNotFound"));
throw new SOAPFaultException(fault);
} catch (SOAPException ex) {
ex.printStackTrace();
}
return "Failure!";
}
use of javax.xml.soap.SOAPFault in project midpoint by Evolveum.
the class AbstractWebserviceTest method assertSoapFault.
protected void assertSoapFault(SOAPFaultException e, String expectedCode, String expectedMessage) {
SOAPFault fault = e.getFault();
String faultCode = fault.getFaultCode();
display("SOAP fault code: " + faultCode);
assertTrue("Unexpected fault code: " + faultCode, faultCode.endsWith(expectedCode));
String message = e.getMessage();
assertTrue("Unexpected fault message: " + message, message.contains(expectedMessage));
}
Aggregations