List of usage examples for javax.xml.soap SOAPMessage writeTo
public abstract void writeTo(OutputStream out) throws SOAPException, IOException;
From source file:com.wandrell.example.swss.test.util.factory.SecureSoapMessages.java
/** * Creates a SOAP message with a signature. * <p>//from ww w.jav a2 s .c o m * A valid SOAP message is required, this will be the message to be signed. * * @param pathBase * path to the SOAP message to sign * @param privateKeyAlias * alias for the private key * @param privateKeyPass * password for the private key * @param certificateAlias * alias for the certificate * @param keystore * key store for the signing * @return a singed SOAP message * @throws Exception * if any error occurs during the message creation */ public static final InputStream getSignedStream(final String pathBase, final String privateKeyAlias, final String privateKeyPass, final String certificateAlias, final KeyStore keystore) throws Exception { SOAPMessage msg = SecureSoapMessages.getSignedMessage(pathBase, privateKeyAlias, privateKeyPass, certificateAlias, keystore); ByteArrayOutputStream out = new ByteArrayOutputStream(); msg.writeTo(out); String strMsg = new String(out.toByteArray()); return new ByteArrayInputStream(strMsg.getBytes()); }
From source file:com.bernardomg.example.swss.test.util.factory.SecureSoapMessages.java
/** * Creates a SOAP message with a signature. * <p>/*www. j a v a 2 s. co m*/ * A valid SOAP message is required, this will be the message to be signed. * * @param pathBase * path to the SOAP message to sign * @param privateKeyAlias * alias for the private key * @param privateKeyPass * password for the private key * @param certificateAlias * alias for the certificate * @param keystore * key store for the signing * @return a singed SOAP message * @throws Exception * if any error occurs during the message creation */ public static final InputStream getSignedStream(final String pathBase, final String privateKeyAlias, final String privateKeyPass, final String certificateAlias, final KeyStore keystore) throws Exception { final SOAPMessage msg = SecureSoapMessages.getSignedMessage(pathBase, privateKeyAlias, privateKeyPass, certificateAlias, keystore); final ByteArrayOutputStream out = new ByteArrayOutputStream(); msg.writeTo(out); final String strMsg = new String(out.toByteArray()); return new ByteArrayInputStream(strMsg.getBytes()); }
From source file:com.hiperium.commons.client.soap.AthenticationDispatcherTest.java
/** * //from w w w .j av a 2 s . c om * @return */ public static SOAPMessage createEndSessionSOAPMessage() { SOAPMessage soapMessage = null; try { soapMessage = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); // Add message body parameters SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addChildElement("endSession", "ns2", "https://sei.general.soap.web.hiperium.com/"); // Check the input System.out.println("REQUEST:"); soapMessage.writeTo(System.out); System.out.println(); } catch (SOAPException e) { LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return soapMessage; }
From source file:com.hiperium.commons.client.soap.AthenticationDispatcherTest.java
/** * //from w w w . j av a2s . co m * @return */ public static SOAPMessage createAuthSOAPMessage(UserCredentialDTO dto) { SOAPMessage soapMessage = null; try { soapMessage = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); // Add message body parameters SOAPBody soapBody = soapEnvelope.getBody(); SOAPElement method = soapBody.addChildElement("userAuthentication", "ns2", "https://sei.authentication.soap.web.hiperium.com/"); SOAPElement argument = method.addChildElement("arg0"); argument.addChildElement("email").addTextNode(dto.getEmail()); argument.addChildElement("password").addTextNode(dto.getPassword()); // Check the input System.out.println("REQUEST:"); soapMessage.writeTo(System.out); System.out.println(); } catch (SOAPException e) { LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return soapMessage; }
From source file:com.hiperium.commons.client.soap.AthenticationDispatcherTest.java
/** * //www.jav a 2 s.c o m * @return */ public static SOAPMessage createSelectHomeSOAPMessage(HomeSelectionDTO dto) { SOAPMessage soapMessage = null; try { soapMessage = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); // Add message body parameters SOAPBody soapBody = soapEnvelope.getBody(); SOAPElement method = soapBody.addChildElement("selectHome", "ns2", "https://sei.authentication.soap.web.hiperium.com/"); SOAPElement argument = method.addChildElement("arg0"); argument.addChildElement("homeId").addTextNode(dto.getHomeId().toString()); argument.addChildElement("profileId").addTextNode(dto.getProfileId().toString()); // Check the input System.out.println("REQUEST:"); soapMessage.writeTo(System.out); System.out.println(); } catch (SOAPException e) { LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return soapMessage; }
From source file:org.drools.server.CamelServerApp.java
public String execute(SOAPMessage soapMessage, CamelContext camelContext) throws SOAPException, IOException { Object object = camelContext.createProducerTemplate().requestBody("direct://kservice/soap", soapMessage); OutputStream out = new ByteArrayOutputStream(); SOAPMessage soapResponse = (SOAPMessage) object; soapResponse.writeTo(out); return out.toString(); }
From source file:ebay.dts.client.LoggingHandler.java
private void log(SOAPMessageContext messageContext) { boolean request = ((Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue(); SOAPMessage meg = messageContext.getMessage(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try {//ww w. java 2 s . co m meg.writeTo(out); } catch (Exception e) { } if (request) { logger.trace("SOAP Request message: " + new String(out.toByteArray())); } else { logger.trace("SOAP Response message: " + new String(out.toByteArray())); } }
From source file:be.fedict.eid.dss.ws.LoggingSoapHandler.java
public boolean handleMessage(SOAPMessageContext context) { LOG.debug("handle message"); Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); try {/*from w ww .j a va2s. c o m*/ soapMessage.writeTo(output); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } LOG.debug("SOAP message: " + output.toString()); return true; }
From source file:be.fedict.hsm.ws.impl.LoggingSOAPHandler.java
@Override public boolean handleMessage(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); try {/* w ww.j a v a 2 s . co m*/ soapMessage.writeTo(output); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } LOG.debug("SOAP message: " + output.toString()); return true; }
From source file:be.fedict.hsm.ws.impl.LoggingSOAPHandler.java
@Override public boolean handleFault(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); try {/*from www. j a v a2 s. co m*/ soapMessage.writeTo(output); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } LOG.debug("SOAP fault: " + output.toString()); return true; }