Solved

wcf, jquery call

Posted on 2013-10-23
7
333 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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
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 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…

690 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