try { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection();
try { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection();
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection();
private static synchronized SOAPConnectionFactory getSOAPConnectionFactory() { if (SOAPUtil.conFactory == null) { try { SOAPUtil.conFactory = SOAPConnectionFactory.newInstance(); } catch (final Exception e) { throw new RuntimeException(e); } } return SOAPUtil.conFactory; }
public EchoClient(String url) throws SOAPException, MalformedURLException { connectionFactory = SOAPConnectionFactory.newInstance(); messageFactory = MessageFactory.newInstance(); this.url = new URL(url); }
@Override public void accept(RadioEvents events) { this.events = events; try { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); soapConnection = soapConnectionFactory.createConnection(); connected = true; events.connected(); } catch (SOAPException e) { logger.warn("accept() failed", e); } }
@Override public void connect(String uri, RadioEvents events) { url = uri; this.events = events; try { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); soapConnection = soapConnectionFactory.createConnection(); connected = true; events.connected(); } catch (SOAPException e) { logger.warn("connect() failed", e); } }
protected SOAPConnection createSOAPConnection() { try { SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = scf.createConnection(); return soapConnection; } catch (UnsupportedOperationException e) { log.error(e); throw new JRRuntimeException(e); } catch (SOAPException e) { log.error(e); throw new JRRuntimeException(e); } }
import javax.xml.soap.*; public String callTestService(String soapRequestXml, String url) throws Exception { // Create SOAP Connection SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); SOAPMessage soapRequest = MessageFactory.newInstance().createMessage(new MimeHeaders(), new ByteArrayInputStream(soapRequestXml.getBytes())); // Send SOAP Message to SOAP Server SOAPMessage soapResponse = soapConnection.call(soapRequest, url); ByteArrayOutputStream soapResponseBaos = new ByteArrayOutputStream(); soapResponse.writeTo(soapResponseBaos); String soapResponseXml = soapResponseBaos.toString(); return soapResponseXml; }
public void sendSoapMessage(String url) throws SOAPException, IOException { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); soapConnection = soapConnectionFactory.createConnection(); try { soapResponse = soapConnection.call(request, url); } catch (Exception e) { logErrorToSystemOut(e); throw new CommandException("The request resulted in an error: " + e.getMessage()); } logResponseToSystemOut(); closeSoapConnection(); storeResponseAsString(); }
public Element send(Element request, URI endpointURL) throws TransportException { if (log.isDebugEnabled()) { String requestMessage = XMLUtils.convertNodeToXMLString(request); log.debug("Request message: %s\n%s" + endpointURL + ":" + requestMessage); } Element response = null; try { SOAPMessage message = this.createSOAPMessage(request); //Make the SAAJ Call now SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); SOAPMessage soapResponse = connection.call(message, endpointURL.toURL()); SOAPBody soapBody = soapResponse.getSOAPBody(); boolean hasFault = soapBody.hasFault(); if (hasFault) { SOAPFault soapFault = soapBody.getFault(); String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString(); throw new RegistryException(faultStr); } response = getFirstChildElement(soapBody); } catch (Exception ex) { log.error("Exception::" + ex.getMessage(), ex); throw new TransportException(ex); } if (log.isDebugEnabled()) { String responseMessage = XMLUtils.convertNodeToXMLString(response); log.debug("Response message: %s" + responseMessage); } return response; }
public HttpResponseBean makeCougarSOAPCall(SOAPMessage message, String serviceName, String version, HttpCallBean httpBean) { try { //Debugging code ByteArrayOutputStream outStream = new ByteArrayOutputStream(); message.writeTo(outStream); SOAPConnectionFactory connectionFactory = SOAPConnectionFactory .newInstance(); SOAPConnection connection = connectionFactory.createConnection(); // this can either be a SOAPException or SOAPMessage HttpResponseBean responseBean = new HttpResponseBean(); Object response; String host = httpBean.getHost(); String port = httpBean.getPort(); String endPoint = "http://" + host + ":" + port + "/" + serviceName + "Service/" + version; try { response = connection.call(message, endPoint); } catch (SOAPException e) { response = e; } finally { connection.close(); } responseBean.setResponseObject(handleResponse(response, responseBean)); return responseBean; } catch (SOAPException | IOException | ParserConfigurationException | TransformerException e) { throw new RuntimeException(SOAP_CALL_TEXT + e, e); } }
public SOAPMessage sendMessage() throws Exception { SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = conFactory.createConnection(); MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage msg = msgFactory.createMessage(); SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-mtom:1.0", "image")); bodyElement.setTextContent(imageData); return connection.call(msg, new URL(SWITCHYARD_WEB_SERVICE)); }
/** * Executes SOAP message * * @param endpointUrl SOAP endpoint * @param message SOAP request * @return SOAP response message * @throws SOAPException in case of a SOAP issue * @throws IOException in case of an IO issue */ public SOAPMessage execute(String endpointUrl, SOAPMessage message) throws SOAPException, IOException { SOAPConnection conn = null; try { conn = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage response = conn.call(message, endpointUrl); SOAPBody body = response.getSOAPBody(); if (body.hasFault()) throw new SOAPException(body.getFault().getFaultString()); return response; } finally { if (conn != null) conn.close(); } }
/** * Forward the SOAP message contained in the specified SOAP message context on * to the specified end-point reference. * * @param ctx Message context to get the message from * @param ref End-point reference to forward to */ protected void forwardMessage(SOAPMessageContext ctx, EndpointReference ref) { try { SOAPConnection soapConn = SOAPConnectionFactory.newInstance().createConnection(); soapConn.call(ctx.getMessage(), new URL(ref.getAddress().toString())); soapConn.close(); SOAPBody responseBody = ctx.getMessage().getSOAPPart().getEnvelope().getBody(); removeAllChildElements(responseBody); } catch (SOAPException e) { throw new JAXRPCException("Failed to forward SOAP message.", e); } catch (MalformedURLException e) { throw new JAXRPCException("Failed to forward SOAP message.", e); } }
/** * Test it! */ public void runTest(Properties properties) { try { Object jibxMessage = createMessage(properties); SOAPMessage soapMessage = createSOAPMessage(jibxMessage); SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage soapResponse = connection.call(soapMessage, getEndpoint(properties)); connection.close(); Object res = getResponseFromSOAPMessage(soapResponse, getResponseClass(jibxMessage)); checkResponseMessage(properties, res); } catch (SOAPException e) { e.printStackTrace(); } } /**
/** * Test it! */ public void runTest(Properties properties) { try { Object jibxMessage = createMessage(properties); SOAPMessage soapMessage = createSOAPMessage(jibxMessage); SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage soapResponse = connection.call(soapMessage, getEndpoint(properties)); connection.close(); Object res = getResponseFromSOAPMessage(soapResponse, getResponseClass(jibxMessage)); checkResponseMessage(properties, res); } catch (SOAPException e) { e.printStackTrace(); } } /**
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection();
public SOAPMessage sendMessage() throws Exception { SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = conFactory.createConnection(); MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); SOAPMessage msg = msgFactory.createMessage(); SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage")); bodyElement.addTextNode("cid:switchyard.png"); // CXF does not set content-type. msg.getMimeHeaders().addHeader("Content-Type", "multipart/related; type=\"text/xml\"; start=\"<root.message@cxf.apache.org>\""); msg.getSOAPPart().setContentId("<root.message@cxf.apache.org>"); AttachmentPart ap = msg.createAttachmentPart(); ap.setDataHandler(new DataHandler(new StreamDataSource())); ap.setContentId("<switchyard.png>"); msg.addAttachmentPart(ap); return connection.call(msg, new URL(SWITCHYARD_WEB_SERVICE)); }
@Test public void testSWA() throws Exception { SOAPFactory soapFac = SOAPFactory.newInstance(); MessageFactory msgFac = MessageFactory.newInstance(); SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance(); SOAPMessage msg = msgFac.createMessage(); QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHiWAttach"); msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi)); AttachmentPart ap1 = msg.createAttachmentPart(); ap1.setContent("Attachment content", "text/plain"); msg.addAttachmentPart(ap1); AttachmentPart ap2 = msg.createAttachmentPart(); ap2.setContent("Attachment content - Part 2", "text/plain"); msg.addAttachmentPart(ap2); msg.saveChanges(); SOAPConnection con = conFac.createConnection(); URL endpoint = new URL("http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1"); SOAPMessage response = con.call(msg, endpoint); QName sayHiResp = new QName("http://apache.org/hello_world_rpclit", "sayHiResponse"); assertNotNull(response.getSOAPBody().getChildElements(sayHiResp)); assertEquals(2, response.countAttachments()); }