• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

wcf, jquery call

Please review the attachment.

The wcf is working fine by calling soap. I have a codes in mvc controller and it works fine.

My goal is to consume wcf by jquery. and I try to html codes (see attached)
and it always come up with 404 error.

No idea how to fix and need some expects instruct me...thank.

The attachment sample is very straight forward - just say Hello method
  • 4
  • 2
1 Solution
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
In your wcf code, do you need to have the address?  Your jquery code is pointing to http://localhost:24860/Service.svc/sayHello


Open in new window

solution1368Author Commented:
Please tell me how to fix it
I know it has no address but why soap call is still working without any address?
solution1368Author Commented:
I added or http://localhost:24860/Service.svc/sayHello or
http://localhost:24860/Service.svc to the endpoint address and it is still not working.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Miguel OzSoftware EngineerCommented:
Q1. Where is the WCF hosted? e.g. Inside your web site.
Q2. Are all WCF methods return JSON data? By default it is JSON if no attribute is defined.
Q3. Why do you need serviceBehaviors node in your web.config file? the typical WCF asmx compatible web service does not need it. Please delete this node and try again.

The JS code looks OK. I will change ServiceSucceeded for IE only if your current code does not work in IE:
        function ServiceSucceeded(result) {
            var resultObject = result.d;
            Log("Success: " + resultObject);

Open in new window

solution1368Author Commented:
All are in one develop environment. hosting in IIS in one pc.
yes return json data
q3: I don't understand what you want me to delete.
Miguel OzSoftware EngineerCommented:
Q3:  refer to serviceBehaviors element.
Please delete this from web.config file
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"  />
          <serviceDebug includeExceptionDetailInFaults="false" />

and update your service attributes to: (delete behaviorConfiguration attrib)
      <service name="MyService">

Open in new window

solution1368Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now