1
votes

I've been building a WCF web-service and am stucked at Post & Put methods. These methods aren't working whereas Get method and Delete method works fine and provides correct output. I've provided .edmx in it and connecting to database using it. Tried to write many lines in WebConfig to make it work but none worked. Hope to get a solution from here. Thanks in advance.

My IService.cs class contains this : Iservice1.cs


 [OperationContract]
 [WebInvoke(Method = "Post", ResponseFormat = WebMessageFormat.Json, RequestFormat =     WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "Postmovie")]
 CompositeType PostUpdatemovie(MovieTbl tbl);

And Service.svc.cs contains this:

public CompositeType PostUpdatemovie(MovieTbl tbl)
        {
            CompositeType obj = new CompositeType();
            //objmovie.Status
            // objmovie.TorrentID  

            return obj;
        }
1

1 Answers

0
votes

try updating your webconfig like the following:

    <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="Default"
            name="Service1">
        <endpoint address="" behaviorConfiguration="webBehavior"
                binding="webHttpBinding"
                contract="IService1" />
        <endpoint address="/netclients"  bindingName="basicBinding" binding="basicHttpBinding" contract="IService1" />

        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicBinding" />
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp helpEnabled="true"  />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

and your method:

[OperationContract]
 [WebInvoke(Method = "Post", ResponseFormat = WebMessageFormat.Json, RequestFormat =     WebMessageFormat.Json, UriTemplate = "/Postmovie")]
 CompositeType PostUpdatemovie(MovieTbl tbl);