001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.net.rpc.client; 020 021import lucee.runtime.PageContext; 022import lucee.runtime.config.Config; 023import lucee.runtime.config.ConfigImpl; 024import lucee.runtime.engine.ThreadLocalPageContext; 025import lucee.runtime.exp.PageException; 026import lucee.runtime.listener.ApplicationContextPro; 027import lucee.runtime.net.proxy.ProxyData; 028import lucee.runtime.type.Collection; 029import lucee.runtime.type.Iteratorable; 030import lucee.runtime.type.Objects; 031import lucee.runtime.type.Struct; 032 033import org.apache.axis.client.Call; 034import org.apache.axis.message.SOAPHeaderElement; 035import org.apache.log4j.Logger; 036 037public abstract class WSClient implements Objects, Iteratorable { 038 039 public static WSClient getInstance(PageContext pc,String wsdlUrl, String username, String password, ProxyData proxyData) throws PageException { 040 pc=ThreadLocalPageContext.get(pc); 041 if(pc!=null) { 042 Logger l = ((ConfigImpl)pc.getConfig()).getLogger("application", true); 043 ApplicationContextPro ac = (ApplicationContextPro) pc.getApplicationContext(); 044 if(ac!=null) { 045 if(ApplicationContextPro.WS_TYPE_JAX_WS==ac.getWSType()) { 046 l.info("using JAX WS Client"); 047 return new JaxWSClient(wsdlUrl, username, password, proxyData); 048 } 049 if(ApplicationContextPro.WS_TYPE_CXF==ac.getWSType()) { 050 l.info("using CXF Client"); 051 return new CXFClient(wsdlUrl, username, password, proxyData); 052 } 053 } 054 l.info("using Axis 1 RPC Client"); 055 } 056 return new Axis1Client(wsdlUrl,username,password,proxyData); 057 } 058 059 060 061 public abstract void addHeader(SOAPHeaderElement header) throws PageException; 062 public abstract Call getLastCall()throws PageException; 063 public abstract Object callWithNamedValues(Config config, Collection.Key methodName, Struct arguments) throws PageException; 064 public abstract Object callWithNamedValues(PageContext pc, Collection.Key methodName, Struct arguments) throws PageException; 065 066}