Java Code Examples for javax.xml.ws.soap.SOAPFaultException#getFault()

The following examples show how to use javax.xml.ws.soap.SOAPFaultException#getFault() . 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: 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 2
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 3
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 4
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 5
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 6
Source File: SOAPTest.java    From riptide with MIT License 5 votes vote down vote up
@Test
void shouldSendAndReceiveFault() {
    final CompletableFuture<ClientHttpResponse> future = unit.post()
            .body(new SayHello("Error"))
            .call(soap(SayHelloResponse.class, System.out::println));

    final CompletionException exception = assertThrows(CompletionException.class, future::join);
    final SOAPFaultException cause = (SOAPFaultException) exception.getCause();
    final SOAPFault fault = cause.getFault();

    assertEquals("Error is not supported", fault.getFaultString());
}
 
Example 7
Source File: KgssServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public KeyResult retrieveKeyFromKgss(byte[] keyId, byte[] myEtk, byte[] kgssEtk) throws IntegrationModuleException {
   LOG.debug("KeyIdentifier : " + Arrays.toString(keyId));
   GetKeyRequestContent getKeyRequestContent = new GetKeyRequestContent();
   Key key = null;
   KeyGenerator var6;
   if (myEtk != null) {
      getKeyRequestContent.setETK(myEtk);
   } else {
      try {
         this.keyGen = KeyGenerator.getInstance("AES");
         var6 = this.keyGen;
         synchronized(this.keyGen) {
            key = this.keyGen.generateKey();
         }
      } catch (Exception var11) {
         throw new IntegrationModuleException(I18nHelper.getLabel("error.technical"), var11);
      }

      getKeyRequestContent.setKeyEncryptionKey(key.getEncoded());
   }

   getKeyRequestContent.setKeyIdentifier(Base64.decodeBase64(keyId));
   var6 = null;

   try {
      be.ehealth.technicalconnector.service.kgss.KgssService kgss = ServiceFactory.getKgssService();
      SessionItem sessionItem = Session.getInstance().getSession();
      GetKeyResponseContent getKeyResponseContent = kgss.getKey(getKeyRequestContent, sessionItem.getHolderOfKeyCredential(), sessionItem.getEncryptionCredential(), sessionItem.getSAMLToken().getAssertion(), sessionItem.getEncryptionPrivateKeys(), kgssEtk);
      KeyResult keyResultToReturn = new KeyResult(new SecretKeySpec(getKeyResponseContent.getKey(), "AES"), new String(keyId));
      return keyResultToReturn;
   } catch (SOAPFaultException var12) {
      if (var12.getFault() != null && var12.getFault().getFaultCode() != null && var12.getFault().getFaultCode().contains("InvalidSecurity")) {
         throw new IntegrationModuleException(I18nHelper.getLabel("error.kgss.getKey"), var12);
      } else {
         throw new IntegrationModuleException(I18nHelper.getLabel("error.kgss.getKey.other"), var12);
      }
   } catch (ClientTransportException var13) {
      throw new IntegrationModuleException(I18nHelper.getLabel("error.connection.kgss"), var13);
   } catch (TechnicalConnectorException var14) {
      LOG.error("Error retrieving key", var14);
      throw new IntegrationModuleException(I18nHelper.getLabel("technical.connector.error.retrieve.key"), var14);
   }
}