View Javadoc

1   /*
2    * $Id: WebServiceWrapperComponent.java 12228 2008-07-03 00:26:59Z aguenther $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.soap.axis.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.axis.AxisConnector;
22  import org.mule.transport.soap.component.AbstractWebServiceWrapperComponent;
23  
24  import java.util.Map;
25  
26  public class WebServiceWrapperComponent extends AbstractWebServiceWrapperComponent
27  {
28  
29      private String use;
30      private String style;
31      private Map properties;
32  
33      protected MuleMessage doOnCall(MuleEvent event) throws Exception
34      {
35          MuleContext muleContext = event.getMuleContext();
36  
37          String tempUrl;
38          if (addressFromMessage)
39          {
40              tempUrl = event.getMessage().getStringProperty(WS_SERVICE_URL, null);
41              if (tempUrl == null)
42              {
43                  throw new IllegalArgumentException(CoreMessages.propertyIsNotSetOnEvent(WS_SERVICE_URL)
44                      .toString());
45              }
46          }
47          else
48          {
49              tempUrl = address;
50          }
51          MuleMessage message = new DefaultMuleMessage(event.transformMessage());
52  
53          if (properties != null && properties.get(AxisConnector.SOAP_METHODS) != null)
54          {
55              message.addProperties((Map) properties.get(AxisConnector.SOAP_METHODS));
56          }
57  
58          EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder("axis:" + tempUrl, muleContext);
59          if (use != null)
60          {
61              endpointBuilder.setProperty(AxisConnector.USE, use);
62          }
63          if (style != null)
64          {
65              endpointBuilder.setProperty(AxisConnector.STYLE, style);
66  
67          }
68  
69          OutboundEndpoint endpoint = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
70              endpointBuilder);
71  
72          MuleMessage result = event.getSession().sendEvent(message, endpoint);
73          return result;
74      }
75  
76      public String getUse()
77      {
78          return use;
79      }
80  
81      public void setUse(String use)
82      {
83          this.use = use;
84      }
85  
86      public String getStyle()
87      {
88          return style;
89      }
90  
91      public void setStyle(String style)
92      {
93          this.style = style;
94      }
95  
96      public Map getProperties()
97      {
98          return properties;
99      }
100 
101     public void setProperties(Map properties)
102     {
103         this.properties = properties;
104     }
105 
106 }