vvra
vvra

Reputation: 2912

Dynamic web service client from wsdl

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

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.

Upvotes: 1

Views: 6805

Answers (1)

Galigator
Galigator

Reputation: 10711

You should look here : http://cxf.apache.org/docs/dynamic-clients.html This is exactly that.

here an example:

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);

There is many other examples in the source distribution of cxf.

Upvotes: 1

Related Questions