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