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