dimanche 21 octobre 2018

Invoke different version of SOAP API (no code duplication)

I need to write a java client to invoke some SOAP APIs exposed by an application.

The client should be able to connect to different version of the same application which exposes different version of the APIs and so different WSDL. I've different packages for the stubs classes generated, one for each version of the wsdl. The client code that invoke the APIs is the same across the different version of the API. How can I implement the client logic without duplicate the code for each version of the api?

For example if the client logic is:

callStubMethodApiFoo() callStubMethodApiBar()

My solution is to have two client implementation one for APIv1:

com.application.api.v1.stub.Client.callStubMethodApiFoo() com.application.api.v1.stub.Client.callStubMethodApiBar()

and one for APIv2:

com.application.api.v2.stub.Client.callStubMethodApiFoo() com.application.api.v2.stub.Client.callStubMethodApiBar()

Is it possible to have no duplicated code that reference the right stub class/methods for the needed API version at runtime?

Thanks

Aucun commentaire:

Enregistrer un commentaire