?
Solved

wcf, jquery call

Posted on 2013-10-23
7
Medium Priority
?
342 Views
Last Modified: 2016-02-26
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
MVCView.txt
wcf.txt
0
Comment
Question by:solution1368
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39597353
In your wcf code, do you need to have the address?  Your jquery code is pointing to http://localhost:24860/Service.svc/sayHello

<endpoint 
          address="" 
          binding="webHttpBinding" 
          contract="MyService" 
          behaviorConfiguration="EndpBehavior"/>

Open in new window

0
 

Author Comment

by:solution1368
ID: 39597523
Please tell me how to fix it
I know it has no address but why soap call is still working without any address?
0
 

Author Comment

by:solution1368
ID: 39598798
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.
0
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 
LVL 36

Expert Comment

by:Miguel Oz
ID: 39599009
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

0
 

Author Comment

by:solution1368
ID: 39599027
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.
thanks
0
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 39599407
Q3:  refer to serviceBehaviors element.
Please delete this from web.config file
<serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"  />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>

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

Open in new window

0
 

Author Closing Comment

by:solution1368
ID: 39634640
work!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question