javax.xml.soap.SOAPException Java Examples

The following examples show how to use javax.xml.soap.SOAPException. 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: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void groupProcessing(
	Value value,
	XSElementDecl xsDecl,
	SOAPElement element,
	SOAPEnvelope envelope,
	boolean first,
	XSModelGroup modelGroup,
	XSSchemaSet sSet,
	String messageNamespace )
	throws SOAPException {

	XSParticle[] children = modelGroup.getChildren();
	XSTerm currTerm;
	for( XSParticle child : children ) {
		currTerm = child.getTerm();
		if( currTerm.isModelGroup() ) {
			groupProcessing( value, xsDecl, element, envelope, first, currTerm.asModelGroup(), sSet,
				messageNamespace );
		} else {
			termProcessing( value, element, envelope, first, currTerm, child.getMaxOccurs(), sSet,
				messageNamespace );
		}
	}
}
 
Example #2
Source File: SoapFaultHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{
  	SOAPPart part = msg.getSOAPPart();
if(part !=null){
	SOAPEnvelope soapEnvelope = part.getEnvelope();
	if(soapEnvelope !=null){
	SOAPBody body = soapEnvelope.getBody();
		if(body !=null){
			SOAPFault fault=body.getFault();
			if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){
				return fault.getFaultString();
			}
		}
	}
}
return null;
  }
 
Example #3
Source File: LoggingHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private void getMessageID(SOAPMessage msg) throws SOAPException {
   SOAPHeader header = msg.getSOAPHeader();
   if (header != null && header.getChildElements().hasNext()) {
      Node elementsResponseHeader = (Node)header.getChildElements().next();
      NodeList elementsheader = elementsResponseHeader.getChildNodes();

      for(int i = 0; i < elementsheader.getLength(); ++i) {
         org.w3c.dom.Node element = elementsheader.item(i);
         if (element.getLocalName() != null && element.getLocalName().equals("MessageID")) {
            LOG.info("The message id of the response: " + element.getNodeValue());
            break;
         }
      }
   }

}
 
Example #4
Source File: OutboundReferenceParameterHeader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void writeTo(SOAPMessage saaj) throws SOAPException {
    //TODO: SAAJ returns null instead of throwing SOAPException,
    // when there is no SOAPHeader in the message,
    // which leads to NPE.
    try {
        SOAPHeader header = saaj.getSOAPHeader();
        if (header == null) {
            header = saaj.getSOAPPart().getEnvelope().addHeader();
        }
        Element node = (Element)infoset.writeTo(header);
        node.setAttributeNS(AddressingVersion.W3C.nsUri,AddressingVersion.W3C.getPrefix()+":"+IS_REFERENCE_PARAMETER,TRUE_VALUE);
    } catch (XMLStreamBufferException e) {
        throw new SOAPException(e);
    }
}
 
Example #5
Source File: STSServiceWsTrustImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public Element getToken(Credential headerCredentials, Credential bodyCredentials, List<SAMLAttribute> attributes, List<SAMLAttributeDesignator> designators, String authenticationMethod, String nameQualifier, String value, String subjectConfirmationMethod, int validity) throws TechnicalConnectorException {
   try {
      Element issuePayload = null;
      if ("urn:oasis:names:tc:SAML:1.0:cm:holder-of-key".equals(subjectConfirmationMethod)) {
         issuePayload = this.issueHokToken(bodyCredentials, attributes, designators, validity);
      } else {
         if (!"urn:oasis:names:tc:SAML:1.0:cm:sender-vouches".equals(subjectConfirmationMethod)) {
            throw new UnsupportedOperationException("SubjectConfirmationMethod [" + subjectConfirmationMethod + "] not supported.");
         }

         SAMLNameIdentifier nameId = this.generateNameIdentifier(bodyCredentials, nameQualifier, value);
         issuePayload = this.issueSVToken(nameId, authenticationMethod, attributes, designators, validity);
      }

      return this.processRequest(headerCredentials, bodyCredentials, issuePayload);
   } catch (SOAPException var12) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var12, new Object[]{var12.getMessage()});
   } catch (DOMException var13) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var13, new Object[]{var13.getMessage()});
   }
}
 
Example #6
Source File: GenericWsSenderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public Node sendUnsecured(String url, Document payload, String soapAction) throws TechnicalConnectorException {
   GenericRequest request = new GenericRequest();
   request.setPayload(payload);
   if (soapAction != null && soapAction.isEmpty()) {
      request.setSoapAction(soapAction);
   }

   request.setEndpoint(url);
   request.setDefaultHandlerChain();
   request.setHandlerChain((new HandlerChain()).register(HandlerPosition.SECURITY, new SoapActionHandler()));

   try {
      return this.send(request).asNode();
   } catch (SOAPException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var6, new Object[]{var6.getMessage()});
   }
}
 
Example #7
Source File: SAAJMetaFactoryImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
 
Example #8
Source File: InitialDevices.java    From onvif-java-lib with Apache License 2.0 6 votes vote down vote up
public Profile createProfile(String name) {
	CreateProfile request = new CreateProfile();
	CreateProfileResponse response = new CreateProfileResponse();

	request.setName(name);

	try {
		response = (CreateProfileResponse) soap.createSOAPMediaRequest(request, response, true);
	}
	catch (SOAPException | ConnectException e) {
		e.printStackTrace();
		return null;
	}

	if (response == null) {
		return null;
	}

	return response.getProfile();
}
 
Example #9
Source File: GenericServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public String sendXML(String payload, String endpoint, String soapAction) throws TechnicalConnectorException, SessionManagementException {
   GenericWsSender sender = ServiceFactory.getGenericWsSender();
   if (this.sessionValidator.validateSession()) {
      GenericRequest request = new GenericRequest();
      request.setEndpoint(endpoint);
      request.setSoapAction(soapAction);
      request.setCredentialFromSession(TokenType.SAML);
      request.setPayload(payload);

      try {
         return sender.send(request).asString();
      } catch (SOAPException var7) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
      }
   } else {
      return null;
   }
}
 
Example #10
Source File: GenInsServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public GetInsurabilityResponse getInsurability(SAMLToken token, GetInsurabilityAsXmlOrFlatRequestType requestType) throws GenInsBusinessConnectorException, TechnicalConnectorException, SessionManagementException {
   GetInsurabilityResponse response = null;
   GetInsurabilityRequest request = new GetInsurabilityRequest();
   this.dozer(requestType, request);

   try {
      GenericRequest service = ServiceFactory.getGeninsPort(token);
      service.setPayload((Object)request);
      GenericResponse xmlResponse = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(service);
      response = (GetInsurabilityResponse)xmlResponse.asObject(GetInsurabilityResponse.class);
      return response;
   } catch (MalformedURLException var7) {
      LOG.error("GeninsServiceImpl : " + var7.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.MALFORMED_URL, var7, new Object[]{"genins " + var7.getMessage()});
   } catch (SOAPException var8) {
      LOG.error("GeninsServiceImpl : " + var8.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #11
Source File: WsAddressingHandlerV200508.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   Boolean wsAddressingUse = context.get("be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508.use") == null ? Boolean.FALSE : (Boolean)context.get("be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508.use");
   if (wsAddressingUse.booleanValue()) {
      try {
         WsAddressingHeader header = (WsAddressingHeader)context.get("be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508");
         if (header == null) {
            LOG.warn("No WsAddressingHeader in the requestMap. Skipping the WsAddressingHandler.");
            return true;
         }

         SOAPHeader soapHeader = getSOAPHeader(context);
         this.processRequiredElements(header, soapHeader);
         this.processOptionalElements(header, soapHeader);
         context.getMessage().saveChanges();
      } catch (SOAPException var5) {
         LOG.error("Error while generating WS-Addressing header", var5);
      }
   } else {
      LOG.warn("WsAddressingHandler is configured but be.ehealth.technicalconnector.handler.WsAddressingHandlerV200508.useproperty was not present or set to FALSE.");
   }

   return true;
}
 
Example #12
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public PutPatientResponse putPatient(SAMLToken token, PutPatientRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:PutPatient");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (PutPatientResponse)genResp.asObject(PutPatientResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw ServiceHelper.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example #13
Source File: SOAP11Fault.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #14
Source File: SoapActionHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   try {
      boolean hasSoapAction = false;
      if (context.containsKey("javax.xml.ws.soap.http.soapaction.use")) {
         hasSoapAction = (Boolean)context.get("javax.xml.ws.soap.http.soapaction.use");
      }

      if (hasSoapAction) {
         String soapAction = (String)context.get("javax.xml.ws.soap.http.soapaction.uri");
         LOG.debug("Adding SOAPAction to mimeheader");
         SOAPMessage msg = context.getMessage();
         String[] headers = msg.getMimeHeaders().getHeader("SOAPAction");
         if (headers != null) {
            LOG.warn("Removing SOAPAction with values: " + ArrayUtils.toString(headers));
            msg.getMimeHeaders().removeHeader("SOAPAction");
         }

         msg.getMimeHeaders().addHeader("SOAPAction", soapAction);
         msg.saveChanges();
      }

      return true;
   } catch (SOAPException var6) {
      throw SOAPFaultFactory.newSOAPFaultException("WSSecurity problem: [SOAPACTION]" + var6.getMessage(), var6);
   }
}
 
Example #15
Source File: StaxLazySourceBridge.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public StaxLazySourceBridge(LazyEnvelopeSource src, SOAPPartImpl soapPart) throws SOAPException {
    super(soapPart);
    lazySource = src;
    final String soapEnvNS = soapPart.getSOAPNamespace();
    try {
        breakpoint = new XMLStreamReaderToXMLStreamWriter.Breakpoint(src.readToBodyStarTag(), saajWriter) {
            @Override
            public boolean proceedAfterStartElement()  {
                if ("Body".equals(reader.getLocalName()) && soapEnvNS.equals(reader.getNamespaceURI()) ){
                    return false;
                } else
                    return true;
            }
        };
    } catch (XMLStreamException e) {
        throw new SOAPException(e);
    }
}
 
Example #16
Source File: GenericWsSenderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public String sendSamlSecured(String url, String payload, Element assertion, Credential credential, String soapAction) throws TechnicalConnectorException {
   GenericRequest request = new GenericRequest();
   request.setPayload(payload);
   request.setEndpoint(url);
   if (soapAction != null && soapAction.isEmpty()) {
      request.setSoapAction(soapAction);
   }

   request.setEndpoint(url);
   request.setDefaultHandlerChain();
   request.setHandlerChain((new HandlerChain()).register(HandlerPosition.SECURITY, new SoapActionHandler()));
   request.setSamlSecured(assertion, credential);

   try {
      return this.send(request).asString();
   } catch (SOAPException var8) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var8, new Object[]{var8.getMessage()});
   }
}
 
Example #17
Source File: HubDecryptionHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private void handleDecryption(SOAPMessageContext cxt) {
   try {
      SOAPMessage soapMessage = cxt.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();
      if (soapBody == null) {
         SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
         soapBody = soapEnvelope.getBody();
      }

      FolderDecryptor.decryptFolder(soapBody, this.crypto);
      soapMessage.saveChanges();
   } catch (SOAPException var5) {
      LOG.error("SOAPException when handling the SOAP Body", var5);
      throw new RuntimeException(var5);
   } catch (UnsealConnectorException var6) {
      LOG.error("UnsealConnectorException when handling the SOAP Message: " + var6.getMessage());
      throw new FolderDecryptionRuntimeException(var6.getMessage(), var6);
   } catch (TechnicalConnectorException var7) {
      LOG.error("TechnicalConnectorException when handling the SOAP Message: " + var7.getMessage());
      throw new RuntimeException(var7);
   }
}
 
Example #18
Source File: SOAPPart1_1Impl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #19
Source File: SAAJMetaFactoryImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}
 
Example #20
Source File: SOAP11Fault.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #21
Source File: StreamHeader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void writeTo(SOAPMessage saaj) throws SOAPException {
    try {
        // TODO what about in-scope namespaces
        // Not very efficient consider implementing a stream buffer
        // processor that produces a DOM node from the buffer.
        TransformerFactory tf = XmlUtil.newTransformerFactory();
        Transformer t = tf.newTransformer();
        XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
        DOMResult result = new DOMResult();
        t.transform(source, result);
        Node d = result.getNode();
        if(d.getNodeType() == Node.DOCUMENT_NODE)
            d = d.getFirstChild();
        SOAPHeader header = saaj.getSOAPHeader();
        if(header == null)
            header = saaj.getSOAPPart().getEnvelope().addHeader();
        Node node = header.getOwnerDocument().importNode(d, true);
        header.appendChild(node);
    } catch (Exception e) {
        throw new SOAPException(e);
    }
}
 
Example #22
Source File: AbstractConsultationServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
protected B obtainTimestamp(X509Certificate certificate, PrivateKey privateKey, A consultRequest) throws TechnicalConnectorException {
   if (certificate != null && privateKey != null) {
      GenericRequest request = ServiceFactory.getTSConsultService(certificate, privateKey);
      request.setPayload(consultRequest);

      try {
         return be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(request).asObject(this.clazzB);
      } catch (SOAPException var6) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, new Object[]{var6.getMessage(), var6});
      }
   } else {
      TechnicalConnectorExceptionValues errorValue = TechnicalConnectorExceptionValues.SECURITY_NO_CERTIFICATE;
      LOG.debug("\t## " + errorValue.getMessage());
      throw new TechnicalConnectorException(errorValue, (Throwable)null, new Object[0]);
   }
}
 
Example #23
Source File: SaajStaxWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Flushes state of this element to the {@code target} element.
 *
 * <p>
 * If this element is initialized then it is added with all the namespace declarations and attributes
 * to the {@code target} element as a child. The state of this element is reset to uninitialized.
 * The newly added element object is returned.
 * </p>
 * <p>
 * If this element is not initialized then the {@code target} is returned immediately, nothing else is done.
 * </p>
 *
 * @param target target element
 * @return {@code target} or new element
 * @throws XMLStreamException on error
 */
public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException {
    try {
        if (this.localName != null) {
            // add the element appropriately (based on namespace declaration)
            final SOAPElement newElement;
            if (this.namespaceUri == null) {
                // add element with inherited scope
                newElement = target.addChildElement(this.localName);
            } else if (prefix == null) {
                newElement = target.addChildElement(new QName(this.namespaceUri, this.localName));
            } else {
                newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri);
            }
            // add namespace declarations
            for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
                newElement.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
            }
            // add attribute declarations
            for (AttributeDeclaration attribute : this.attributeDeclarations) {
                addAttibuteToElement(newElement,
                        attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value);
            }
            // reset state
            this.reset();

            return newElement;
        } else {
            return target;
        }
        // else after reset state -> not initialized
    } catch (SOAPException e) {
        throw new XMLStreamException(e);
    }
}
 
Example #24
Source File: EhealthServiceHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static <T extends ResponseType> T callEhealthServiceV1(SAMLToken token, GenericRequest service, Object request, Class<T> clazz, EhealthReplyValidator ehealthReplyValidator) throws TechnicalConnectorException {
   try {
      service.setPayload(request);
      T response = ServiceFactory.getGenericWsSender().send(service).asObject(clazz);
      ehealthReplyValidator.validateReplyStatus(response);
      return response;
   } catch (SOAPException ex) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, ex, ex.getMessage());
   }
}
 
Example #25
Source File: Packet.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPMessage getAsSOAPMessage() throws SOAPException {
    Message msg = this.getMessage();
    if (msg == null)
        return null;
    if (msg instanceof MessageWritable)
        ((MessageWritable) msg).setMTOMConfiguration(mtomFeature);
    return msg.readAsSOAPMessage(this, this.getState().isInbound());
}
 
Example #26
Source File: KgssServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public GetNewKeyResponseContent getNewKey(GetNewKeyRequestContent request, Credential encryption, Map<String, PrivateKey> decryptionKeys, byte[] etkKGSS) throws TechnicalConnectorException {
   KgssMessageBuilder builder = new KgssMessageBuilderImpl(etkKGSS, encryption, decryptionKeys);
   GetNewKeyRequest sealedRequest = builder.sealGetNewKeyRequest(request);
   GenericRequest genericRequest = ServiceFactory.getKGSSService();
   genericRequest.setPayload((Object)sealedRequest);

   try {
      GetNewKeyResponse response = (GetNewKeyResponse)be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genericRequest).asObject(GetNewKeyResponse.class);
      checkReplyStatus(response.getStatus().getCode());
      this.checkErrorMessages(response.getErrors());
      return builder.unsealGetNewKeyResponse(response);
   } catch (SOAPException var9) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, new Object[]{var9.getMessage(), var9});
   }
}
 
Example #27
Source File: SAAJFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads the message within the Packet to a SAAJMessage.  After this call message is consumed.
 * @param packet Packet
 * @return Created SAAJPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SAAJMessage read(Packet packet) throws SOAPException {
    // Use the Component from the Packet if it exists.  Note the logic
    // in the ServiceFinder is such that find(Class) is not equivalent
    // to find (Class, null), so the ternary operator is needed.
    ServiceFinder<SAAJFactory> factories = (packet.component != null ?
            ServiceFinder.find(SAAJFactory.class, packet.component) :
            ServiceFinder.find(SAAJFactory.class));
    for (SAAJFactory s : factories) {
        SAAJMessage msg = s.readAsSAAJ(packet);
        if (msg != null) return msg;
    }
    return instance.readAsSAAJ(packet);
}
 
Example #28
Source File: TarificationSessionServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TarificationConsultationResponse consultTarification(TarificationConsultationRequest request) throws TechnicalConnectorException {
   try {
      this.sessionValidator.validateSession();
      GenericRequest service = ServiceFactory.getTarificationService(Session.getInstance().getSession().getSAMLToken());
      service.setPayload((Object)request);
      GenericResponse xmlResponse = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(service);
      TarificationConsultationResponse response = (TarificationConsultationResponse)xmlResponse.asObject(TarificationConsultationResponse.class);
      return response;
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   }
}
 
Example #29
Source File: SoapServlet.java    From mdw with Apache License 2.0 5 votes vote down vote up
/**
 * Allow version specific factory passed in TODO: allow specifying response
 * headers
 */
protected String createSoapResponse(String soapVersion, String xml) throws SOAPException {
    try {
        SOAPMessage soapMessage = getSoapMessageFactory(soapVersion).createMessage();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        soapBody.addDocument(DomHelper.toDomDocument(xml));
        return DomHelper.toXml(soapMessage.getSOAPPart().getDocumentElement());
    }
    catch (Exception ex) {
        throw new SOAPException(ex.getMessage(), ex);
    }
}
 
Example #30
Source File: FaultElement1_2Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}