1   /*
2    * $Id: AxisSoapHeadersTestCase.java 10789 2008-02-12 20:04:43Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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.FunctionalTestCase;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  public class AxisSoapHeadersTestCase extends FunctionalTestCase
22  {
23  
24      protected String getConfigResources()
25      {
26          return "axis-soapheader-test.xml";
27      }
28  
29      public void testSoapRequest() throws Exception
30      {
31  
32          MuleClient client = new MuleClient();
33          Map properties = new HashMap();
34          properties.put("http.method", "POST");
35  
36          DefaultMuleMessage soapRequest = null;
37          soapRequest = new DefaultMuleMessage(
38              "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
39                              +
40  
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                              +
43  
44                              "<soapenv:Header>"
45                              + "<Action>storeModuleInformation</Action>"
46                              + // this should be ignored
47                              "<mule:header>"
48                              + "<mule:MULE_REPLYTO>http://localhost:62182/reply</mule:MULE_REPLYTO>"
49                              + "</mule:header>"
50                              + "</soapenv:Header>"
51                              +
52  
53                              "<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>"
54                              + "</soapenv:Envelope>");
55  
56          MuleMessage reply = client.send("http://localhost:62181/services/component", soapRequest, properties);
57  
58          // Put this in so that no spurious exceptions are thrown
59          // TODO research and see why sometimes we get 404 or Connection refused
60          // errors without this line. Note that the test completes even when the
61          // exceptions are thrown.
62          Thread.sleep(2000);
63  
64          assertEquals(
65              reply.getPayloadAsString(),
66              "<?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>");
67      }
68  
69  }