Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
When I run My client application in Internet explorer, I got the output.

It called the service, but when I run the same client application in Google chrome and Firefox its getting 404 error.

Can you give some solution for the problem I am facing?

web.config

XML
<system.serviceModel>

      <services>
      <service name="WcfService3codepro.Service1" behaviorConfiguration="MyServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="WcfService3codepro.IService1" behaviorConfiguration="MyEndpointBehavior" />
      </service>
    </services>
    <bindings>

    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehaviour">
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>

    <endpointBehaviors>
        <behavior name="MyEndpointBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
        <defaultDocument>
            <files>
                <add value="Service1.svc" />
            </files>
        </defaultDocument>
  </system.webServer>

</configuration>


interface

C#
[OperationContract]
      [WebInvoke(Method = "*", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
      string MyFunction(string Count);
      // TODO: Add your service operations here
  }


class
C#
[AspNetCompatibilityRequirements(RequirementsMode
    = AspNetCompatibilityRequirementsMode.Allowed)]
   public class Service1 : IService1
   {
       public string MyFunction(string Count)
       {
           return "The Name you passed  is: " + Count.ToString();
       }

   }


client jquery code
XML
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" lang="ja">
        var counter = "karthik";

        function CallMyService() {
            $.ajax({
                type: "POST",
                url: "http://localhost/WcfService3codepro/Service1.svc/MyFunction",
                data: '{"Count": "' + counter + '"}',
                contentType: "application/json",
                success: ServiceSucceeded,
                error: ServiceFailed
            });
        }
        function ServiceFailed(result) {

            Log('Service call failed: ' + result.status + '  ' + result.statusText);
        }
        function ServiceSucceeded(result) {
            var resultObject = result.MyFunctionResult;
            Log("Success: " + resultObject);
        }

        function Log(msg) {
            $("#logdiv").append(msg + "<br />");
        }

    </script>
</head>

XML
<body>
    <form id="form1" runat="server">
    <div>
     <input id="Button1" type="button" value="Execute" onclick="CallMyService();" />
    <div id="logdiv"></div>
    </div>
        <asp:Label ID="lblmsg" runat="server" />
    </form>
</body>
Posted
Updated 1-Nov-13 1:55am
v3
Comments
Very less info. Please post the codes and try to explain what you want to achieve.
Prasad Khandekar 1-Nov-13 3:58am    
Hello Karthik,

Perhaps this article can provide you some help. (http://www.codeproject.com/Articles/132809/Calling-WCF-Services-using-jQuery)

Regards,

I was getting the same problem just 15 days before.
And i googled it so much and found that it may work if i hosted it on IIS server.
try hosting that in IIS and check what happens.

And check the request header the request header might sending request with OPTION method instead of GET/POST.Try to explore on that also.
change your contract method to
C#
[WebInvoke(Mehtod="*",...]


Hope This Helps You.
-----------------------
Pratik Bhuva
 
Share this answer
 
Comments
karthik mushyam 1-Nov-13 7:17am    
i tried it but no solution
Pratik Bhuva 1-Nov-13 9:01am    
Have you Hosted on IIS???
karthik mushyam 3-Nov-13 23:33pm    
ya i have Hosted ...sorry for the delay ..
This problem also same behaves like below url. which question is posted by you

calling wcf service Endpoint not found[^]

please check your answer given link
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900