Example usage for javax.xml.soap SOAPMessage writeTo

List of usage examples for javax.xml.soap SOAPMessage writeTo

Introduction

In this page you can find the example usage for javax.xml.soap SOAPMessage writeTo.

Prototype

public abstract void writeTo(OutputStream out) throws SOAPException, IOException;

Source Link

Document

Writes this SOAPMessage object to the given output stream.

Usage

From source file:org.openhie.test.xds.util.SoapMessageSender.java

private SOAPMessage getSoapMessageFromString() throws SOAPException, IOException {
    MessageFactory factory = MessageFactory.newInstance();

    //MimeHeaders header=new MimeHeaders();
    //header.addHeader("Content-Type","application/xop+xml; application/soap+xml" + "action=urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b" + "boundary=MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616;"+ "Content-Transfer-Encoding=binary" + "Content-ID=\"<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>\"");
    //header.addHeader("action", "urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b");

    SOAPMessage message = MessageFactory.newInstance().createMessage();
    SOAPPart soapPart = message.getSOAPPart();

    MimeHeaders header = message.getMimeHeaders();
    //header.addHeader("Content-Type","application/xop+xml; application/soap+xml" + "action=urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b" + "boundary=MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616;"+ "Content-Transfer-Encoding=binary" + "Content-ID=\"<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>\"");
    //header.addHeader("Content-Type", "multipart/related;start=<rootpart*17f1ec84-85ec-4f1f-9b29-423a6a2e354f@example.jaxws.sun.com>;type=application/xop+xml;boundary=uuid:17f1ec84-85ec-4f1f-9b29-423a6a2e354f\";start-info=\"application/soap+xml\";action=\"urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b");
    header.setHeader("Content-Type", "application/soap+xml;charset=UTF-8");

    SOAPHeader soap = message.getSOAPHeader();
    soapPart.setContent(new StreamSource(new FileInputStream(
            "/Users/snkasthu/SourceCode/cds/openhie-integration-tests/src/test/resources/xds/OHIE-XDS-01-10.xml")));

    System.out.print("Request SOAP Message :");
    message.writeTo(System.out);
    System.out.println();//from   w  w  w . j a v a 2  s .com

    return message;
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.activityserver.JBossASActivityServerServiceTest.java

@Test
@OperateOnDeployment("orders-app")
public void testQueryActivityServer() {

    try {/*  w ww.  ja va2 s  .com*/
        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 {/*from w  w w.  j  a va  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>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. ja  va2s . co  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 {//w  w w .j a  va 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>" + 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 {/*from www.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>" + 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 {/*from   www  . j a va 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>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 {/* www . j a  va 2 s .  com*/
        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);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@SuppressWarnings("unchecked")
@Test/*from   w  ww  .ja va 2  s.co  m*/
@OperateOnDeployment("orders-app")
public void testViolationsFromACMgr() {

    try {
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String orderId = "PO-19838-XYZ";

        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>" + orderId + "</orderId>"
                + "                <itemId>JAM</itemId>" + "                <quantity>200</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();

        QuerySpec qs1 = new QuerySpec();
        qs1.setCollection(SITUATIONS);

        java.util.List<?> result0 = performACMQuery(qs1);

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> result1 = performACMQuery(qs1);

        System.out.println("RETRIEVED RESULTS 1=" + result1);

        if (result1 == null) {
            fail("Result 1 is null");
        }

        if (result1.size() - result0.size() != 2) {
            fail("2 event expected, but got: " + -result1.size() + " - " + -result0.size() + " = "
                    + (result1.size() - result0.size()));
        }

        java.util.Map<String, ?> results1 = (java.util.Map<String, ?>) result1.get(result1.size() - 1);
        java.util.Map<String, ?> results2 = (java.util.Map<String, ?>) result1.get(result1.size() - 2);

        System.out.println("RESULT1 KEYS=" + results1.keySet() + " SUBJECT=" + results1.get("subject"));
        System.out.println("RESULT2 KEYS=" + results2.keySet() + " SUBJECT=" + results2.get("subject"));

        // Check that conversation id is in the context
        java.util.List<?> contextList = null;

        if (((String) results1.get("subject")).endsWith("OrderService")) {
            contextList = (java.util.List<?>) results1.get("context");
        } else {
            contextList = (java.util.List<?>) results2.get("context");
        }

        if (contextList.size() != 3) {
            fail("Expecting 3 entries in context list: " + contextList.size());
        }

        boolean f_found = false;

        for (int i = 0; i < contextList.size(); i++) {
            java.util.Map<String, String> contextEntry = (java.util.Map<String, String>) contextList.get(i);

            if (contextEntry.containsKey("type") && contextEntry.get("type").equalsIgnoreCase("conversation")) {

                if (!contextEntry.containsKey("value")) {
                    fail("'value' property not found in context entry");
                }

                if (!contextEntry.get("value").equals(orderId)) {
                    fail("Value should be order id '" + orderId + "': " + contextEntry.get("value"));
                }

                f_found = true;
            }
        }

        if (!f_found) {
            fail("Conversation context not found");
        }

        // Check that the customer properties has been included
        java.util.Map<String, String> properties = null;

        if (((String) results1.get("subject")).endsWith("OrderService")) {
            properties = (java.util.Map<String, String>) results1.get("properties");
        } else {
            properties = (java.util.Map<String, String>) results2.get("properties");
        }

        System.err.println("PROPS=" + properties);

        // 13 properties, including the 'header' properties
        if (properties.size() != 13) {
            fail("Expecting 13 entries in property list: " + properties.size());
        }

        if (!properties.containsKey("customer")) {
            fail("Properties did not contain customer");
        }

        if (!properties.get("customer").equals("Fred")) {
            fail("Customer property not Fred: " + properties.get("customer"));
        }

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
public void testViolationsFromSLAMonitor() {

    try {// w  w  w .  ja  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>PO-19838-XYZ</orderId>"
                + "                <itemId>JAM</itemId>" + "                <quantity>200</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();

        java.util.List<?> violationsBefore = getViolations();

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> violations = getViolations();

        if (violations == null) {
            fail("No violations returned");
        }

        System.out.println("VIOLATIONS=" + violations);

        if (violations.size() - violationsBefore.size() != 2) {
            fail("2 violation expected, but got: " + violations.size() + " - " + violationsBefore.size() + " = "
                    + (violations.size() - violationsBefore.size()));
        }

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}