1 10 11 package org.mule.providers.soap.axis.wsdl; 12 13 import org.apache.axis.client.AxisClient; 14 import org.apache.axis.client.Service; 15 import org.apache.axis.wsdl.gen.Parser; 16 import org.apache.axis.wsdl.symbolTable.ServiceEntry; 17 import org.apache.axis.wsdl.symbolTable.SymTabEntry; 18 import org.mule.providers.soap.SoapConstants; 19 import org.mule.providers.soap.axis.AxisMessageDispatcher; 20 import org.mule.umo.UMOEvent; 21 import org.mule.umo.endpoint.UMOImmutableEndpoint; 22 23 import javax.xml.namespace.QName ; 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import java.util.Map ; 28 import java.util.Vector ; 29 30 36 public class AxisWsdlMessageDispatcher extends AxisMessageDispatcher 37 { 38 39 public AxisWsdlMessageDispatcher(UMOImmutableEndpoint endpoint) 40 { 41 super(endpoint); 42 } 43 44 protected Service createService(UMOEvent event) throws Exception 45 { 46 String wsdlUrl = event.getEndpoint().getEndpointURI().getAddress(); 47 Parser parser = new Parser(); 49 if (event.getEndpoint().getEndpointURI().getUserInfo() != null) 50 { 51 parser.setUsername(event.getEndpoint().getEndpointURI().getUsername()); 52 parser.setPassword(event.getEndpoint().getEndpointURI().getPassword()); 53 } 54 parser.run(wsdlUrl); 55 Map map = parser.getSymbolTable().getHashMap(); 57 List entries = new ArrayList (); 58 for (Iterator it = map.entrySet().iterator(); it.hasNext();) 59 { 60 Map.Entry entry = (Map.Entry )it.next(); 61 Vector v = (Vector )entry.getValue(); 62 for (Iterator it2 = v.iterator(); it2.hasNext();) 63 { 64 SymTabEntry e = (SymTabEntry)it2.next(); 65 if (ServiceEntry.class.isInstance(e)) 66 { 67 entries.add(entry.getKey()); 68 } 69 } 70 } 71 if (entries.size() != 1) 73 { 74 throw new Exception ("Need one and only one service entry, found " + entries.size()); 75 } 76 Service service = new Service(parser, (QName )entries.get(0)); 78 79 service.setEngineConfiguration(clientConfig); 80 service.setEngine(new AxisClient(clientConfig)); 81 82 event.getMessage().setProperty(SoapConstants.METHOD_NAMESPACE_PROPERTY, 84 parser.getCurrentDefinition().getTargetNamespace()); 85 return service; 87 } 88 } 89 | Popular Tags |