1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.module.cxf.component; |
8 | |
|
9 | |
import org.mule.DefaultMuleEvent; |
10 | |
import org.mule.MessageExchangePattern; |
11 | |
import org.mule.api.MuleContext; |
12 | |
import org.mule.api.MuleEvent; |
13 | |
import org.mule.api.MuleMessage; |
14 | |
import org.mule.api.endpoint.EndpointBuilder; |
15 | |
import org.mule.api.endpoint.OutboundEndpoint; |
16 | |
import org.mule.config.i18n.CoreMessages; |
17 | |
import org.mule.module.cxf.endpoint.CxfEndpointBuilder; |
18 | |
|
19 | 0 | public class WebServiceWrapperComponent extends AbstractWebServiceWrapperComponent |
20 | |
{ |
21 | |
private String wsdlPort; |
22 | |
private String operation; |
23 | |
|
24 | |
protected MuleMessage doInvoke(MuleEvent event) throws Exception |
25 | |
{ |
26 | 0 | MuleContext muleContext = event.getMuleContext(); |
27 | |
|
28 | |
String tempUrl; |
29 | 0 | if (addressFromMessage) |
30 | |
{ |
31 | 0 | tempUrl = event.getMessage().getInboundProperty(WS_SERVICE_URL); |
32 | 0 | if (tempUrl == null) |
33 | |
{ |
34 | 0 | throw new IllegalArgumentException(CoreMessages.propertyIsNotSetOnEvent(WS_SERVICE_URL) |
35 | |
.toString()); |
36 | |
} |
37 | |
} |
38 | |
else |
39 | |
{ |
40 | 0 | tempUrl = address; |
41 | |
} |
42 | |
|
43 | 0 | EndpointBuilder endpointBuilder = new CxfEndpointBuilder("cxf:" + tempUrl, muleContext); |
44 | 0 | if (wsdlPort != null) |
45 | |
{ |
46 | 0 | endpointBuilder.setProperty("port", wsdlPort); |
47 | |
} |
48 | 0 | if (operation != null) |
49 | |
{ |
50 | 0 | endpointBuilder.setProperty("operation", operation); |
51 | |
|
52 | |
} |
53 | |
|
54 | |
|
55 | 0 | endpointBuilder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE); |
56 | 0 | OutboundEndpoint endpoint = endpointBuilder.buildOutboundEndpoint(); |
57 | |
|
58 | 0 | MuleEvent responseEvent = endpoint.process(new DefaultMuleEvent(event.getMessage(), endpoint, |
59 | |
event.getSession())); |
60 | |
|
61 | 0 | if (responseEvent != null) |
62 | |
{ |
63 | 0 | return responseEvent.getMessage(); |
64 | |
} |
65 | |
else |
66 | |
{ |
67 | 0 | return null; |
68 | |
} |
69 | |
} |
70 | |
|
71 | |
public String getWsdlPort() |
72 | |
{ |
73 | 0 | return wsdlPort; |
74 | |
} |
75 | |
|
76 | |
public void setWsdlPort(String wsdlPort) |
77 | |
{ |
78 | 0 | this.wsdlPort = wsdlPort; |
79 | 0 | } |
80 | |
|
81 | |
public String getOperation() |
82 | |
{ |
83 | 0 | return operation; |
84 | |
} |
85 | |
|
86 | |
public void setOperation(String operation) |
87 | |
{ |
88 | 0 | this.operation = operation; |
89 | 0 | } |
90 | |
|
91 | |
} |