I'm slight confused on how to do this. I've followed some examples after searching but still cant get this working then again most examples seem to target Json (not sure if that would make a difference).
Im using basicHttpBinding.
So i have a simple Interface:
<ServiceContract()>
Public Interface ICustomersService
<OperationContract()>
<WebGet(UriTemplate:="SaveName/{name}")>
Sub SaveName(ByVal name as string)
Next i create my hosting application which works and i can reach the WSDL page and can view SaveName.
The current URL is http://example.com/
I would like to pass in a name which then saves to the database. Im expecting the URL to be along the lines of
http://example.com/SaveName?name="Tony"
That doesnt work so i tried a couple of variations using standard query string parameters but non work.
Am i doing something wrong or is there a step missing?
To use the WebGet
/ WebInvoke
attributes, you cannot use a basicHttpBinding
(or, you can use it, but those attributes will be ignored). BasicHttpBinding is one of the bindings that use the SOAP protocol, and it has some strong requirements regarding the format of the message (in a nutshell, almost everything goes in the request body, and some addressing parameters may go in HTTP headers).
To be able to define your endpoint operations using the WebGet
attribute, your endpoint needs to use the webHttpBinding
, and it also needs to have the <webHttp/>
behavior applied to it (WebHttpBehavior
, if you're defining your endpoint via code).
One more thing worth pointing out: if you use a "web" endpoint, the WSDL will not have all the information that you need to connect a client to it, so you won't be able to use the "WCF test client" to talk to it. More information about it at this blog post.