Solved

wcf, jquery call

Posted on 2013-10-23
7
318 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 52

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 35

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 35

Accepted Solution

by:
Miguel Oz earned 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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)

803 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