Acting as a proxy for web service calls
James Berry <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
I have a .net 2.0 client that talks to a .net 2.0 web service. The
prototype for two of the web methods are approximately this:
bool Send(string destination, SendData a);
SendResult Receive(string source);
SendData might be defined:
public class SendData {
public string A;
public string B;
}
And SendResult might be defined:
public class SendResult {
public string X;
public string Y;
}
This works very nicely, and is fairly standard. However, I now have to
produce a proxy web service that can forward results to different web
servers based on the destination/source parameter to the web method. It
needs to be completely transparent to the client. It also needs to be
forward compatible so that web services can be upgraded to include extra
parameters in SendData/SendResult in the future without having to roll
out a different proxy.
My first attempt was to build a web service like this (in exactly the
same namespace)
bool Send(string destination, XmlDocument a);
XmlDocument Receive(string source);
I was hoping that the XmlDocument would contain the entire xml
represending the SendData when Send was called, and then I could call
the other web service. However, the document "a" above, only contained
the element for the string "A".
For my next attempt, I implemented a .ashx HttpHandler, and read the
entire post data for the web service, used an XmlDocument to retrieve
the appropriate parameter, and forwarded the request using
HttpWebRequest. This works, but feels a little bit complex.
Can anyone offer any guideance as to whether my solution is appropriate,
or whether there is an "easier" way to implement this proxy?
Best wishes
James
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com