Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking WCF service method through a browser

I've a WCF service which uses basic http binding. How do I invoke its operations/methods through a browser?

like image 663
Steve Chapman Avatar asked Apr 29 '09 14:04

Steve Chapman


People also ask

How can I access WCF service?

With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.

How do I hit a WCF service?

1.) Right-click on the 'My Service Projects' tree node in WCF Test Client, and click 'Add Service'. 3.) Invoke a method on it as you would have done a local service, then track in Fiddler and add to Postman as per the steps above.


1 Answers

You would need to add WebGetAttribute to your method like following sample

[OperationContract] [WebGet(UriTemplate = "/placesList/{userId}", ResponseFormat = WebMessageFormat.Xml)] List<Places> GetAllPlacesForUser(String userId) {   string xml = "";   // build xml here   return xml; } 

Now in the browser, you could invoke the method like this

http://localhost:8085/GeoPlacesDataService/placesList/10
where 10 is the userId parameter.

Note: In order to add WebGetAttribute you have to reference System.ServiceModel.Web namespace which is found in a separate assembly

like image 70
Jalal El-Shaer Avatar answered Sep 28 '22 03:09

Jalal El-Shaer