views:

3366

answers:

3

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

A: 

Please look at this.

Soul_Master
+2  A: 

I would recommend setting up multiple endpoints for the Service. Add an endpoint using webHttpBinding to get an XML version of the service. If this is done correctly the response you will get from the service is identical to the basicHttpBinding endpoint, but without the SOAP overhead.

Other than that, you can't call a SOAP web service directly from the browser because it requires a form post. You could use a tool to test it using SOAP though, I recommend Soap UI. Its written in Java but I try not to hold that against it. :)

Steve
+2  A: 

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

jalchr