List of usage examples for javax.xml.soap SOAPConnectionFactory newInstance
public static SOAPConnectionFactory newInstance() throws SOAPException, UnsupportedOperationException
From source file:org.libreplan.importers.TimSoapClient.java
/** * Creates a SOAP connection to the SOAP server * * @return the SOAPconnection object/*from w w w .j a v a2 s. c o m*/ * @throws SOAPException * if unable to create connection */ private static SOAPConnection createConnection() throws SOAPException { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); return soapConnectionFactory.createConnection(); }
From source file:org.mule.modules.paypal.util.PayPalAPIHelper.java
public static void getPalDetails(@NotNull String url, @NotNull String username, @NotNull String password, @NotNull String appId, String signature) throws Exception { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); // Send SOAP Message to SOAP Server SOAPMessage soapResponse;// w w w. ja va 2 s . c o m try { soapResponse = soapConnection.call(createGetPalDetailsSOAPRequest(username, password, appId, signature), url); } catch (Exception e) { throw new org.mule.api.ConnectionException(ConnectionExceptionCode.UNKNOWN_HOST, "", "PayPal SOAP Endpoint not reachable.", e); } if (soapResponse.getSOAPBody().hasFault()) { Exception e = processException(soapResponse); throw e; } NodeList palList = soapResponse.getSOAPBody().getElementsByTagName("Pal"); if (palList == null || (palList != null && palList.getLength() == 0)) { Exception e = processException(soapResponse); throw e; } String pal = soapResponse.getSOAPBody().getElementsByTagName("Pal").item(0).getTextContent(); if (StringUtils.isEmpty(pal)) { Exception e = processException(soapResponse); throw e; } soapConnection.close(); }
From source file:org.openhie.test.xds.util.SoapMessageSender.java
public static void main(String args[]) throws Exception { SoapMessageSender test = new SoapMessageSender(); // Create SOAP Connection SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); // Send SOAP Message to SOAP Server String url = "http://iol.test.ohie.org:5001/xdsrepository"; SOAPMessage so = test.getSoapMessageFromString(); SOAPHeader header = so.getSOAPHeader(); log.info(soapConnection.call(test.getSoapMessageFromString(), url)); // print SOAP Response System.out.print("Response SOAP Message:"); //soapResponse.writeTo(System.out); soapConnection.close();/*from w w w. j a v a2 s .co m*/ }
From source file:org.overlord.rtgov.tests.platforms.jbossas.activityserver.JBossASActivityServerServiceTest.java
@Test @OperateOnDeployment("orders-app") public void testQueryActivityServer() { try {//w w w. j a v a 2 s . c om SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>1</orderId>" + " <itemId>BUTTER</itemId>" + " <quantity>100</quantity>" + " <customer>Fred</customer>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; long startTime = System.currentTimeMillis(); java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); java.util.List<ActivityType> acts = getActivityEvents(startTime, System.currentTimeMillis()); if (acts == null) { fail("Activity event list is null"); } System.out.println("LIST SIZE=" + acts.size()); System.out.println("LIST=" + acts); if (acts.size() != 12) { fail("Expecting 12 activity events: " + acts.size()); } // RTGOV-256 Check that first activity type has header value extracted as a property ActivityType at = acts.get(0); if (!at.getProperties().containsKey("contentType")) { fail("Property 'contentType' not found"); } if (!at.getProperties().get("contentType") .equals("{urn:switchyard-quickstart-demo:orders:1.0}submitOrder")) { fail("Incorrect content type, expecting '{urn:switchyard-quickstart-demo:orders:1.0}submitOrder' but got: " + at.getProperties().get("contentType")); } if (!at.getProperties().containsKey("gateway")) { fail("Property 'gateway' not found"); } if (!at.getProperties().get("gateway").equals("soap")) { fail("Incorrect gateway, expecting 'soap' but got: " + at.getProperties().get("gateway")); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }
From source file:org.overlord.rtgov.tests.platforms.jbossas.activityserver.JBossASActivityServerServiceTest.java
@Test @OperateOnDeployment("orders-app") public void testQueryActivityServerFaultResponse() { try {/* w w w. ja va2 s. c o m*/ SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); long startTime = System.currentTimeMillis(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>1</orderId>" + " <itemId>Laptop</itemId>" + " <quantity>100</quantity>" + " <customer>Fred</customer>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); java.util.List<ActivityType> acts = getActivityEvents(startTime, System.currentTimeMillis()); if (acts == null) { fail("Activity event list is null"); } System.out.println("LIST SIZE=" + acts.size()); System.out.println("LIST=" + acts); if (acts.size() != 7) { fail("Expecting 7 activity events: " + acts.size()); } ActivityType at1 = acts.get(4); if ((at1 instanceof ResponseSent) == false) { fail("Expecting a 'response sent' event"); } ResponseSent resp = (ResponseSent) at1; if (resp.getMessageType() == null) { fail("Message type should not be null"); } if (resp.getFault() == null) { fail("Fault should not be null"); } if (!resp.getFault().equals("ItemNotFound")) { fail("Fault should be 'ItemNotFound': " + resp.getFault()); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }
From source file:org.overlord.rtgov.tests.platforms.jbossas.activityserver.JBossASActivityServerServiceTest.java
@Test @OperateOnDeployment("orders-app") public void testQueryActivityServerInvalidRequestStructure() { try {// w ww . j a v a 2 s . c o m SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); long startTime = System.currentTimeMillis(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>1</orderId>" + " <itemId>BUTTER</itemId>" + " <quantity>100</quantity>" + " <customerx>Fred</customerx>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); java.util.List<ActivityType> acts = getActivityEvents(startTime, System.currentTimeMillis()); if (acts == null) { fail("Activity event list is null"); } System.out.println("LIST SIZE=" + acts.size()); System.out.println("LIST=" + acts); if (acts.size() != 2) { fail("Expecting 2 activity events: " + acts.size()); } // RTGOV-262 Check response has replyTo id ActivityType at1 = acts.get(0); ActivityType at2 = acts.get(1); if ((at1 instanceof RequestReceived) == false) { fail("Expecting a 'request received' event"); } if ((at2 instanceof ResponseSent) == false) { fail("Expecting a 'response sent' event"); } RequestReceived req = (RequestReceived) at1; ResponseSent resp = (ResponseSent) at2; if (resp.getReplyToId() == null) { fail("Response 'replyTo' id not set"); } if (!req.getMessageId().equals(resp.getReplyToId())) { fail("Response 'replyTo' id not same as request message id"); } if (resp.getMessageType() != null) { fail("Message type of fault response, for validation error, should be null: " + resp.getMessageType()); } if (resp.getFault() == null) { fail("Fault for invalid response should not be null"); } if (!resp.getFault().equals("ERROR")) { fail("Fault for invalid response should be 'ERROR': " + resp.getFault()); } if (resp.getContent() == null) { fail("Fault response should have message content representing a description of the fault"); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }
From source file:org.overlord.rtgov.tests.platforms.jbossas.calltrace.JBossASCallTraceServiceTest.java
@Test @OperateOnDeployment("orders-app") public void testCallTrace() { String id = "ID" + System.currentTimeMillis(); //UUID.randomUUID().toString(); try {/*from w ww . ja v a 2s . c o m*/ SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>" + id + "</orderId>" + " <itemId>BUTTER</itemId>" + " <quantity>100</quantity>" + " <customer>Fred</customer>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); String ct = getCallTrace(id); if (ct == null) { fail("Call trace is null"); } CallTrace trace = CallTraceUtil.deserializeCallTrace(ct.getBytes()); if (trace == null) { fail("Failed to deserialize call trace"); } if (trace.getTasks().size() != 1) { fail("Should only be one top level task: " + trace.getTasks().size()); } if (!(trace.getTasks().get(0) instanceof Call)) { fail("Top level task should be a Call: " + trace.getTasks().get(0)); } Call call = (Call) trace.getTasks().get(0); if (call.getTasks().size() != 2) { fail("Should be 2 child tasks: " + call.getTasks().size()); } // Verify that the top level call had two inner calls if (!(call.getTasks().get(0) instanceof Call)) { fail("Child task 0 should be a Call: " + call.getTasks().get(0)); } if (!(call.getTasks().get(1) instanceof Call)) { fail("Child task 1 should be a Call: " + call.getTasks().get(1)); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }
From source file:org.overlord.rtgov.tests.platforms.jbossas.calltrace.JBossASCallTraceServiceTest.java
@Test @OperateOnDeployment("orders-app") @org.junit.Ignore("RTGOV-459 - using Elasticsearch activity store caused this test to stop working") public void testCallTraceWithException() { String id = "ID" + System.currentTimeMillis(); //UUID.randomUUID().toString(); try {/* w w w.ja v a2s .c om*/ SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>" + id + "</orderId>" + " <itemId>ERROR</itemId>" + " <quantity>100</quantity>" + " <customer>Fred</customer>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); String ct = getCallTrace(id); if (ct == null) { fail("Call trace is null"); } CallTrace trace = CallTraceUtil.deserializeCallTrace(ct.getBytes()); if (trace == null) { fail("Failed to deserialize call trace"); } if (trace.getTasks().size() != 1) { fail("Should only be one top level task: " + trace.getTasks().size()); } if (!(trace.getTasks().get(0) instanceof Call)) { fail("Top level task should be a Call: " + trace.getTasks().get(0)); } Call call = (Call) trace.getTasks().get(0); if (call.getTasks().size() != 1) { fail("Should be 1 child tasks: " + call.getTasks().size()); } // Verify that the top level call had one inner call if (!(call.getTasks().get(0) instanceof Call)) { fail("Child task 0 should be a Call: " + call.getTasks().get(0)); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }
From source file:org.overlord.rtgov.tests.platforms.jbossas.servicedependency.JBossASServiceDependencyServiceTest.java
@Test @OperateOnDeployment("orders-app") public void testServiceDependency() { try {//www .j a va2 s .c o m SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>1</orderId>" + " <itemId>BUTTER</itemId>" + " <quantity>100</quantity>" + " <customer>Fred</customer>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); String so = getServiceOverview(); if (so == null) { fail("Service overview is null"); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }
From source file:org.overlord.rtgov.tests.platforms.jbossas.situationmgr.JBossASSituationManagerServiceTest.java
@Test @OperateOnDeployment("orders-app") public void testFilteredSituations() { try {/*from w w w . j a v a 2 s .c o m*/ SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); java.net.URL url = new java.net.URL(ORDER_SERVICE_URL); String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <soap:Body>" + " <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">" + " <order>" + " <orderId>3</orderId>" + " <itemId>JAM</itemId>" + " <quantity>100</quantity>" + " <customer>Fred</customer>" + " </order>" + " </orders:submitOrder>" + " </soap:Body>" + "</soap:Envelope>"; java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes()); SOAPMessage request = MessageFactory.newInstance().createMessage(null, is); is.close(); SOAPMessage response = con.call(request, url); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); response.writeTo(baos); baos.close(); // Wait for events to propagate Thread.sleep(4000); QuerySpec qsSituations = new QuerySpec(); qsSituations.setCollection(SITUATIONS); QuerySpec qsFilteredSituations = new QuerySpec(); qsFilteredSituations.setCollection(FILTERED_SITUATIONS); java.util.List<?> result0 = performACMQuery(qsSituations); if (result0.size() != 2) { fail("Expecting two situations: " + result0.size()); } java.util.List<?> result1 = performACMQuery(qsFilteredSituations); if (result1.size() != 2) { fail("Expecting two filtered situations: " + result1.size()); } System.out.println("RESULT=" + result1); // Send 'ignore' for filtered subject IgnoreSubject ignore = new IgnoreSubject(); ignore.setSubject(FILTERED_SUBJECT); ignore.setReason("No particular reason"); ignore(ignore); java.util.List<?> result2 = performACMQuery(qsSituations); if (result2.size() != 2) { fail("Still expecting two situations: " + result2.size()); } java.util.List<?> result3 = performACMQuery(qsFilteredSituations); if (result3.size() != 1) { fail("Now expecting just one filtered situations: " + result3.size()); } observe(ignore.getSubject()); java.util.List<?> result4 = performACMQuery(qsSituations); if (result4.size() != 2) { fail("Still again expecting two situations: " + result4.size()); } java.util.List<?> result5 = performACMQuery(qsFilteredSituations); if (result5.size() != 2) { fail("Again expecting two filtered situations: " + result5.size()); } } catch (Exception e) { e.printStackTrace(); fail("Failed to invoke service: " + e); } }