Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dynamic proxy soap web service client in java?

Is there any way to use soap-rpc web services such that the client is generated via a shared interface? Restful web services do it this way, but what about soap based? Do you always have to use a tool like Axis or CXF to generate your stubs and proxies, or is there something out there that will set it up dynamically?

Thanks.

EDIT #1:

To clarify, I'm looking to do something like this:

Common interface:

@WebService
public interface MyWebService {

   @WebMethod
   String helloWorld();
}

This common interface can already be used to create the server side component. My question is: can this type of common interface be used on the client side to generate dynamic proxies? Restful web services do it this way (Restlets & CXF) and it seems the .Net world has this type of functionality too.

like image 810
javamonkey79 Avatar asked Jun 23 '11 00:06

javamonkey79


3 Answers

I would see this tutorial of JAX-WS useful for your purposes:

In the example code the Web Services Client is configured by adding an annotation @WebServiceRef with a property pointing to the WSDL location to the client implementation class and no tools are needed to access the stuff from the Web Service that is referenced.

Was this the way you would like to have it, or did this even answer to right question?

like image 76
mico Avatar answered Oct 22 '22 03:10

mico


Not exactly sure what you're looking for, but if you don't want to rely on JAX-WS/JAXB-generated artifacts (service interfaces and binding objects), you can make use of the Service and Dispatch APIs. For example:

QName serviceName = new QName(...);
Service service = Service.create(serviceName);
QName portName = new QName(...);
String endpointAddress = "...";
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
SOAPMessage request = ...;
SOAPMessage response = dispatch.invoke(request);
like image 2
kschneid Avatar answered Oct 22 '22 05:10

kschneid


Check Apache CXF. Configuring a Spring Client (Option 1).

like image 2
Grigoris Grigoriadis Avatar answered Oct 22 '22 03:10

Grigoris Grigoriadis