Coverage Report - org.mule.providers.soap.axis.wsdl.AxisWsdlMessageDispatcher
 
Classes in this File Line Coverage Branch Coverage Complexity
AxisWsdlMessageDispatcher
0%
0/24
0%
0/5
4
 
 1  
 /*
 2  
  * $Id: AxisWsdlMessageDispatcher.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.wsdl;
 12  
 
 13  
 import org.mule.providers.soap.SoapConstants;
 14  
 import org.mule.providers.soap.axis.AxisMessageDispatcher;
 15  
 import org.mule.umo.UMOEvent;
 16  
 import org.mule.umo.endpoint.UMOImmutableEndpoint;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Iterator;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 import java.util.Vector;
 23  
 
 24  
 import javax.xml.namespace.QName;
 25  
 
 26  
 import org.apache.axis.client.AxisClient;
 27  
 import org.apache.axis.client.Service;
 28  
 import org.apache.axis.wsdl.gen.Parser;
 29  
 import org.apache.axis.wsdl.symbolTable.ServiceEntry;
 30  
 import org.apache.axis.wsdl.symbolTable.SymTabEntry;
 31  
 
 32  
 /**
 33  
  * Creates and Axis client services from WSDL and invokes it
 34  
  * 
 35  
  * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
 36  
  * @version $Revision: 7976 $
 37  
  */
 38  
 public class AxisWsdlMessageDispatcher extends AxisMessageDispatcher
 39  
 {
 40  
 
 41  
     public AxisWsdlMessageDispatcher(UMOImmutableEndpoint endpoint)
 42  
     {
 43  0
         super(endpoint);
 44  0
     }
 45  
 
 46  
     protected Service createService(UMOEvent event) throws Exception
 47  
     {
 48  0
         String wsdlUrl = event.getEndpoint().getEndpointURI().getAddress();
 49  
         // Parse the wsdl
 50  0
         Parser parser = new Parser();
 51  0
         if (event.getEndpoint().getEndpointURI().getUserInfo() != null)
 52  
         {
 53  0
             parser.setUsername(event.getEndpoint().getEndpointURI().getUsername());
 54  0
             parser.setPassword(event.getEndpoint().getEndpointURI().getPassword());
 55  
         }
 56  0
         parser.run(wsdlUrl);
 57  
         // Retrieves the defined services
 58  0
         Map map = parser.getSymbolTable().getHashMap();
 59  0
         List entries = new ArrayList();
 60  0
         for (Iterator it = map.entrySet().iterator(); it.hasNext();)
 61  
         {
 62  0
             Map.Entry entry = (Map.Entry)it.next();
 63  0
             Vector v = (Vector)entry.getValue();
 64  0
             for (Iterator it2 = v.iterator(); it2.hasNext();)
 65  
             {
 66  0
                 SymTabEntry e = (SymTabEntry)it2.next();
 67  0
                 if (ServiceEntry.class.isInstance(e))
 68  
                 {
 69  0
                     entries.add(entry.getKey());
 70  
                 }
 71  
             }
 72  
         }
 73  
         // Currently, only one service should be defined
 74  0
         if (entries.size() != 1)
 75  
         {
 76  0
             throw new Exception("Need one and only one service entry, found " + entries.size());
 77  
         }
 78  
         // Create the axis service
 79  0
         Service service = new Service(parser, (QName)entries.get(0));
 80  
 
 81  0
         service.setEngineConfiguration(clientConfig);
 82  0
         service.setEngine(new AxisClient(clientConfig));
 83  
 
 84  
         // Really the Axis Client service should set this stuff
 85  0
         event.getMessage().setProperty(SoapConstants.METHOD_NAMESPACE_PROPERTY,
 86  
             parser.getCurrentDefinition().getTargetNamespace());
 87  
         // Todo how can we autogenerate the named params from the WSDL?
 88  0
         return service;
 89  
     }
 90  
 }