wsdl的动态Web服务客户端 [英] Dynamic web service client from wsdl
问题描述
我的系统之一需要调用基于SOAP的Web服务.到目前为止,对于每个新的Web服务,我都会从提供的WSDL文件中生成Java存根,并使用新的Web服务使用者代码重新部署Web应用程序.有没有一种好的方法可以动态创建可从提供的WSDL文件中调用方法的Web服务客户端?我所期望的只是
One of my system need to invoke SOAP based webservices. As of now, for every new webservices, I generate Java stubs from the provided WSDL file and redeploy the web application with new webservice consumer code. Is there a good approach to dynamically create a webservice client that can invoke the methods from the provided WSDL files? All I am expecting is
- 将WSDL文件放在Web应用程序可以访问的位置
- 使用具有wsdl文件名和webservice方法所需的其他参数的关键字来调用Servlet.
Apache CXF可以提供帮助吗?我读了一篇文章,在运行时生成wsdl2java并加载类,一段时间后会耗尽pemgen内存空间.
Can the Apache CXF help in this? I read in a post, generating wsdl2java in the runtime and loading the classes, over a time, can exhaust the pemgen memory space.
推荐答案
您应该在这里查看: http://cxf.apache.org/docs/dynamic-clients.html 就是这样.
You should look here : http://cxf.apache.org/docs/dynamic-clients.html This is exactly that.
这里是一个例子:
ClientImpl client = (ClientImpl)doc.getClientFromWsdl("http://myurl:8080/DataCentersWS?wsdl");
String operationName = "getVirtualisationManagerUuid";
BindingOperationInfo op = doc.getOperation(client, operationName);
List<MessagePartInfo> messagesParts = op.getInput().getMessageParts();
Object[] params = new Object[messagesParts.size()];
/* feed yours params here (this feeding was heavy in my code */
Object[] res = client.invoke(op, params);
cxf的源代码分发中还有许多其他示例.
There is many other examples in the source distribution of cxf.
这篇关于wsdl的动态Web服务客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!