Why is my POST method not working?

I have a WCF service contract:

[ServiceContract]
public interface IVLSContentService
{
    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, UriTemplate = "GetCategoriesGET/{userIdArg}", BodyStyle = WebMessageBodyStyle.Bare)]
    List<Video> GetVideosGET(string userIdArg);

    [WebInvoke(Method = "POST",BodyStyle=WebMessageBodyStyle.Wrapped, UriTemplate = "submit")]
    [OperationContract]
    void SubmitVideoPOST(Video videoArg, string userId);
}

And I have a service that implements a contract:

public class VLSContentService : IVLSContentService
{

    List<Video> catsForUser1 = new List<Video>();
    List<Video> catsForUser2 = new List<Video>();

    public List<Video> GetVideosGET(string userIdArg)
    {
        List<Video> catsToReturn = new List<Video>();

        if (Int32.Parse(userIdArg) == 1)
        {
            catsToReturn = catsForUser1;
        }
        else if (Int32.Parse(userIdArg) == 2)
        {
            catsToReturn = catsForUser2;
        }

        return catsToReturn;
    }


    public void SubmitVideoPOST(Video videoArg, string userId)
    {
        int i = 0;
    }
}

And I have a configuration:

  <system.serviceModel>

    <services>
      <service behaviorConfiguration="VLSContentServiceBehaviour" name="VLSContentService">
        <endpoint address="" behaviorConfiguration="VLSContentServiceEndpointBehaviour" binding="webHttpBinding" contract="IVLSContentService"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="VLSContentServiceBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
        <behavior name="VLSContentServiceEndpointBehaviour">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

  </system.serviceModel>

And I'm trying to invoke a WCF POST operation with the following client code:

static void Main(string[] args)
{
    WebChannelFactory<IVLSContentService> cs = new WebChannelFactory<IVLSContentService>(new Uri("http://localhost:52587/Api/Content/VLSContentService.svc/SubmitVideoPOST"));
    IVLSContentService client = cs.CreateChannel();

    Video videoToAdd = new Video("My First Video");

    client.SubmitVideoPOST(videoToAdd,"1");

}

But I get this error and I can not understand why:

There was no endpoint listening http: // localhost: 52587 / Api / Content / VLSContentService.svc / SubmitVideoPOST / submit which could receive the message. This is often caused by an incorrect address or SOAP. See InnerException, if present, for more details.

, GET URL-, . xml, POST . Ive , .svc - ...

- ?

+3
2

,

http://localhost:52587/Api/Content/VLSContentService.svc/submit

UriTemplate ,

http://localhost:52587/Api/Content/VLSContentService.svc

WebChannelFactory cs = new WebChannelFactory ( Uri ( "http://localhost: 52587/Api/Content/VLSContentService.svc/" ));

+3

, URL. , "/SubmitVideoPOST/submit", UriTemplate "/submit".

.NET URL- REST. UriTemplate . WCF REST UriTemplate.

+3

All Articles