1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.soap.xfire.transport; |
12 | |
|
13 | |
import org.mule.providers.soap.xfire.MuleInvoker; |
14 | |
|
15 | |
import org.apache.commons.logging.Log; |
16 | |
import org.apache.commons.logging.LogFactory; |
17 | |
import org.codehaus.xfire.MessageContext; |
18 | |
import org.codehaus.xfire.service.Binding; |
19 | |
import org.codehaus.xfire.service.Service; |
20 | |
import org.codehaus.xfire.soap.Soap11; |
21 | |
import org.codehaus.xfire.soap.Soap12; |
22 | |
import org.codehaus.xfire.soap.SoapTransportHelper; |
23 | |
import org.codehaus.xfire.soap.SoapVersion; |
24 | |
import org.codehaus.xfire.transport.AbstractTransport; |
25 | |
import org.codehaus.xfire.transport.Channel; |
26 | |
import org.codehaus.xfire.transport.DefaultEndpoint; |
27 | |
import org.codehaus.xfire.wsdl11.WSDL11Transport; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class MuleUniversalTransport extends AbstractTransport implements WSDL11Transport |
33 | |
{ |
34 | |
public static final String SOAP11_HTTP_BINDING = "http://schemas.xmlsoap.org/soap/http"; |
35 | |
public static final String SOAP12_HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/"; |
36 | |
public static final String HTTP_BINDING = "http://www.w3.org/2004/08/wsdl/http"; |
37 | |
public static final String HTTP_TRANSPORT_NS = "http://schemas.xmlsoap.org/soap/mule"; |
38 | |
private static final String URI_PREFIX = "urn:xfire:transport:mule:"; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 88 | protected transient Log logger = LogFactory.getLog(getClass()); |
44 | |
|
45 | |
public MuleUniversalTransport() |
46 | 88 | { |
47 | 88 | SoapTransportHelper.createSoapTransport(this); |
48 | 88 | } |
49 | |
|
50 | |
protected Channel createNewChannel(String uri) |
51 | |
{ |
52 | 34 | logger.debug("Creating new channel for uri: " + uri); |
53 | |
|
54 | 34 | MuleUniversalChannel c = new MuleUniversalChannel(uri, this); |
55 | 34 | c.setEndpoint(new DefaultEndpoint()); |
56 | |
|
57 | 34 | return c; |
58 | |
} |
59 | |
|
60 | |
protected String getUriPrefix() |
61 | |
{ |
62 | 0 | return URI_PREFIX; |
63 | |
} |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
public String getServiceURL(Service service) |
69 | |
{ |
70 | |
|
71 | 22 | String ep = ((MuleInvoker) service.getInvoker()).getEndpoint().getEndpointURI().getAddress(); |
72 | 22 | return ep + "/" + service.getSimpleName(); |
73 | |
} |
74 | |
|
75 | |
public String getTransportURI(Service service) |
76 | |
{ |
77 | 0 | return HTTP_TRANSPORT_NS; |
78 | |
} |
79 | |
|
80 | |
public String[] getKnownUriSchemes() |
81 | |
{ |
82 | 0 | return new String[]{"http://", "https://", "jms://", "vm://", "xmpp://", "smtp://", "tcp://"}; |
83 | |
} |
84 | |
|
85 | |
public String[] getSupportedBindings() |
86 | |
{ |
87 | 88 | return new String[]{SOAP11_HTTP_BINDING, SOAP12_HTTP_BINDING}; |
88 | |
} |
89 | |
|
90 | |
public String getName() |
91 | |
{ |
92 | 22 | return "Mule"; |
93 | |
} |
94 | |
|
95 | |
public Binding findBinding(MessageContext context, Service service) |
96 | |
{ |
97 | 0 | SoapVersion version = context.getCurrentMessage().getSoapVersion(); |
98 | |
|
99 | 0 | if (version instanceof Soap11) |
100 | |
{ |
101 | 0 | return service.getBinding(SOAP11_HTTP_BINDING); |
102 | |
} |
103 | 0 | else if (version instanceof Soap12) |
104 | |
{ |
105 | 0 | return service.getBinding(SOAP12_HTTP_BINDING); |
106 | |
} |
107 | |
|
108 | 0 | return super.findBinding(context, service); |
109 | |
} |
110 | |
} |