Java Code Examples for javax.xml.ws.soap.SOAPFaultException

The following examples show how to use javax.xml.ws.soap.SOAPFaultException. These examples are extracted from open source projects. 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
@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 Project: cxf   Source File: WSAFromJavaTest.java    License: 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 Project: cxf   Source File: HandlerInvocationTest.java    License: 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
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
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 6
Source Project: cxf   Source File: FragmentPutInsertAfterTest.java    License: 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 7
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
/**
 * //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
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 10
@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 11
@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 12
@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 13
Source Project: cxf   Source File: FragmentPutAddTest.java    License: 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 14
Source Project: cxf   Source File: WebFaultOutInterceptorTestCase.java    License: 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 Project: feign   Source File: SOAPErrorDecoder.java    License: 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 16
Source Project: development   Source File: TriggerDefinitonServiceWSTest.java    License: 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 17
Source Project: development   Source File: BugfixWSTest.java    License: 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 18
Source Project: cxf   Source File: BraveTracingTest.java    License: 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 Project: cxf   Source File: Soap11ClientServerTest.java    License: 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 20
Source Project: cxf   Source File: WSAFromWSDLTest.java    License: 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 21
Source Project: development   Source File: VatServiceWSTest.java    License: 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 22
Source Project: cxf   Source File: HandlerInvocationTest.java    License: 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 23
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 24
Source Project: cxf   Source File: AbstractJAXWSMethodInvoker.java    License: Apache License 2.0 5 votes vote down vote up
protected SOAPFaultException findSoapFaultException(Throwable ex) {
    if (ex instanceof SOAPFaultException) {
        return (SOAPFaultException)ex;
    }
    if (ex.getCause() != null) {
        return findSoapFaultException(ex.getCause());
    }
    return null;
}
 
Example 25
Source Project: cxf   Source File: WebFaultOutInterceptorTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSoapFaultCauseCause() {
    SOAPFaultException cause = new SOAPFaultException(new SOAPFaultStub());
    Exception innerException = new Exception(cause);
    Exception outerException = new Exception(innerException);
    SoapFault soapFault = new SoapFault("message", outerException, CODE);
    Message message = createMessage(soapFault);

    interceptor.handleMessage(message);

    Assert.assertTrue("SoapFault.subCodes are expected to be empty.",
            soapFault.getSubCodes() == null || soapFault.getSubCodes().isEmpty());
    Assert.assertEquals(CODE, soapFault.getFaultCode());
}
 
Example 26
@Test(expected = SOAPFaultException.class)
public void BusinessNameLangTooLongTest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("BusinessNameLangTooLongTest");
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        Name n = new Name();

        n.setValue("BusinessNameLangTooLongTest A Test business");
        //27
        n.setLang(str27);
        be.getName().add(n);
        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 27
@Test(expected = SOAPFaultException.class)
public void ServiceDescTooLongTest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("ServiceDescTooLongTest");
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        Name n = new Name();
        n.setValue("ServiceDescTooLongTest A Test business");
        be.getName().add(n);
        be.setBusinessServices(new BusinessServices());
        BusinessService bs = new BusinessService();
        Description d = new Description();
        d.setValue(str256);
        bs.getDescription().add(d);
        n = new Name();
        n.setValue(str255);
        bs.getName().add(n);
        be.getBusinessServices().getBusinessService().add(bs);

        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 28
@Test(expected = SOAPFaultException.class)
public void CreateKeyGenKeyDescriptionTooLongTest() throws DispositionReportFaultMessage, RemoteException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("CreateKeyGenKeyDescriptionTooLongTest");

        SaveTModel st = new SaveTModel();
        st.setAuthInfo(authInfoJoe);
        TModel tm = new TModel();
        tm.setName(new Name());
        tm.getName().setValue("CreateKeyGenKeyDescriptionTooLongTest Key gen name");
        tm.getName().setLang("en");
        Description d = new Description();
        d.setValue(str256);
        tm.getDescription().add(d);
        tm.setCategoryBag(new CategoryBag());
        KeyedReference kr = new KeyedReference();
        kr.setTModelKey("uddi:uddi.org:categorization:types");
        kr.setKeyName("uddi-org:keyGenerator");
        kr.setKeyValue("keyGenerator");
        tm.getCategoryBag().getKeyedReference().add(kr);
        tm.setTModelKey("uddi:uddi.joepublisher.com:mycustomkey");
        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 29
public static SOAPFaultException newSOAPFaultException(String reasonText, Throwable cause) {
   try {
      SOAPFactory factory = SOAPFactory.newInstance();
      SOAPFault soapFault = factory.createFault();
      soapFault.setFaultString(reasonText);
      SOAPFaultException except = new SOAPFaultException(soapFault);
      except.initCause(cause);
      return except;
   } catch (SOAPException var5) {
      throw new IllegalArgumentException(var5);
   }
}
 
Example 30
Source Project: cxf   Source File: JMSClientServerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected = SOAPFaultException.class)
public void testReplyAndReplyToDestinations() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl");
    factory.setServiceName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService"));
    factory.setEndpointName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort"));
    factory.setAddress("jms://");
    JMSConfigFeature feature = new JMSConfigFeature();
    JMSConfiguration config = new JMSConfiguration();
    config.setConnectionFactory(new ActiveMQConnectionFactory(broker.getBrokerURL()));
    config.setRequestURI("test.jmstransport.text");
    config.setTargetDestination("test.jmstransport.text");
    // replyDestination and replyToDestination intentionally differ in this test scenario
    // replyDestination = Destination name to listen on for reply messages
    config.setReplyDestination("test.jmstransport.text.reply");
    // replyToDestination = Destination name to send out as replyTo address in the message
    config.setReplyToDestination("test.jmstransport.text.replyTo");
    config.setReceiveTimeout(1000L);
    feature.setJmsConfig(config);
    factory.getFeatures().add(feature);
    HelloWorldPortType greeter = factory.create(HelloWorldPortType.class);

    try {
        greeter.greetMe("FooBar");
        // Timeout exception should be thrown
    } finally {
        ((java.io.Closeable)greeter).close();
    }
}