In Python, I can easily use the web service:
from suds.client import Client client = Client('http://www.example.org/MyService/wsdl/myservice.wsdl')
I would like to achieve such a simple use with Java.
Using Axis or CXF, you need to create a web service client, that is, a package that reproduces all the web service methods so that we can refer to them as if they were regular methods. Call to call proxy classes ; they are usually generated using the wsdl2java tool.
Useful and convenient. But anytime when I add / change a web service method and I want to use it in a client program, I need to regenerate proxy classes .
So, I found CXF DynamicClientFactory , this method avoids the use of proxy classes:
import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.dynamic.DynamicClientFactory; //... //create client DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient("http://www.example.org/MyService/wsdl/myservice.wsdl"); //invoke method Object[] res = client.invoke("myWSMethod", "Bubi"); //print the result System.out.println("Response:\n" + res[0]);
But unfortunately, it creates and compiles proxy class classes, so it requires the JDK on the production machine . I must avoid this, or at least I cannot rely on him.
My question is :
Is there any other way to dynamically call any web service method in Java without using the JDK at runtime and without creating βstaticβ proxy classes? Maybe with a different library? Thanks!
source share