c# - Simple WCF service throwing 404 not found error -


i trying create simple wcf service interact javascript ajax calls (rest), not working me, seems i'm lost:

service interface

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.servicemodel.web; using system.text;  namespace wcf.app {     [servicecontract]     public interface iservice1     {         [operationcontract]         [webget(             uritemplate = "getdata/{value}",              responseformat = webmessageformat.json,             bodystyle = webmessagebodystyle.wrappedrequest)]         string getempdata(string value);     } } 

implementation:

using newtonsoft.json; using system; using system.collections.generic; using system.data.sqlclient; using system.diagnostics; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.servicemodel.web; using system.text;  namespace wcf.app {     public class clocked     {         public string date { get; set; }         public string type { get; set; }     }      public class data     {         public string firstname { get; set; }         public string lastname { get; set; }         public string emailaddress { get; set; }         public string phonenum { get; set; }         public string image { get; set; }         public string title { get; set; }         public list<clocked> clocked { get; set; }     }      public class rootobject     {         public data data { get; set; }     }      public class service1 : iservice1     {         public string getempdata(string test)         {             try             {                 return " hello " + test;                 }                 catch (exception ex)                 {                     return "can not open connection! " + ex.message + "  connection: " + connetionstring;                 }             }             catch (sqlexception e)             {                 return e.message;             }         }     } } 

now when try call service using jquery ajax, throws 404 not found error.

js:

 $.ajax({                 url: "service1.svc/getdata/3046722425",                 type: "get",                 datatype: "json",                 success: function (data) {                     console.log(data);                 },                 error: function (xmlhttprequest, textstatus, errorthrown) {                     alert(textstatus);                 }             }); 

configuration:

<system.servicemodel>     <servicehostingenvironment aspnetcompatibilityenabled="false" multiplesitebindingsenabled="true"/>     <bindings>       <custombinding>         <binding name="basicconfig">           <binarymessageencoding/>           <httptransport transfermode="streamed" maxreceivedmessagesize="67108864" />         </binding>       </custombinding>             <webhttpbinding>         <binding name="basicconfig">           <security mode="none">             <transport clientcredentialtype="basic"/>           </security>         </binding>         <binding>           <security mode="transport">             <transport clientcredentialtype="none"/>           </security>         </binding>       </webhttpbinding>     </bindings>     <client/>     <services>         <service name="wcf.app.service1" behaviorconfiguration="servicebehaviour">           <!--<endpoint address="custombinding" binding="custombinding" bindingconfiguration="basicconfig" contract="wcf.app.iservice1"/>-->           <endpoint address="" binding="webhttpbinding" behaviorconfiguration="rest" contract="wcf.app.iservice1"/>         </service>     </services>     <behaviors>       <servicebehaviors>         <behavior name="servicebehaviour">           <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>           <servicedebug includeexceptiondetailinfaults="true"/>         </behavior>         <behavior name="rest">           <servicemetadata httpgetenabled="true" httpsgetenabled="true" />           <servicedebug includeexceptiondetailinfaults="true" />         </behavior>       </servicebehaviors>       <endpointbehaviors>         <behavior name="servicebehaviour">           <webhttp helpenabled="true" defaultoutgoingresponseformat="json"/>         </behavior>         <behavior name="rest">           <webhttp helpenabled="true" defaultoutgoingresponseformat="json"/>         </behavior>       </endpointbehaviors>           </behaviors>   </system.servicemodel> 

please make sure you've activated wcf components here.

http error 404.3 - not found" while browsing wcf service on windows server 2008(64bit)


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -