dubbo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] lixiaguang opened a new issue #1585: How to use standard cxf client to invoke Dubbo Webservice?
Date Wed, 11 Apr 2018 00:33:08 GMT
lixiaguang opened a new issue #1585: How to use standard cxf client to invoke Dubbo Webservice?
URL: https://github.com/apache/incubator-dubbo/issues/1585
 
 
   I got a  Dubbo Webservice WSDL Address. I want to use cxf client toinvoke.But when i run
my code,I got some error "NullPointerException".
   here is my client code:
   -----------------------------------------
   import javax.xml.namespace.QName;
   import javax.xml.ws.WebServiceClient;
   
   import org.apache.cxf.endpoint.Client;
   import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
   import org.apache.log4j.Logger;
   
   import cn.com.shenhuagroup.xxgs.bigdata.test.builddata.BuildTestData;
   
   public class Test1 {
   	Logger log = Logger.getLogger(Test1.class);
   
   	public Object[] callWebService(String wsdl, String targetNamespace, String methodName,
Object args[]) {
   		Object[] res = null;
   		try {
   			log.info("动态调用webservice开始,wsdl:" + wsdl + ",methodName:" + methodName
+ ",args:" + args);
   			JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
   			Client client = dcf.createClient(wsdl);
   			if (targetNamespace == null) {
   				res = client.invoke(methodName, args);
   			} else {
   				res = client.invoke(new QName(targetNamespace, methodName), args);
   			}
   
   		} catch (Exception e) {
   			log.error("动态调用webservice 失败,wsdl:" + wsdl + ",targetNamespace:" + targetNamespace
+ ",methodName:"
   					+ methodName + ",args:" + args, e);
   		}
   		return res;
   	}
   
   	public static void main(String[] args) {
   		String wsdl = "http://xxxxxxxxxx:8080/TestService?wsdl"; // WSDL
   		String targetNamespace = "http://xxxxxxxxxx.com/"; // WSDL
   		String methodName = "getUserInfo";
   		Object params[] = {"id","1" };
   		Test1 client = new Test1();
   		Object[] res = client.callWebService(wsdl, targetNamespace, methodName, params);
   		System.out.println(res.toString());
   	}
   }
   
   Here is error:
   ---------------------------------------
   java.lang.NullPointerException
   	at org.apache.cxf.transport.http.URLConnectionHTTPConduit.createConnection(URLConnectionHTTPConduit.java:109)
   	at org.apache.cxf.transport.http.URLConnectionHTTPConduit.setupConnection(URLConnectionHTTPConduit.java:122)
   	at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:499)
   	at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)
   	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
   	at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
   	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
   	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
   	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
   	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:297)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message