View Javadoc

1   package org.kuali.ole.editor.service.impl;
2   
3   import org.apache.cxf.frontend.ClientProxyFactoryBean;
4   import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
5   import org.kuali.ole.editor.service.OleWebServiceProvider;
6   import org.kuali.rice.core.api.exception.RiceRuntimeException;
7   
8   import javax.xml.namespace.QName;
9   
10  /**
11   * OleWebServiceProviderImpl uses OleWebServiceProvider for consuming webservices which are exposed in other applications.
12   */
13  public class OleWebServiceProviderImpl implements OleWebServiceProvider{
14      private ClientProxyFactoryBean clientFactory=null;
15  
16      /**
17       *   Gets the services from JaxWsProxyFactoryBean,And sets the ServiceClass,ServiceName,and URL.
18       * @param serviceClassName
19       * @param serviceName
20       * @param serviceURL
21       * @return  Returns the Service.
22       */
23      @Override
24      public Object getService(String serviceClassName, String serviceName, String serviceURL) {
25          try {
26              clientFactory = new JaxWsProxyFactoryBean();
27              clientFactory.setServiceClass(Class.forName(serviceClassName));
28          } catch (ClassNotFoundException e) {
29              throw new RiceRuntimeException("Failed to connect to soap service because failed to load interface class: ", e);
30          }
31          QName namespaceURI = new QName("http://service.select.ole.kuali.org/", serviceName);
32          clientFactory.setServiceName(namespaceURI);
33          clientFactory.setAddress(serviceURL);
34          Object service = clientFactory.create();
35          return service;
36      }
37  }