1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.soap.xfire.wsdl; |
12 | |
|
13 | |
import org.mule.providers.soap.xfire.XFireMessageDispatcher; |
14 | |
import org.mule.umo.endpoint.UMOEndpointURI; |
15 | |
import org.mule.umo.endpoint.UMOImmutableEndpoint; |
16 | |
import org.mule.util.StringUtils; |
17 | |
|
18 | |
import java.net.URL; |
19 | |
|
20 | |
import javax.xml.namespace.QName; |
21 | |
|
22 | |
import org.codehaus.xfire.XFire; |
23 | |
import org.codehaus.xfire.client.Client; |
24 | |
import org.codehaus.xfire.service.Service; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class XFireWsdlMessageDispatcher extends XFireMessageDispatcher |
30 | |
{ |
31 | |
public static final String DEFAULT_WSDL_TRANSPORT = "org.codehaus.xfire.transport.http.SoapHttpTransport"; |
32 | |
|
33 | |
public XFireWsdlMessageDispatcher(UMOImmutableEndpoint endpoint) |
34 | |
{ |
35 | 0 | super(endpoint); |
36 | 0 | } |
37 | |
|
38 | |
|
39 | |
protected void doConnect() throws Exception |
40 | |
{ |
41 | |
try |
42 | |
{ |
43 | 0 | XFire xfire = connector.getXfire(); |
44 | 0 | String wsdlUrl = endpoint.getEndpointURI().getAddress(); |
45 | 0 | String serviceName = endpoint.getEndpointURI().getAddress(); |
46 | |
|
47 | |
|
48 | 0 | if (endpoint.getProperty("wsdlUrl") != null && StringUtils.isNotBlank(endpoint.getProperty("wsdlUrl").toString())) |
49 | |
{ |
50 | 0 | wsdlUrl = (String) endpoint.getProperty("wsdlUrl"); |
51 | |
} |
52 | |
|
53 | 0 | if (serviceName.indexOf("?") > -1) |
54 | |
{ |
55 | 0 | serviceName = serviceName.substring(0, serviceName.lastIndexOf('?')); |
56 | |
} |
57 | |
|
58 | 0 | Service service = xfire.getServiceRegistry().getService(new QName(serviceName)); |
59 | |
|
60 | 0 | if (service == null) |
61 | |
{ |
62 | 0 | service = new Client(new URL(wsdlUrl)).getService(); |
63 | 0 | service.setName(new QName(serviceName)); |
64 | 0 | xfire.getServiceRegistry().register(service); |
65 | |
} |
66 | |
|
67 | |
try |
68 | |
{ |
69 | 0 | this.client = createXFireWsdlClient(endpoint, service, xfire, wsdlUrl); |
70 | |
} |
71 | 0 | catch (Exception ex) |
72 | |
{ |
73 | 0 | disconnect(); |
74 | 0 | throw ex; |
75 | 0 | } |
76 | |
} |
77 | 0 | catch (Exception ex) |
78 | |
{ |
79 | 0 | disconnect(); |
80 | 0 | throw ex; |
81 | 0 | } |
82 | 0 | } |
83 | |
|
84 | |
protected Client createXFireWsdlClient(UMOImmutableEndpoint endpoint, Service service, XFire xfire, String wsdlUrl) throws Exception |
85 | |
{ |
86 | 0 | UMOEndpointURI uri = endpoint.getEndpointURI(); |
87 | 0 | Client client = new Client(new URL(wsdlUrl)); |
88 | 0 | client.setXFire(xfire); |
89 | 0 | client.setEndpointUri(uri.toString()); |
90 | 0 | return configureXFireClient(client); |
91 | |
} |
92 | |
} |