The situation is I have multiple webservices for which I need send request and get a response. I want to implement a generic method to call the webservi开发者_StackOverflowces and get a response. Is it possible to implement a generic method to call any webservice in C# (.net framework 3.5/4.0).
Thanks
You could do it by manually assembling the SOAP XML for a .NET Web Service, but I sure wouldn't want to.
Use SOAP UI to create a test request / response and modify the XML it creates to suit your needs. Then submit that request to the web service using WebClient.
You could have a generic method that does accepts XML as input and returns XML as a result, but you'd still have to parse the XML on a method by method basis.
If your webservices are RESTful you can do that. Your request might respond as XML or JSON. There are other ways but not so straightforward.
精彩评论