I have a third-party web service that I need to use. The calls to it will be something like this: https://somesitename.com/Service.dll?[operation]?[parameter1]&[parameter2]
It returns various XML structures depending on the operation called and the results of the operation. It can be as simple as this:
<?xml version="1.0"?>
<RESULTS>
<VALUE>some return value here</VALUE>
</RESULTS>
Or for a call that returns slightly more complex data, it could be like this:
<?xml version="1.0" ?>
<RESULTS>
<RETURN>
<RESPONSEMSG>Some message.</RESPONSEMSG>
</RETURN>
<DATA>
<COUNT>1</COUNT>
<VALUE1>1</VALUE1>
<VALUE2>1</VALUE2>
<VALUE3>FALSE</VALUE3>
</DATA>
</RESULTS>
If that call had errored instead, it would just return something like:
<?xml version="1.0" ?>
<RESULTS>
<RETURN>
<ERROR>Error Message.</ERROR>
</RETURN>
</RESULTS>
So, basically I'm just trying to consume the XML response from a REST service. There is no data contract for it, and all I have to go on is the example responses that were provided to me. Should I build poco classes for each type of result? I'm thinking that I would use HTTPClient or WebClient to make the requests to the service. Then I'd need to somehow deserialize the resulting XML into an object that I can return. Is there a best practice or pattern for this kind of thing? Any advice would be appreciated, thanks!