javax.xml.ws.handler.soap.SOAPMessageContext Java Examples

The following examples show how to use javax.xml.ws.handler.soap.SOAPMessageContext. 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: JAXWSHandler.java    From cxf with Apache License 2.0 7 votes vote down vote up
protected void logToSystemOut(SOAPMessageContext smc) {
    Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    if (outboundProperty.booleanValue()) {
        out.println("\nOutbound message:");
    } else {
        out.println("\nInbound message:");
    }

    SOAPMessage message = smc.getMessage();
    try {
        message.writeTo(out);
        out.println();
    } catch (Exception e) {
        out.println("Exception in handler: " + e);
    }

    out.println("WSDL_SERVICE = " + smc.get(MessageContext.WSDL_SERVICE));
    out.println("WSDL_INTERFACE = " + smc.get(MessageContext.WSDL_INTERFACE));
    out.println("WSDL_PORT = " + smc.get(MessageContext.WSDL_PORT));
    out.println("WSDL_OPERATION = " + smc.get(MessageContext.WSDL_OPERATION));
}
 
Example #2
Source File: AbstractWsSender.java    From freehealth-connector with GNU Affero General Public License v3.0 7 votes vote down vote up
protected GenericResponse call(GenericRequest genericRequest) throws TechnicalConnectorException {
   SOAPConnection conn = null;
   Handler[] chain = genericRequest.getHandlerchain();

   GenericResponse genericResponse;
   try {
      SOAPMessageContext request = this.createSOAPMessageCtx(genericRequest);
      request.putAll(genericRequest.getRequestMap());
      request.put("javax.xml.ws.handler.message.outbound", true);
      executeHandlers(chain, request);
      conn = scf.createConnection();
      SOAPMessageContext reply = createSOAPMessageCtx(conn.call(request.getMessage(), generateEndpoint(request)));
      reply.putAll(genericRequest.getRequestMap());
      reply.put("javax.xml.ws.handler.message.outbound", false);
      ArrayUtils.reverse(chain);
   executeHandlers(chain, reply);
      genericResponse = new GenericResponse(reply.getMessage(), request.getMessage());
   } catch (Exception var10) {
      throw translate(var10);
   } finally {
      ConnectorIOUtils.closeQuietly((Object)conn);
   }

   return genericResponse;
}
 
Example #3
Source File: LoggingHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
/** {@inheritDoc} */
public boolean handleMessage(SOAPMessageContext c) {

	SOAPMessage msg = c.getMessage();
	try {

		ByteArrayOutputStream out = new ByteArrayOutputStream();			
		msg.writeTo(out);			
		LOG.debug(out.size() + " bytes - " + out.toString());


		if( MessageDumper.getInstance().isDumpEnabled() ){
			final Boolean outboundProperty = (Boolean) c.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
			if (outboundProperty) {
				MessageDumper.getInstance().dump(out, MessageDumper.getOperationName(c), MessageDumper.OUT);
			} else {
				MessageDumper.getInstance().dump(out, MessageDumper.getOperationName(c), MessageDumper.IN);
			}
		}
		out.close();
	} catch (Throwable t) {
		LOG.warn("SOAPException when logging the message: ",t);
	}
	return true;
}
 
Example #4
Source File: SchemaValidatorHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private void validate(SOAPMessageContext context, String mode) {
   try {
      SOAPBody body = context.getMessage().getSOAPBody();
      SOAPFault fault = body.getFault();
      if (fault != null) {
         return;
      }

      Node payloadNode = body.getFirstChild();
      ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles);
   } catch (Exception var6) {
      dumpMessage(context.getMessage(), mode, LOG);
      LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage());
      throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6);
   }

   LOG.info("Message validation done.");
}
 
Example #5
Source File: UserAgentHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   if (context.getMessage() != null) {
      MimeHeaders mimeHeaders = context.getMessage().getMimeHeaders();
      if (mimeHeaders != null) {
         String[] agents = mimeHeaders.getHeader("User-Agent");
         if (ArrayUtils.isNotEmpty(agents)) {
            LOG.info("Removing MIME header [User-Agent] with value [" + StringUtils.join(agents, ",") + "]");
            mimeHeaders.removeHeader("User-Agent");
         }

         String value = this.config.getProperty("be.ehealth.technicalconnector.handler.user-agent.value", "Ehealth Technical") + " (" + applicationProps.getProperty("application.version", "unknown") + ")";
         LOG.debug("Adding MIME header [User-Agent] with value [" + value + "]");
         mimeHeaders.addHeader("User-Agent", value);
      }
   }

   return true;
}
 
Example #6
Source File: UpdateFieldAdapter.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
public void exec(SOAPMessageContext context, ModificationDetail detail)
        throws SOAPException {
    UpdateFieldDetail upd_detail = (UpdateFieldDetail) detail;

    if (!detail.getType().equals(ModificationType.UPDATEFIELD)) {
        return;
    }
    if (detail.getPart().equals(ModificationPart.EXCEPTION)
            || detail.getPart().equals(ModificationPart.METHOD)) {
        return;
    }

    if (detail.getPart().equals(ModificationPart.RETURNVALUE)) {
        updateForResponse(context, upd_detail);
    }

    if (detail.getPart().equals(ModificationPart.PARAMETER)) {
        updateForRequest(context, upd_detail);
    }
}
 
Example #7
Source File: TraceeClientHandler.java    From tracee with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected final void handleOutgoing(final SOAPMessageContext context) {

		final SOAPMessage msg = context.getMessage();
		if (msg != null && !traceeBackend.isEmpty() && traceeBackend.getConfiguration().shouldProcessContext(IncomingResponse)) {

			try {
				final SOAPHeader header = getOrCreateHeader(msg);

				final Map<String, String> filteredContext = traceeBackend.getConfiguration().filterDeniedParams(traceeBackend.copyToMap(), IncomingResponse);
				transportSerialization.renderSoapHeader(filteredContext, header);

				msg.saveChanges();
			} catch (final SOAPException e) {
				logger.warn("TraceeClientHandler : Exception occurred during processing of outbound message.", e);
			}
		}
	}
 
Example #8
Source File: CacheFeederHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   if (distributor.mustCache(this.endpoint)) {
      try {
         CacheInformation cacheInformation = distributor.getCacheInformation(this.endpoint);
         Node body = context.getMessage().getSOAPBody().cloneNode(true);
         Source response = new DOMSource(ConnectorXmlUtils.getFirstChildElement(body));
         CacheHelper.put(this.request, response, cacheInformation);
      } catch (Exception var5) {
         LOG.error("Unable to put request into cache", var5);
      }
   } else {
      LOG.debug("Request for endpoint [{}], not cached", this.endpoint);
   }

   return true;
}
 
Example #9
Source File: LoggingHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleMessage(SOAPMessageContext c) {
   SOAPMessage msg = c.getMessage();

   try {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      msg.writeTo(out);
      LOG.debug(out.size() + " bytes - " + out.toString());
      if (MessageDumper.getInstance().isDumpEnabled()) {
         Boolean outboundProperty = (Boolean)c.get("javax.xml.ws.handler.message.outbound");
         if (outboundProperty.booleanValue()) {
            MessageDumper.getInstance().dump(out, MessageDumper.getOperationName(c), "OUT");
         } else {
            MessageDumper.getInstance().dump(out, MessageDumper.getOperationName(c), "IN");
         }
      }

      out.close();
   } catch (Throwable var5) {
      LOG.warn("SOAPException when logging the message: ", var5);
   }

   return true;
}
 
Example #10
Source File: SchemaValidatorHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private void validate(SOAPMessageContext context, String mode) {
   try {
      SOAPBody body = context.getMessage().getSOAPBody();
      SOAPFault fault = body.getFault();
      if (fault != null) {
         return;
      }

      Node payloadNode = body.getFirstChild();
      ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles);
   } catch (Exception var6) {
      dumpMessage(context.getMessage(), mode, LOG);
      LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage());
      throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6);
   }

   LOG.info("Message validation done.");
}
 
Example #11
Source File: UpdateAdapter.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
public void exec(SOAPMessageContext soapMessageContext,
        ModificationDetail detail) throws SOAPException {
    if (detail instanceof UpdateDetail) {
        UpdateDetail upd_detail = (UpdateDetail) detail;
        if (ModificationPart.PARAMETER.equals(upd_detail.getPart())) {
            renameParameter(soapMessageContext, upd_detail.getOldVariable()
                    .getVariableName(), upd_detail.getVariable()
                    .getVariableName());
        } else if (ModificationPart.METHOD.equals(upd_detail.getPart())) {
            if (upd_detail.isRequest()) {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName(),
                        METHODPREFIX + upd_detail.getNewMethodName());
            } else {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName()
                                + RESPONSESUFFIX,
                        METHODPREFIX + upd_detail.getNewMethodName()
                                + RESPONSESUFFIX);
            }
        }
    }
}
 
Example #12
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 #13
Source File: TestSOAPHandler.java    From cxf with Apache License 2.0 6 votes vote down vote up
public boolean handleFault(SOAPMessageContext ctx) {
    methodCalled("handleFault");
    printHandlerInfo("handleFault", isOutbound(ctx));

    if (isServerSideHandler()) {

        if (!"soapHandler4".equals(getHandlerId())) {
            return true;
        }

        try {
            SOAPMessage msg = ctx.getMessage();
            String fs = msg.getSOAPPart().getEnvelope().getBody().getFault().getFaultString();
            if ("soapHandler4HandleFaultThrowsRunException".equals(fs)) {
                throw new RuntimeException("soapHandler4 HandleFault throws RuntimeException");
            } else if ("soapHandler4HandleFaultThrowsSOAPFaultException".equals(fs)) {
                throw createSOAPFaultException("soapHandler4 HandleFault throws SOAPFaultException");
            }
        } catch (SOAPException e) {
            // do nothing
        }
    }

    return true;
}
 
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: RequestContextHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   try {
      SOAPMessage msg = context.getMessage();
      RequestContext reqContext = RequestContext.getInstance();
      reqContext.clear();
      String endPoint = (String)context.get("javax.xml.ws.service.endpoint.address");
      if (endPoint != null && !endPoint.isEmpty()) {
         reqContext.put("endpoint", endPoint);
      }

      this.addToRequestContext(msg, reqContext, "OUT");
   } catch (SOAPException var5) {
      LOG.error("SOAPException", var5.getMessage(), var5);
   } catch (IOException var6) {
      LOG.error("IOException", var6.getMessage(), var6);
   }

   return true;
}
 
Example #16
Source File: AbstractWsSender.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
protected GenericResponse call(GenericRequest genericRequest) throws TechnicalConnectorException {
   SOAPMessageContext request = this.createSOAPMessageCtx(genericRequest);
   request.putAll(genericRequest.getRequestMap());
   request.put("javax.xml.ws.handler.message.outbound", true);
   Handler<?>[] chain = genericRequest.getHandlerchain();
   SOAPConnection conn = null;
   SOAPMessageContext reply = null;

   try {
      URL endpoint = generateEndpoint(request);
      executeHandlers(chain, request);
      SOAPMessage msgToSend = request.getMessage();
      conn = scf.createConnection();
      reply = createSOAPMessageCtx(conn.call(msgToSend, endpoint));
   } catch (UnsupportedOperationException var13) {
      throw translate(var13);
   } catch (SOAPException var14) {
      throw translate(var14);
   } catch (MalformedURLException var15) {
      throw translate(var15);
   } finally {
      ConnectorIOUtils.closeQuietly((Object)conn);
   }

   reply.put("javax.xml.ws.handler.message.outbound", false);
   executeHandlers(chain, reply);
   return new GenericResponse(reply.getMessage());
}
 
Example #17
Source File: JaxWSHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleFault(SOAPMessageContext context) {

    boolean isOut = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    // inbound
    if (isOut == false) {

        getTargetServer(context);
    }
    return true;
}
 
Example #18
Source File: LoggingHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   SOAPMessage msg = context.getMessage();
   if (msg != null && LOG.isInfoEnabled()) {
      String endPoint = (String)context.get("javax.xml.ws.service.endpoint.address");
      String soapAction = ArrayUtils.toString(msg.getMimeHeaders().getHeader("SOAPAction"));
      LOG.info("Invoking webservice on url: [" + endPoint + "] with SOAPAction(s) " + soapAction);
   }

   if (LOG.isDebugEnabled()) {
      dumpMessage(msg, "OUT", LOG);
   }

   return true;
}
 
Example #19
Source File: JaxWSHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", })
@Override
public boolean handleMessage(SOAPMessageContext context) {

    boolean isOut = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    // outbound
    if (isOut == true) {
        Map<String, List<String>> headers = (Map<String, List<String>>) context
                .get(MessageContext.HTTP_REQUEST_HEADERS);

        List<String> ls = new ArrayList<String>();

        ls.add(MonitorServerUtil.getUAVClientSrc(appid));

        if (headers == null) {
            headers = new HashMap<String, List<String>>();
            context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
        }

        // when service use axis 1.4, SOAPAction header is necessary
        if (!headers.containsKey("SOAPAction")) {
            List<String> soapActionHeader = new ArrayList<String>();
            soapActionHeader.add("\"\"");
            headers.put("SOAPAction", soapActionHeader);
        }

        headers.put("UAV-Client-Src", ls);
        for (String key : this.headerMeta.keySet()) {
            headers.remove(key);
        }
        headers.putAll(this.headerMeta);
    }
    // inbound
    else {

        getTargetServer(context);
    }
    return true;
}
 
Example #20
Source File: SOAPHeaderLoggerHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleMessage(SOAPMessageContext ctx) {
   try {
      SOAPHeader header = ctx.getMessage().getSOAPHeader();
      if (header != null) {
         Iterator it = ctx.getMessage().getSOAPHeader().examineAllHeaderElements();

         while(it.hasNext()) {
            Object obj = it.next();
            if (obj instanceof Element) {
               Element el = (Element)obj;
               String nameValue = "{" + el.getNamespaceURI() + "}" + el.getLocalName();
               if (this.propList.contains(nameValue)) {
                  LOG.info(ConnectorXmlUtils.toString((Source)(new DOMSource(el))));
               }
            } else {
               LOG.error("Unsupported Object with name: [" + obj.getClass().getName() + "]");
            }
         }
      }
   } catch (SOAPException var7) {
      LOG.error("SOAPException: " + var7.getMessage(), var7);
   } catch (TechnicalConnectorException var8) {
      LOG.error("TechnicalConnectorException: " + var8.getMessage(), var8);
   }

   return true;
}
 
Example #21
Source File: HarFileHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   this.setHandler();
   SOAPMessage msg = context.getMessage();

   try {
      String soapenv = this.getEnvelope(msg);
      JsonObject response = new JsonObject();
      response.addProperty("status", 200);
      response.addProperty("statusText", "OK");
      response.addProperty("httpVersion", "HTTP/1.1");
      response.add("headers", this.handleHeaders(msg.getMimeHeaders()));
      response.add("cookies", new JsonArray());
      JsonObject content = new JsonObject();
      content.addProperty("size", soapenv.getBytes().length);
      response.addProperty("headersSize", -1);
      response.addProperty("bodySize", -1);
      response.addProperty("redirectURL", "");
      content.addProperty("mimeType", "text/xml; charset=utf-8");
      if (msg.getMimeHeaders() != null) {
         String[] header = msg.getMimeHeaders().getHeader("Content-Type");
         if (header != null && header.length > 0) {
            content.addProperty("mimeType", header[0]);
         }
      }

      content.addProperty("text", soapenv);
      response.add("content", content);
      this.getEntry().add("response", response);
      this.getEntry().get("timings").getAsJsonObject().addProperty("wait", this.recieved - this.split);
      long end = System.currentTimeMillis();
      this.getEntry().get("timings").getAsJsonObject().addProperty("receive", end - this.recieved);
      this.getEntry().addProperty("time", end - this.start);
      this.saveHar();
   } catch (Exception var8) {
      LOG.error(var8.getMessage(), var8);
   }

   return true;
}
 
Example #22
Source File: SAMLHolderOfKeyHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void addWSSecurity(SOAPMessageContext context) throws TechnicalConnectorException {
   SAMLToken lazyToken = this.token;
   if (lazyToken == null) {
      LOG.debug("[Lazy Loading] Trying to load SAMLToken from session.");
      lazyToken = Session.getInstance().getSession().getSAMLToken();
   }

   this.buildSignature().on(context.getMessage()).withTimeStamp(this.duration).withSAMLToken(lazyToken).sign(new AbstractWsSecurityHandler.SignedParts[]{AbstractWsSecurityHandler.SignedParts.TIMESTAMP});
}
 
Example #23
Source File: TestMustUnderstandHandler.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean handleMessage(SOAPMessageContext ctx) {

        boolean continueProcessing = true;

        try {
            Object b = ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
            boolean outbound = (Boolean)b;
            SOAPMessage msg = ctx.getMessage();
            if (isServerSideHandler()) {
                if (outbound) {
                    QName qname = new QName("http://cxf.apache.org/mu", "MU");
                    SOAPPart soapPart = msg.getSOAPPart();
                    SOAPEnvelope envelope = soapPart.getEnvelope();
                    SOAPHeader header = envelope.getHeader();
                    if (header == null) {
                        header = envelope.addHeader();
                    }


                    SOAPHeaderElement headerElement
                        = header.addHeaderElement(envelope.createName("MU", "ns1", qname.getNamespaceURI()));

                    // QName soapMustUnderstand = new QName("http://schemas.xmlsoap.org/soap/envelope/",
                    // "mustUnderstand");
                    Name name = SOAPFactory.newInstance()
                        .createName("mustUnderstand", "soap", "http://schemas.xmlsoap.org/soap/envelope/");
                    headerElement.addAttribute(name, "1");
                } else {
                    getHandlerInfoList(ctx).add(getHandlerId());
                }
            }
        } catch (SOAPException e) {
            e.printStackTrace();
        }
        return continueProcessing;
    }
 
Example #24
Source File: HandlerInvocationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testMustUnderstandSoapFaultOneWay() {
    TestMustUnderstandHandler<SOAPMessageContext> handler =
        new TestMustUnderstandHandler<>();
    addHandlersToChain((BindingProvider)handlerTest, handler);
    try {
        handlerTest.pingOneWay();
    } catch (Exception e) {
        fail("Catch unexpected exception: soap faule message "
             + "should not be returned for one way operation");
    }

}
 
Example #25
Source File: HubDecryptionHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleMessage(SOAPMessageContext cxt) {
   if (cxt == null) {
      throw new IllegalArgumentException("The message cannot be handled since the SOAPMessageContext doesn't have a valid value");
   } else {
      Boolean outboundProperty = (Boolean)cxt.get("javax.xml.ws.handler.message.outbound");
      if (!outboundProperty) {
         this.handleDecryption(cxt);
      }

      return true;
   }
}
 
Example #26
Source File: ConnectionTimeOutHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   String requestTimeOut = this.getDuration("connector.soaphandler.connection.request.timeout");
   LOG.debug("Setting request timeout on: {} milliseconds.", requestTimeOut);
   context.put("com.sun.xml.internal.ws.request.timeout", requestTimeOut);
   context.put("connector.soaphandler.connection.request.timeout", requestTimeOut);
   String connectTimeOut = this.getDuration("connector.soaphandler.connection.connection.timeout");
   LOG.debug("Setting connect timeout on: {} milliseconds.", connectTimeOut);
   context.put("com.sun.xml.internal.ws.connect.timeout", connectTimeOut);
   context.put("connector.soaphandler.connection.connection.timeout", connectTimeOut);
   return true;
}
 
Example #27
Source File: AbstractWsSecurityHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   try {
      this.getLogger().debug("adding WS-Security header");
      this.addWSSecurity(context);
      context.getMessage().saveChanges();
      return true;
   } catch (Exception var3) {
      throw new ProtocolException(var3);
   }
}
 
Example #28
Source File: SoapFaultHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
public boolean handleMessage(SOAPMessageContext c) {
	
	SOAPMessage msg = c.getMessage();

	try {
		if(getSoapFaultCode(msg) !=null){
			throw new IntegrationModuleEhealthException(I18nHelper.getLabel("error.ehealth.technical", new Object[]{getSoapFaultCode(msg)}));
		}
	} catch (SOAPException e) {
		LOG.error(e.getMessage(), e);
	}
	
	return true;
}
 
Example #29
Source File: SOAPHeaderLoggerHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleMessage(SOAPMessageContext ctx) {
   try {
      SOAPHeader header = ctx.getMessage().getSOAPHeader();
      if (header != null) {
         Iterator it = ctx.getMessage().getSOAPHeader().examineAllHeaderElements();

         while(it.hasNext()) {
            Object obj = it.next();
            if (obj instanceof Element) {
               Element el = (Element)obj;
               String nameValue = "{" + el.getNamespaceURI() + "}" + el.getLocalName();
               if (this.propList.contains(nameValue)) {
                  LOG.info(ConnectorXmlUtils.toString((Source)(new DOMSource(el))));
               }
            } else {
               LOG.error("Unsupported Object with name: [" + obj.getClass().getName() + "]");
            }
         }
      }
   } catch (SOAPException var7) {
      LOG.error("SOAPException: " + var7.getMessage(), var7);
   } catch (TechnicalConnectorException var8) {
      LOG.error("TechnicalConnectorException: " + var8.getMessage(), var8);
   }

   return true;
}
 
Example #30
Source File: AbstractWsSender.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
protected SOAPMessageContext createSOAPMessageCtx(GenericRequest genericRequest) throws TechnicalConnectorException {
   try {
      SOAPMessage soapMessage = mf.createMessage();
      SOAPPart soapPart = soapMessage.getSOAPPart();
      if (genericRequest.isXopEnabled()) {
         soapMessage.getMimeHeaders().addHeader("Content-Type", "application/xop+xml");
         soapPart.addMimeHeader("Content-ID", "<[email protected]>");
         soapPart.addMimeHeader("Content-Transfer-Encoding", "8bit");
      }

      SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
      SOAPBody soapBody = soapEnvelope.getBody();
      soapBody.addDocument(genericRequest.getPayload());
      Map<String, DataHandler> handlers = genericRequest.getDataHandlerMap();

      AttachmentPart part;
      for(Iterator i$ = handlers.entrySet().iterator(); i$.hasNext(); soapMessage.addAttachmentPart(part)) {
         Entry<String, DataHandler> handlerEntry = (Entry)i$.next();
         DataHandler handler = (DataHandler)handlerEntry.getValue();
         part = soapMessage.createAttachmentPart(handler);
         part.setContentType(handler.getContentType());
         if (genericRequest.isXopEnabled()) {
            part.addMimeHeader("Content-Transfer-Encoding", "binary");
            part.setContentId("<" + (String)handlerEntry.getKey() + ">");
         } else {
            part.setContentId((String)handlerEntry.getKey());
         }
      }

      return createSOAPMessageCtx(soapMessage);
   } catch (SOAPException var11) {
      throw translate(var11);
   }
}