Hello,
I'm trying to learn how to create a json REST webservice and starting off with a simple example ... but can't get it to function. This is what I get when attempting to call it with a cUrl ...
curl -X GET -v http:
Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8733 (#0)
> GET /Design_Time_Addresses/HelloService/HelloService/GetData/value/334 HTTP/1.1
> Host: localhost:8733
> User-Agent: curl/7.55.1
> Accept: *
If it matters I am running/serving the service using "debug mode" which calls the WCF Test Client application.
Can anyone please tell me why it thinks I should be asking for a POST?
What I have tried:
Here are my HelloService.VB, IHelloService.VB and my App.Config files:
IHelloService.vb
<ServiceContract()>
Public Interface IHelloService
<OperationContract()>
Function GetData(ByVal value As String) As String
End Interface
HelloService.vb
Public Class HelloService
Implements IHelloService
<WebInvoke(ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json, Method:="GET", UriTemplate:="value/{value}")>
Public Function GetData(ByVal value As String) As String Implements IHelloService.GetData
Return String.Format("You entered: {0}", value)
End Function
End Class
app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<services>
<service name="HelloService.HelloService">
<endpoint address="web" behaviorConfiguration="JsonBehavior"
binding="webHttpBinding" contract="HelloService.IHelloService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/HelloService/HelloService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>