javax.xml.ws.soap.SOAPFaultException Java Examples

The following examples show how to use javax.xml.ws.soap.SOAPFaultException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UDDI_140_NegativePublicationIntegrationTest.java    From juddi with Apache License 2.0 13 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void ContactMaxAddressFFTFFFFtest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("ContactMaxAddressFFTFFFFtest");
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        Name n = new Name();
        n.setValue("ContactMaxAddressFFTFFFFtest A Test business");
        be.getName().add(n);
        be.setContacts(ContactAddressAllMax(false, false, true, false, false, false, false));
        sb.getBusinessEntity().add(be);
        try {
                BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
                DeleteBusiness db = new DeleteBusiness();
                db.setAuthInfo(authInfoJoe);
                db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
                publicationJoe.deleteBusiness(db);
                Assert.fail("request should have been rejected");

        } catch (SOAPFaultException ex) {
                HandleException(ex);
                throw ex;
        }
}
 
Example #2
Source File: WSAFromJavaTest.java    From cxf with Apache License 2.0 9 votes vote down vote up
@Test
public void testAddNumbersJaxWsContext() throws Exception {
    ByteArrayOutputStream output = setupOutLogging();

    AddNumberImpl port = getPort();

    BindingProvider bp = (BindingProvider)port;
    java.util.Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "cxf");

    try {
        assertEquals(3, port.addNumbers(1, 2));
        fail("Should have thrown an ActionNotSupported exception");
    } catch (SOAPFaultException ex) {
        //expected
    }
    assertLogContains(output.toString(), "//wsa:Action", "cxf");
    assertTrue(output.toString(), output.toString().indexOf("SOAPAction=\"cxf\"") != -1);
}
 
Example #3
Source File: HandlerInvocationTest.java    From cxf with Apache License 2.0 9 votes vote down vote up
@Test
    public void testLogicalHandlerHandleFaultThrowsSOAPFaultExceptionServerOutbound() throws PingException {
        try {
            handlerTest.pingWithArgs("handler1 inbound throw ProtocolException "
                                     + "handler2HandleFaultThrowsSOAPFaultException");
            fail("did not get expected SOAPFaultException");
        } catch (SOAPFaultException e) {
/*            e.printStackTrace();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(baos, true);
            e.printStackTrace(ps);
            assertTrue("Did not get expected exception message", baos.toString()
                .indexOf("handler2 HandleFault throws SOAPFaultException") > -1);
            assertTrue("Did not get expected javax.xml.ws.soap.SOAPFaultException", baos.toString()
                .indexOf("javax.xml.ws.soap.SOAPFaultException") > -1);*/
        }
    }
 
Example #4
Source File: ConnectorExceptionUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 9 votes vote down vote up
public static void processSOAPFault(SOAPFaultException e) throws SoaErrorException {
   if (e.getFault() == null) {
      throw e;
   } else {
      Node detail = ConnectorXmlUtils.getFirstChildElement(e.getFault().getDetail());
      if (detail == null) {
         throw e;
      } else {
         MarshallerHelper helper;
         if ("BusinessError".equals(detail.getLocalName())) {
            helper = new MarshallerHelper(BusinessError.class, BusinessError.class);
            throw new SoaErrorException(e.getFault().getFaultCode() + ": " + e.getFault().getFaultString(), (ErrorType)helper.toObject((Node)detail));
         } else if ("SystemError".equals(detail.getLocalName())) {
            helper = new MarshallerHelper(SystemError.class, SystemError.class);
            throw new SoaErrorException(e.getFault().getFaultCode() + ": " + e.getFault().getFaultString(), (ErrorType)helper.toObject((Node)detail));
         } else {
            throw e;
         }
      }
   }
}
 
Example #5
Source File: FragmentPutInsertAfterTest.java    From cxf with Apache License 2.0 9 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void insertAfterAttrTest() throws XMLStreamException {
    String content = "<a foo=\"1\"/>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);

    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_INSERT_AFTER);
    expression.getContent().add("/a/@foo");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("b");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);

    client.put(request);

    resource.destroy();
}
 
Example #6
Source File: GenericResponse.java    From freehealth-connector with GNU Affero General Public License v3.0 9 votes vote down vote up
public void getSOAPException() throws SOAPException {
   if (this.message != null && this.message.getSOAPBody() != null) {
      SOAPFault fault = this.message.getSOAPBody().getFault();
      if (fault != null) {
         try {
            LOG.error("SOAPFault: " + ConnectorXmlUtils.flatten(ConnectorXmlUtils.toString((Node)fault)));
         } catch (TechnicalConnectorException var3) {
            LOG.debug("Unable to dump SOAPFault. Reason [" + var3.getMessage() + "]", var3);
         }

         throw new SOAPFaultException(fault);
      }
   } else {
      throw new SOAPException("No message SOAPmessage recieved");
   }
}
 
Example #7
Source File: ConnectorExceptionUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 9 votes vote down vote up
public static void processSOAPFault(SOAPFaultException e) throws SoaErrorException {
   if (e.getFault() == null) {
      throw e;
   } else {
      Node detail = ConnectorXmlUtils.getFirstChildElement(e.getFault().getDetail());
      if (detail == null) {
         throw e;
      } else {
         MarshallerHelper helper;
         if ("BusinessError".equals(detail.getLocalName())) {
            helper = new MarshallerHelper(BusinessError.class, BusinessError.class);
            throw new SoaErrorException(e.getFault().getFaultCode() + ": " + e.getFault().getFaultString(), (ErrorType)helper.toObject((Node)detail));
         } else if ("SystemError".equals(detail.getLocalName())) {
            helper = new MarshallerHelper(SystemError.class, SystemError.class);
            throw new SoaErrorException(e.getFault().getFaultCode() + ": " + e.getFault().getFaultString(), (ErrorType)helper.toObject((Node)detail));
         } else {
            throw e;
         }
      }
   }
}
 
Example #8
Source File: UDDI_140_NegativePublicationIntegrationTest.java    From juddi with Apache License 2.0 7 votes vote down vote up
/**
 * //create a tmodel with a key gen defined valid, regular tmodel,
 * //then a business, service, binding template, tmodel instance infos,
 * attach tmodel with some data, success //create a tmodel without a key
 * gen defined- fail
 *
 * @throws DispositionReportFaultMessage
 * @throws RemoteException
 */
@Test(expected = SOAPFaultException.class)
public void CreateTmodelnoKeyGen() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("CreateTmodelnoKeyGen");

        SaveTModel st = new SaveTModel();
        st.setAuthInfo(authInfoJoe);
        TModel tm = new TModel();
        tm.setName(new Name());
        tm.getName().setValue("CreateTmodelnoKeyGen My Cool Company's tmodel");
        tm.getName().setLang("en");

        tm.setTModelKey("uddi:uddi.joepublisher.com:nokeygenerator:customkey");
        st.getTModel().add(tm);
        try {
                @SuppressWarnings("unused")
                TModelDetail saveTModel = publicationJoe.saveTModel(st);
                Assert.fail("request should have been rejected");
        } catch (SOAPFaultException ex) {
                HandleException(ex);
                throw ex;
        }

}
 
Example #9
Source File: TriggerDefinitonServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void deleteTriggerDefinition_NonAdmin() throws Exception {

    VOTriggerDefinition triggerCreate = createVOTriggerDefinition();
    serviceSupplier.createTriggerDefinition(triggerCreate);

    List<VOTriggerDefinition> triggerDefinitions = serviceSupplier
            .getTriggerDefinitions();
    assertNotNull(triggerDefinitions);
    assertEquals(1, triggerDefinitions.size());

    try {
        serviceServiceManager.deleteTriggerDefinition(triggerDefinitions
                .get(0).getKey());
    } catch (SOAPFaultException ex) {
        validateExceptionContent(ex);
    } finally {
        // cleanup
        serviceSupplier.deleteTriggerDefinition(triggerDefinitions.get(0)
                .getKey());
    }
}
 
Example #10
Source File: HandlerInvocationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSOAPHandlerHandleMessageThrowsSOAPFaultExceptionServerInbound() throws PingException {
    try {
        handlerTest.pingWithArgs("soapHandler3 inbound throw SOAPFaultExceptionWDetail");
        fail("did not get expected SOAPFaultException");
    } catch (SOAPFaultException e) {
        assertEquals("HandleMessage throws exception", e.getMessage());
        SOAPFault fault = e.getFault();
        assertNotNull(fault);
        assertEquals(new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"),
                     fault.getFaultCodeAsQName());
        assertEquals("http://gizmos.com/orders", fault.getFaultActor());

        Detail detail = fault.getDetail();
        assertNotNull(detail);

        QName nn = new QName("http://gizmos.com/orders/", "order");
        Element el = DOMUtils.getFirstChildWithName(detail, nn);
        assertNotNull(el);
        el.normalize();
        assertEquals("Quantity element does not have a value", el.getFirstChild().getNodeValue());
        el = DOMUtils.getNextElement(el);
        el.normalize();
        assertEquals("Incomplete address: no zip code", el.getFirstChild().getNodeValue());
    }
}
 
Example #11
Source File: FragmentPutAddTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void addToNonEmptyDocumentTest() throws XMLStreamException {
    String content = "<a/>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);

    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
    expression.getContent().add("/");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("b");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);

    client.put(request);

    resource.destroy();
}
 
Example #12
Source File: VatServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void testSaveDefaultVat_UserUnauthorized() throws Exception {
    VatService defaultVatService = ServiceFactory.getDefault()
            .getVatService();

    VOVatRate defaultVat = new VOVatRate();
    defaultVat.setRate(TEN);

    try {
        defaultVatService.saveDefaultVat(defaultVat);
        fail();
    } catch (SOAPFaultException e) {
        checkAccessException(e);
    }

}
 
Example #13
Source File: WSAFromWSDLTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonAnonToAnon() throws Exception {
    try (AddNumbersPortTypeProxy port = getPort()) {
        port.getRequestContext()
            .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                 "http://localhost:" + PORT + "/jaxws/addAnon");

        AddressingProperties maps = new AddressingProperties();
        EndpointReferenceType ref = new EndpointReferenceType();
        AttributedURIType add = new AttributedURIType();
        add.setValue("http://localhost:" + INVALID_PORT + "/not/a/real/url");
        ref.setAddress(add);
        maps.setReplyTo(ref);
        maps.setFaultTo(ref);

        port.getRequestContext()
            .put("javax.xml.ws.addressing.context", maps);

        try {
            port.addNumbers3(-1, 2);
        } catch (SOAPFaultException e) {
            assertTrue(e.getFault().getFaultCode().contains("OnlyAnonymousAddressSupported"));
        }
    }
}
 
Example #14
Source File: WebFaultOutInterceptorTestCase.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSoapFaultException() {
    // create message that contains Fault that contains exception
    SOAPFaultException soapFaultException = new SOAPFaultException(new SOAPFaultStub());
    SoapFault soapFault = new SoapFault("message", soapFaultException, CODE);
    Message message = createMessage(soapFault);

    interceptor.handleMessage(message);




    Assert.assertNotNull(soapFault.getSubCodes());
    Assert.assertEquals(1, soapFault.getSubCodes().size());
    Assert.assertEquals(SUBCODE, soapFault.getSubCodes().get(0));
    Assert.assertEquals(CODE, soapFault.getFaultCode());
}
 
Example #15
Source File: ConnectorExceptionUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void processSOAPFault(SOAPFaultException e) throws SoaErrorException {
   if (e.getFault() == null) {
      throw e;
   } else {
      Node detail = ConnectorXmlUtils.getFirstChildElement(e.getFault().getDetail());
      if (detail == null) {
         throw e;
      } else {
         MarshallerHelper helper;
         if ("BusinessError".equals(detail.getLocalName())) {
            helper = new MarshallerHelper(BusinessError.class, BusinessError.class);
            throw new SoaErrorException(e.getFault().getFaultCode() + ": " + e.getFault().getFaultString(), (ErrorType)helper.toObject((Node)detail));
         } else if ("SystemError".equals(detail.getLocalName())) {
            helper = new MarshallerHelper(SystemError.class, SystemError.class);
            throw new SoaErrorException(e.getFault().getFaultCode() + ": " + e.getFault().getFaultString(), (ErrorType)helper.toObject((Node)detail));
         } else {
            throw e;
         }
      }
   }
}
 
Example #16
Source File: Soap11ClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNewLineInExceptionMessage() throws Exception {
    Greeter greeter = getGreeter();

    try {
        greeter.greetMe("newline");
        fail("Should throw Exception!");
    } catch (SOAPFaultException ex) {
        assertEquals("greetMeFault Caused by: Get a wrong name <greetMe>", ex.getMessage());
        StackTraceElement[] elements = ex.getCause().getStackTrace();
        assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",
                     elements[0].getClassName());
        assertTrue(ex.getCause().getCause().getMessage().endsWith("Test \n cause."));
    }


}
 
Example #17
Source File: UDDI_140_NegativePublicationIntegrationTest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void ContactTooLongEmailMaxUseTypeTest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("ContactTooLongEmailMaxUseTypeTest");
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        Name n = new Name();
        n.setValue("ContactTooLongEmailMaxUseTypeTest A Test business");
        be.getName().add(n);
        be.setContacts(ContactTooLongEmailMaxUseType());
        sb.getBusinessEntity().add(be);
        try {
                BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
                DeleteBusiness db = new DeleteBusiness();
                db.setAuthInfo(authInfoJoe);
                db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
                publicationJoe.deleteBusiness(db);
                Assert.fail("request should have been rejected");

        } catch (SOAPFaultException ex) {
                HandleException(ex);
                throw ex;
        }
}
 
Example #18
Source File: BraveTracingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault() throws Exception {
    try (Tracing brave = createTracer()) {
        final BookStoreService service = createJaxWsService(new BraveClientFeature(brave));

        try {
            service.removeBooks();
            fail("Expected SOAPFaultException to be raised");
        } catch (final SOAPFaultException ex) {
            /* expected exception */
        }

        assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
        assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("post /bookstore"));
        assertThat(TestSpanReporter.getAllSpans().get(1).name(),
            equalTo("post http://localhost:" + PORT + "/bookstore"));
    }
}
 
Example #19
Source File: SOAPErrorDecoder.java    From feign with Apache License 2.0 6 votes vote down vote up
@Override
public Exception decode(String methodKey, Response response) {
  if (response.body() == null || response.status() == 503)
    return defaultErrorDecoder(methodKey, response);

  SOAPMessage message;
  try {
    message = MessageFactory.newInstance(soapProtocol).createMessage(null,
        response.body().asInputStream());
    if (message.getSOAPBody() != null && message.getSOAPBody().hasFault()) {
      return new SOAPFaultException(message.getSOAPBody().getFault());
    }
  } catch (SOAPException | IOException e) {
    // ignored
  }
  return defaultErrorDecoder(methodKey, response);
}
 
Example #20
Source File: UDDI_140_NegativePublicationIntegrationTest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void ContactPhoneTooLongtest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("ContactPhoneTooLongtest");
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        Name n = new Name();
        n.setValue("ContactPhoneTooLongtest A Test business");
        be.getName().add(n);
        be.setContacts(ContactPhoneTooLong());
        sb.getBusinessEntity().add(be);
        try {
                BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
                DeleteBusiness db = new DeleteBusiness();
                db.setAuthInfo(authInfoJoe);
                db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
                publicationJoe.deleteBusiness(db);
                Assert.fail("request should have been rejected");
        } catch (SOAPFaultException ex) {
                HandleException(ex);
                throw ex;
        }
}
 
Example #21
Source File: BugfixWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug7461() throws Exception {

    ServiceProvisioningService serviceProvisioningSrv = ServiceFactory
            .getDefault().getServiceProvisioningService();

    VOServiceDetails sd = new VOServiceDetails();
    VOImageResource ir = new VOImageResource();
    try {
        serviceProvisioningSrv.updateService(sd, ir);
        fail("Call must not succeed!");
    } catch (Exception e) {
        if (e instanceof SOAPFaultException) {
            assertTrue(e.getMessage().contains("AccessException"));
        }
    }
}
 
Example #22
Source File: UDDI_140_NegativePublicationIntegrationTest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void ContactMaxAddressFFFFFFTtest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("ContactMaxAddressFFFFFFTtest");
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        Name n = new Name();
        n.setValue("ContactMaxAddressFFFFFFTtest A Test business");
        be.getName().add(n);
        be.setContacts(ContactAddressAllMax(false, false, false, false, false, false, true));
        sb.getBusinessEntity().add(be);
        try {
                BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
                DeleteBusiness db = new DeleteBusiness();
                db.setAuthInfo(authInfoJoe);
                db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
                publicationJoe.deleteBusiness(db);
                Assert.fail("request should have been rejected");

        } catch (SOAPFaultException ex) {
                HandleException(ex);
                throw ex;
        }
}
 
Example #23
Source File: ResponseBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private SOAPFaultException createDuplicateHeaderException() {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault();
        fault.setFaultCode(soapVersion.faultCodeServer);
        fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName));
        return new SOAPFaultException(fault);
    } catch(SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #24
Source File: EndpointArgumentsBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private SOAPFaultException createDuplicateHeaderException() {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault();
        fault.setFaultCode(soapVersion.faultCodeClient);
        fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName));
        return new SOAPFaultException(fault);
    } catch(SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #25
Source File: SecurityPolicyTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testFault() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();

    URL busFile = SecurityPolicyTest.class.getResource("https_config_client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);

    QName portQName = new QName(NAMESPACE, "DoubleItFaultPortSignThenEncrypt");
    DoubleItPortType pt = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(pt, PORT);
    ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
                                                  new KeystorePasswordCallback());
    ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
                                                  "alice.properties");
    ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
                                                  "bob.properties");

    // DOM
    try {
        pt.doubleIt(5);
        fail("SOAPFaultException expected!");
    } catch (SOAPFaultException e) {
        assertEquals("Foo", e.getFault().getFaultString());
    } finally {
        ((java.io.Closeable)pt).close();
        bus.shutdown(true);
    }
}
 
Example #26
Source File: DispatchHandlerInvocationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeWithSOAPMessagePayloadMode() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
    assertNotNull(wsdl);

    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    assertNotNull(service);

    Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class, Mode.PAYLOAD);
    setAddress(disp, addNumbersAddress);

    TestHandler handler = new TestHandler();
    TestSOAPHandler soapHandler = new TestSOAPHandler();
    addHandlersProgrammatically(disp, handler, soapHandler);

    InputStream is2 = this.getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage soapReq = factory.createMessage(null, is2);

    try {
        disp.invoke(soapReq);
        fail("Did not get expected exception");
    } catch (SOAPFaultException e) {
        assertTrue("Did not get expected exception message: " + e.getMessage(),  e.getMessage()
                   .indexOf("is not valid in PAYLOAD mode with SOAP/HTTP binding") > -1);
    }
}
 
Example #27
Source File: DeleteTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void deleteDeletedStudent() throws XMLStreamException {
    CreateResponse response = createStudent();
    Resource client = TestUtils.createResourceClient(response.getResourceCreated());
    client.delete(new Delete());
    client.delete(new Delete());
}
 
Example #28
Source File: MUTube.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param notUnderstoodHeaders
 * @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
 *         notUnderstoodHeaders are added in the fault detail.
 */
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault(
            MUST_UNDERSTAND_FAULT_MESSAGE_STRING,
            soapVersion.faultCodeMustUnderstand);
        fault.setFaultString("MustUnderstand headers:" +
            notUnderstoodHeaders + " are not understood");
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #29
Source File: TriggerDefinitonServiceWSTest.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void getTriggerTypes_nonAdmin() throws Exception {
    try {
        // given
        // when
        serviceServiceManager.getTriggerTypes();
    } catch (SOAPFaultException ex) {
        // then
        ex.printStackTrace();
        validateExceptionContent(ex);
    }
}
 
Example #30
Source File: MUTube.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param notUnderstoodHeaders
 * @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
 *         notUnderstoodHeaders are added in the fault detail.
 */
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault(
            MUST_UNDERSTAND_FAULT_MESSAGE_STRING,
            soapVersion.faultCodeMustUnderstand);
        fault.setFaultString("MustUnderstand headers:" +
            notUnderstoodHeaders + " are not understood");
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}