1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.cxf.component;
12
13 import org.mule.DefaultMuleMessage;
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.endpoint.EndpointURIEndpointBuilder;
21 import org.mule.transport.soap.component.AbstractWebServiceWrapperComponent;
22
23 public class WebServiceWrapperComponent extends AbstractWebServiceWrapperComponent
24 {
25 private String wsdlPort;
26 private String operation;
27
28 protected MuleMessage doOnCall(MuleEvent event) throws Exception
29 {
30 MuleContext muleContext = event.getMuleContext();
31
32 String tempUrl;
33 if (addressFromMessage)
34 {
35 tempUrl = event.getMessage().getStringProperty(WS_SERVICE_URL, null);
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 MuleMessage message = new DefaultMuleMessage(event.transformMessage());
47
48 EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder("cxf:" + tempUrl, muleContext);
49 if (wsdlPort != null)
50 {
51 endpointBuilder.setProperty("wsdlPort", wsdlPort);
52 }
53 if (operation != null)
54 {
55 endpointBuilder.setProperty("operation", operation);
56
57 }
58
59 OutboundEndpoint endpoint = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
60 endpointBuilder);
61
62 MuleMessage result = event.getSession().sendEvent(message, endpoint);
63 return result;
64 }
65
66 public String getWsdlPort()
67 {
68 return wsdlPort;
69 }
70
71 public void setWsdlPort(String wsdlPort)
72 {
73 this.wsdlPort = wsdlPort;
74 }
75
76 public String getOperation()
77 {
78 return operation;
79 }
80
81 public void setOperation(String operation)
82 {
83 this.operation = operation;
84 }
85
86 }