1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
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 | |
|
34 | |
|
35 | |
|
36 | |
|
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 | |
|
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 | |
|
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 | |
|
74 | 0 | if (entries.size() != 1) |
75 | |
{ |
76 | 0 | throw new Exception("Need one and only one service entry, found " + entries.size()); |
77 | |
} |
78 | |
|
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 | |
|
85 | 0 | event.getMessage().setProperty(SoapConstants.METHOD_NAMESPACE_PROPERTY, |
86 | |
parser.getCurrentDefinition().getTargetNamespace()); |
87 | |
|
88 | 0 | return service; |
89 | |
} |
90 | |
} |