XRemotingProxyFactory factory = new XRemotingProxyFactory("http://yourhost.com/your-service");
YourService yourService = (YourService) factory.create(YourService.class);
System.out.println(yourService.sayHello("Santa Claus"));
Examples shown above are for the basic case which is described as follows:
- XStream is used as a Serializer (XStreamSerializer)
- Default machinery based on URL.openConnection() is used as a transport (implemented by HttpRequester)
There's an alternative Requester implementation: CommonsHttpClientRequester which uses HttpClient under the covers. You may first intialize the client (including proxy, ssl configuration and other things) and then use that implementation:
HttpClient httpClient = new HttpClient();
// ... configure httpClient ...
Requester requester = new CommonsHttpClientRequester(httpClient, "http://yourhost/your-service");
You can then feed this Requester to XRemotingProxyFactory constructor.
There's a helper class called HttpClientBuilder which is aimed to aid constructing HttpClient instances.
For more information on implementing your own Requester, see Extending
You can also override a Serializer. Please note that you should use the same Serializer implementation (or at least compatible ones) on both sides: on your server and on the calling side.
For more information on implementing your own Serializer, see Extending
See SpringIntegration to get information on how to invoke your service exposed via XRemoting using Spring Framework.