1   /*
2    * $Id: AxisNamedParametersTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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.providers.soap.axis;
12  
13  import org.mule.config.MuleProperties;
14  import org.mule.extras.client.MuleClient;
15  import org.mule.providers.soap.NamedParameter;
16  import org.mule.providers.soap.SoapMethod;
17  import org.mule.tck.FunctionalTestCase;
18  import org.mule.umo.UMOMessage;
19  
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  import javax.xml.namespace.QName;
24  import javax.xml.rpc.ParameterMode;
25  
26  public class AxisNamedParametersTestCase extends FunctionalTestCase
27  {
28  
29      protected String getConfigResources()
30      {
31          return "axis-named-param-mule-config.xml";
32      }
33  
34      public void testNamedParameters() throws Exception
35      {
36          MuleClient client = new MuleClient();
37          // The component itself will throw an exception if the parameters in the
38          // request SOAP message are not named
39          UMOMessage result = client.send("vm://mycomponent1", "Hello Named", null);
40          assertEquals("Hello Named", result.getPayload());
41      }
42  
43      public void testNamedParametersViaClient() throws Exception
44      {
45          MuleClient client = new MuleClient();
46          Map props = new HashMap();
47          // create the soap method passing in the method name and return type
48          SoapMethod soapMethod = new SoapMethod(new QName("echo"), NamedParameter.XSD_STRING);
49          // add one or more parameters
50          soapMethod.addNamedParameter(new QName("value"), NamedParameter.XSD_STRING, ParameterMode.IN);
51          // set the soap method as a property and pass the properties
52          // when making the call
53          props.put(MuleProperties.MULE_SOAP_METHOD, soapMethod);
54  
55          UMOMessage result = client.send("axis:http://localhost:62111/mule/mycomponent2?method=echo",
56              "Hello Named", props);
57          assertEquals("Hello Named", result.getPayload());
58      }
59  }