?
Solved

wcf, jquery call

Posted on 2013-10-23
7
Medium Priority
?
368 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
  • 4
  • 2
7 Comments
 
LVL 54

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
Independent Software Vendors: 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!

 
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

Industry Leaders: 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

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 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