1   /*
2    * $Id: MuleClientWsdlSoapExternalTestCase.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.integration.client;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.AbstractMuleTestCase;
17  import org.mule.util.ExceptionUtils;
18  import org.mule.util.StringUtils;
19  
20  public class MuleClientWsdlSoapExternalTestCase extends AbstractMuleTestCase
21  {
22      public static final String WSDL_URL = "http://www.dataaccess.com/webservicesserver/conversions.wso?WSDL";
23      public static final String METHOD = "NumberToWords";
24      public static final String INPUT = "24";
25      public static final String OUTPUT = "twenty four";
26  
27      public void testXFireWsdlRequestResponse() throws Throwable
28      {
29          if (isOffline("org.mule.test.integration.client.MuleClientXFireExternalTestCase.testRequestResponse()"))
30          {
31              return;
32          }
33  
34          String url = "wsdl-xfire:" + WSDL_URL + "&method=" + METHOD;
35          MuleMessage result = null;
36          String resultPayload = StringUtils.EMPTY;
37  
38          try
39          {
40              MuleClient client = new MuleClient();
41              result = client.send(url, INPUT, null);
42              resultPayload = (result != null ? result.getPayloadAsString() : StringUtils.EMPTY);
43          }
44          catch (MuleException e)
45          {
46              fail(ExceptionUtils.getStackTrace(e));
47          }
48  
49          assertNotNull(result);
50          assertEquals(OUTPUT, resultPayload);
51      }
52  
53      // This doesn't work as Axis WSDL parser doesn't grab the param names from the
54      // schema for some reason...
55  
56      // public void testAxisWsdlRequestResponseAuto() throws Throwable {
57      // if
58      // (isOffline("org.mule.test.integration.client.MuleClientXFireExternalTestCase.testAxisWsdlRequestResponse()"))
59      // return;
60      // Map properties = new HashMap();
61      // //properties.put(AxisConnector.SOAP_ACTION_PROPERTY,
62      // "${methodNamespace}#${method}");
63      // //properties.put(AxisConnector.METHOD_NAMESPACE_PROPERTY,
64      // "urn:xmethods-delayed-quotes");
65      //
66      // properties.put("style", "document");
67      // properties.put("use", "literal");
68      // String url = "wsdl-axis:" + WSDL_URL + "&method=" + METHOD;
69      // MuleClient client = null;
70      // client = new MuleClient();
71      // MuleMessage result = client.send(url, INPUT, properties);
72      // assertNotNull(result);
73      // assertEquals(OUTPUT, result.getPayload());
74      // }
75  
76      public void testDiscoveryWsdlRequestResponse() throws Throwable
77      {
78          if (isOffline("org.mule.test.integration.client.MuleClientXFireExternalTestCase.testDiscoveryWsdlRequestResponse()"))
79          {
80              return;
81          }
82  
83          String url = "wsdl:" + WSDL_URL + "&method=" + METHOD;
84          MuleClient client;
85          client = new MuleClient();
86          MuleMessage result = client.send(url, INPUT, null);
87          assertNotNull(result);
88          assertEquals(OUTPUT, result.getPayload());
89      }
90  
91  }