1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.soap.axis.functional;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleMessage;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.DynamicPortTestCase;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 public class AxisSoapHeadersTestCase extends DynamicPortTestCase
22 {
23 private static final String EXPECTED_RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><echoResponse soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><echoReturn xsi:type=\"xsd:string\">Test Message</echoReturn></echoResponse></soapenv:Body></soapenv:Envelope>";
24
25 @Override
26 protected String getConfigResources()
27 {
28 return "axis-soapheader-test.xml";
29 }
30
31 public void testSoapRequest() throws Exception
32 {
33
34 MuleClient client = new MuleClient(muleContext);
35 Map<String, Object> properties = new HashMap<String, Object>();
36 properties.put("http.method", "POST");
37
38 DefaultMuleMessage soapRequest = null;
39 soapRequest = new DefaultMuleMessage(
40 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
41 + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:mule=\"http://www.muleumo.org/providers/soap/1.0\">"
42 + "<soapenv:Header>"
43 + "<Action>storeModuleInformation</Action>"
44 +
45 "<mule:header>"
46 + "<mule:MULE_REPLYTO>http://localhost:62182/reply</mule:MULE_REPLYTO>"
47 + "</mule:header>"
48 + "</soapenv:Header>"
49 + "<soapenv:Body><echo soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><value0 xsi:type=\"soapenc:string\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">Test Message</value0></echo></soapenv:Body>"
50 + "</soapenv:Envelope>", muleContext);
51
52 MuleMessage reply = client.send("http://localhost:" + getPorts().get(0) + "/services/component", soapRequest, properties);
53
54
55
56
57
58 Thread.sleep(2000);
59
60 assertEquals(EXPECTED_RESPONSE, reply.getPayloadAsString());
61 }
62
63 @Override
64 protected int getNumPortsToFind()
65 {
66
67 return 2;
68 }
69 }