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