开发者

How to perform GET web requests to WCF Service Without WCF Client?

I want to send a GET web Request to a WCF service: for example to: http://TheirServerIP:PortNumber/TheirSe开发者_StackOverflow社区rvice/TheirServiceName.svc?op=theirWCFmethod

i want to write a C# code in my page (web aplication) that send HTTP GET request to their service (without WCF Client)

can i do that ?


To create a WCF service that responds to HTTP GET or HTTP POST requests http://msdn.microsoft.com/en-us/library/bb628610.aspx


Well, in that case, you need to create a WCF REST service, one that can be called from any language using any HTTP stack and no need for any WCF specifics.

Check out the WCF REST developer center for lots of great info on WCF REST services.

Basically, what it boils down to is

  • using the WebHttpBinding on your server side
  • defining a URL pattern to handle requests and their parameters

For the client part of this, use the answer Ladislav provided - just new up a HttpRequest object and make a HTTP GET request to a valid URL - that's all there is, really.


The basic approach to call HTTP resource is:

var request = HttpWebRequest.Create("YourURL");
request.Method = "GET";
var response = request.GetResponse();
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜