tags:

views:

63

answers:

3

I want to send a GET web Request to a WCF service: for example to: http://TheirServerIP:PortNumber/TheirService/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 ?

+1  A: 

The basic approach to call HTTP resource is:

var request = HttpWebRequest.Create("YourURL");
request.Method = "GET";
var response = request.GetResponse();
...
Ladislav Mrnka
If there is no authentication on the service and you are just dumping xml content, you may just be able to use the XmlReader as well.
Matthew Whited
Thanks guys, just to make things clearer:I need to create a web service and i want to create it in WCF.i need to give another company a code sample of how to use my service.They Didn't write WCF and they don't know it.They want to access my WCf service with http GET.can they access my WCF Service just like they did with my previous asmx service ? do they have to write WCF CLient for that?
Rodniko
So are you going to build REST or SOAP service? How did the company accessed your previous ASMX services? You can create WCF SOAP service exposed on BasicHttpBinding and they will be able to consume it in exactly same way as they consumed your ASMX service.
Ladislav Mrnka
In the past, The other company accessed my asmx with HTTP GET, They don't use SOAP, only HTTP GET (they use Javascript or JQuery),That is the reason i'm trying to find a way for them to access my WCF Service With HTTP GET.Can i make my WCF Service a WCF REST service? and that way give them access to my WCF service using HTTP GET?
Rodniko
Yes you can create WCF Rest service which can be consumed from javascript or from .net code. But this question is far away from question you have asked in this thread.
Ladislav Mrnka
A: 

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.

marc_s
A: 

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

BugsBUggy