1   /*
2    * $Id: AxisClientWithComplexTypesTestCase.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.test.usecases.axis;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transport.soap.axis.AxisConnector;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  /**
22   * TODO document
23   */
24  public class AxisClientWithComplexTypesTestCase extends FunctionalTestCase
25  {
26      private Trade trade = null;
27      private String uri = "axis:http://localhost:8081/services/BackOfficeImplBindingImplUMO?method=submitTrade";
28  
29      // @Override
30      protected void doSetUp() throws Exception
31      {
32          trade = new Trade();
33          trade.setAccountID(11);
34          trade.setCusip("33");
35          trade.setCurrency(22);
36          trade.setTradeID(22);
37          trade.setTransaction(11);
38  
39      }
40  
41      protected String getConfigResources()
42      {
43          return "org/mule/test/usecases/routing/axis/axis-client-test.xml";
44      }
45  
46      public void testSendComplexDOCLIT() throws Exception
47      {
48  
49          MuleClient client = new MuleClient();
50          Map props = new HashMap();
51          props.put(AxisConnector.STYLE, "Document");
52          props.put(AxisConnector.USE, "Literal");
53  
54          SubmitTrade submittrade = new SubmitTrade();
55          submittrade.setArg0(trade);
56  
57          // We need to name the parameters weh using Doc/Lit
58          // SoapMethod method = new SoapMethod(new QName("submitTrade"),
59          // SubmitTradeResponse.class);
60          // method.addNamedParameter(new NamedParameter(new QName("submitTrade"),
61          // NamedParameter.createQName("Object"), ParameterMode.IN));
62          // props.put(MuleProperties.MULE_SOAP_METHOD, method);
63          MuleMessage result = client.send(uri, submittrade, props);
64          assertNotNull(result);
65          SubmitTradeResponse response = (SubmitTradeResponse)result.getPayload();
66          assertEquals("RECEIVED", response.get_return().getStatus());
67  
68      }
69  
70      public void testSendComplexRPCENC() throws Exception
71      {
72          MuleClient client = new MuleClient();
73  
74          MuleMessage result = client.send(uri, trade, null);
75          assertNotNull(result);
76          TradeStatus status = (TradeStatus)result.getPayload();
77          assertEquals("RECEIVED", status.getStatus());
78      }
79  }