Saturday, April 4, 2015

When wrapping a SOAP API with your own API, the versioning may present a challenge.

Let's say you wish to expose an API that needs to talk to an API itself. Let's say the other API is a SOAP API and this other thing just offers a different WSDL for each version of its service and whenever there is to be a new version there will be a new WSDL. This makes it painful to wrap. The other option this third party would have had would have been to consume an XML packet as a serialized string which could then be upwards compatible by being capable of being flexible to take in really any settings and also a version number in that packet in the name of making sense of the packet. Alright, well if they aren't going to do it I guess we have to. I have recently put together some code for this which uses:

  1. Xsd2Code++
  2. XmlDocument
  3. Activator.CreateInstance
  4. dynamic

I envision a wrapper class using an instance of a generic parent class that is an upcasting of a version-specific class to call a web service before/after it does whatever else it needs to do (no one writes a wrapper just to wrap, right?) as seen in my goofy notes here:

 
 

This is done and works, but I don't like that I have to populate the meat of the child in child-specific code. I'm going to try to making things better by overriding a virtual method as seen below so that the parent may give its kids data upstream of the kids doing their own thing. That is the next step I think. I guess I must like my job if I'm off work daydreaming of what I'll do as soon as I get back.

No comments:

Post a Comment