These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SOAPFactory class.
/** * Constructor for JaxWsSoapFaultException. * @param original the original JAX-WS SOAPFaultException to wrap */ public JaxWsSoapFaultException(SOAPFaultException original) { super(original.getMessage(), original); } /** * Return the wrapped JAX-WS SOAPFault. */ public final SOAPFault getFault() { return ((SOAPFaultException) getCause()).getFault(); } @Override public String getFaultCode() { return getFault().getFaultCode(); }
import org.aopalliance.intercept.MethodInvocation; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.remoting.RemoteAccessException; import org.springframework.remoting.RemoteConnectFailureException; import org.springframework.remoting.RemoteLookupFailureException; import org.springframework.remoting.RemoteProxyFailureException; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** * {@link org.aopalliance.intercept.MethodInterceptor} for accessing a * specific port of a JAX-WS service. Compatible with JAX-WS 2.1 and 2.2, * as included in JDK 6 update 4+ and Java 7/8. * * <p>Uses either {@link LocalJaxWsServiceFactory}'s facilities underneath,
Greeter greeter = getGreeter(); try { greeter.sayHi(); fail("Should throw Exception!"); } catch (SOAPFaultException ex) { assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>", ex.getMessage()); StackTraceElement[] element = ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl12", element[0].getClassName()); } } @Test public void testPingMeFault() throws Exception { Greeter greeter = getGreeter(); try { greeter.pingMe(); fail("Should throw Exception!"); } catch (PingMeFault ex) { FaultDetail detail = ex.getFaultInfo(); assertEquals((short)2, detail.getMajor());
Source response = dispatch.invoke(request); } catch (SOAPFaultException ex) { e = ex; } assertNotNull("We should have an exception, but none was thrown.", e); assertEquals("FaultCode should be \"MustUnderstand\"", "MustUnderstand", e.getFault().getFaultCodeAsQName().getLocalPart()); // Invoke a second time to verify bais = new ByteArrayInputStream(bytes); request = new StreamSource(bais); e = null; try { Source response = dispatch.invoke(request); } catch (SOAPFaultException ex) { e = ex; } assertNotNull("We should have an exception, but none was thrown.", e);
assertNotNull(dispatch); dispatch.invoke(soapMessage); fail("Did not get expected SOAPFaultException for not understood MustUnderstand header"); TestLogger.logger.debug("----------------------------------"); } catch (SOAPFaultException e) { TestLogger.logger.debug("Got expected SOAPFault", e); assertTrue(e.toString().indexOf( "Must Understand check failed for header soap : {http://demo/}badHeader") != -1); TestLogger.logger.debug("MustUnderstand failed as exptected"); TestLogger.logger.debug("----------------------------------"); } } /** * Test that a mustUnderstand header with a specific SOAP role that the endpoint is acting in * doesn't cause a NotUnderstood fault if the header QName is one that the handler understands. */ public void testSoapRoleActedIn() { TestLogger.logger.debug("----------------------------------");
addOutOfBoundHeader(putLastTradedPrice, invalid, mu); putLastTradedPrice.sayHi(holder); checkReturnedOOBHeader(putLastTradedPrice); return true; } catch (SOAPFaultException ex) { if (ex.getMessage().contains("MustUnderstand")) { return false; } throw ex; } } }
try { disp.invoke(soapReqMsg); fail("SOAPFaultFxception is expected"); } catch (SOAPFaultException ex) { assertTrue("WSA header exception is expected", ex.getMessage().indexOf("A header representing a Message Addressing") > -1); } } @Test public void testNonAnonSoap12Fault() throws Exception { try { AddNumbersPortType port = getNonAnonPort(); ((BindingProvider)port).getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT2 + "/jaxws/soap12/add"); port.addNumbers(1, 2); fail("expected SOAPFaultException"); } catch (SOAPFaultException e) {
} return continueProcessing; } private SoapFault mapSoapFault(SOAPFaultException sfe) { SoapFault sf = new SoapFault(sfe.getFault().getFaultString(), sfe, sfe.getFault().getFaultCodeAsQName()); sf.setRole(sfe.getFault().getFaultActor()); if (sfe.getFault().hasDetail()) { sf.setDetail(sfe.getFault().getDetail()); } return sf; } /* * When the message direction is reversed, if the message is not already a * fault message then it is replaced with a fault message */
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(); } @POST @Path("/") @WebMethod(action = "urn:switchyard-quickstart:camel-soap-proxy:1.0") @WebResult(name = "text") public String upper(@WebParam(name = "text") String text) { return text.toUpperCase(); } }
private void throwUnsupportedOperation(String string) { try { SOAPFault fault = SAAJFactoryResolver.createSOAPFactory(null).createFault(); fault.setFaultString("Unsupported operation " + string); throw new SOAPFaultException(fault); } catch (SOAPException e) { throw new Fault(e); } } }