1   /*
2    * $Id: MuleClientWSDLExternalTestCase.java 12118 2008-06-20 12:08:00Z dandiep $
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.transport.soap.SoapConstants;
18  import org.mule.util.ExceptionUtils;
19  import org.mule.util.StringUtils;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  public class MuleClientWSDLExternalTestCase extends AbstractMuleTestCase
25  {
26      public void testRequestResponse() throws Throwable
27      {
28          if (isOffline("org.mule.test.integration.client.MuleClientWSDLExternalTestCase.testRequestResponse()"))
29          {
30              return;
31          }
32  
33          String input = "IBM";
34          Map properties = new HashMap();
35          properties.put(SoapConstants.SOAP_ACTION_PROPERTY, "${methodNamespace}${method}");
36          properties.put(SoapConstants.METHOD_NAMESPACE_PROPERTY, "http://www.webserviceX.NET/");
37          String url = "wsdl:http://www.webservicex.net/stockquote.asmx?WSDL&method=GetQuote";
38          MuleMessage result = null;
39          String resultPayload = StringUtils.EMPTY;
40  
41          try
42          {
43              MuleClient client = new MuleClient();
44              result = client.send(url, input, properties);
45              resultPayload = (result != null ? result.getPayloadAsString() : StringUtils.EMPTY);
46          }
47          catch (MuleException e)
48          {
49              fail(ExceptionUtils.getStackTrace(e));
50          }
51  
52          if (result != null)
53          {
54              logger.debug("The quote for " + input + " is: " + result.getPayload());
55          }
56  
57          assertNotNull(result);
58          assertTrue(resultPayload.startsWith("<StockQuotes><Stock><Symbol>IBM</Symbol>"));
59      }
60  
61  }