Coverage Report - org.mule.providers.soap.xfire.wsdl.XFireWsdlMessageDispatcher
 
Classes in this File Line Coverage Branch Coverage Complexity
XFireWsdlMessageDispatcher
76%
22/29
38%
3/8
3.333
 
 1  
 /*
 2  
  * $Id: XFireWsdlMessageDispatcher.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 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.providers.soap.xfire.wsdl;
 12  
 
 13  
 import org.mule.providers.soap.xfire.XFireMessageDispatcher;
 14  
 import org.mule.umo.endpoint.UMOEndpointURI;
 15  
 import org.mule.umo.endpoint.UMOImmutableEndpoint;
 16  
 import org.mule.util.StringUtils;
 17  
 
 18  
 import java.net.URL;
 19  
 
 20  
 import javax.xml.namespace.QName;
 21  
 
 22  
 import org.codehaus.xfire.XFire;
 23  
 import org.codehaus.xfire.client.Client;
 24  
 import org.codehaus.xfire.service.Service;
 25  
 
 26  
 /**
 27  
  * TODO document
 28  
  */
 29  
 public class XFireWsdlMessageDispatcher extends XFireMessageDispatcher
 30  
 {
 31  
     public static final String DEFAULT_WSDL_TRANSPORT = "org.codehaus.xfire.transport.http.SoapHttpTransport";
 32  
 
 33  
     public XFireWsdlMessageDispatcher(UMOImmutableEndpoint endpoint)
 34  
     {
 35  6
         super(endpoint);
 36  6
     }
 37  
 
 38  
     // @Override
 39  
     protected void doConnect() throws Exception
 40  
     {
 41  
         try
 42  
         {
 43  6
             XFire xfire = connector.getXfire();
 44  6
             String wsdlUrl = endpoint.getEndpointURI().getAddress();
 45  6
             String serviceName = endpoint.getEndpointURI().getAddress();
 46  
 
 47  
             // If the property specified an alternative WSDL url, use it
 48  6
             if (endpoint.getProperty("wsdlUrl") != null && StringUtils.isNotBlank(endpoint.getProperty("wsdlUrl").toString()))
 49  
             {
 50  0
                 wsdlUrl = (String) endpoint.getProperty("wsdlUrl");
 51  
             }
 52  
 
 53  6
             if (serviceName.indexOf("?") > -1)
 54  
             {
 55  6
                 serviceName = serviceName.substring(0, serviceName.lastIndexOf('?'));
 56  
             }
 57  
 
 58  6
             Service service = xfire.getServiceRegistry().getService(new QName(serviceName));
 59  
 
 60  6
             if (service == null)
 61  
             {
 62  6
                 service = new Client(new URL(wsdlUrl)).getService();
 63  6
                 service.setName(new QName(serviceName));
 64  6
                 xfire.getServiceRegistry().register(service);
 65  
             }
 66  
 
 67  
             try
 68  
             {
 69  6
                 this.client = createXFireWsdlClient(endpoint, service, xfire, wsdlUrl);
 70  
             }
 71  0
             catch (Exception ex)
 72  
             {
 73  0
                 disconnect();
 74  0
                 throw ex;
 75  6
             }
 76  
         }
 77  0
         catch (Exception ex)
 78  
         {
 79  0
             disconnect();
 80  0
             throw ex;
 81  6
         }
 82  6
     }
 83  
 
 84  
     protected Client createXFireWsdlClient(UMOImmutableEndpoint endpoint, Service service, XFire xfire, String wsdlUrl) throws Exception
 85  
     {
 86  6
         UMOEndpointURI uri = endpoint.getEndpointURI();
 87  6
         Client client = new Client(new URL(wsdlUrl));
 88  6
         client.setXFire(xfire);
 89  6
         client.setEndpointUri(uri.toString());
 90  6
         return configureXFireClient(client);
 91  
     }
 92  
 }