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 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 MuleContext muleContext = event.getMuleContext();
31
32 String tempUrl;
33 if (addressFromMessage)
34 {
35 tempUrl = event.getMessage().getInboundProperty(WS_SERVICE_URL);
36 if (tempUrl == null)
37 {
38 throw new IllegalArgumentException(CoreMessages.propertyIsNotSetOnEvent(WS_SERVICE_URL)
39 .toString());
40 }
41 }
42 else
43 {
44 tempUrl = address;
45 }
46
47 EndpointBuilder endpointBuilder = new CxfEndpointBuilder("cxf:" + tempUrl, muleContext);
48 if (wsdlPort != null)
49 {
50 endpointBuilder.setProperty("port", wsdlPort);
51 }
52 if (operation != null)
53 {
54 endpointBuilder.setProperty("operation", operation);
55
56 }
57
58
59 endpointBuilder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
60 OutboundEndpoint endpoint = endpointBuilder.buildOutboundEndpoint();
61
62 MuleEvent responseEvent = endpoint.process(new DefaultMuleEvent(event.getMessage(), endpoint,
63 event.getSession()));
64
65 if (responseEvent != null)
66 {
67 return responseEvent.getMessage();
68 }
69 else
70 {
71 return null;
72 }
73 }
74
75 public String getWsdlPort()
76 {
77 return wsdlPort;
78 }
79
80 public void setWsdlPort(String wsdlPort)
81 {
82 this.wsdlPort = wsdlPort;
83 }
84
85 public String getOperation()
86 {
87 return operation;
88 }
89
90 public void setOperation(String operation)
91 {
92 this.operation = operation;
93 }
94
95 }