tags:

views:

180

answers:

6

this occured when I called my WCF Service

as follows:

  1. hosted WCF Service in IIS in name 'testWCF'.
  2. web application name is 'webWCF'.

gave scriptreference as :"http://localhost/testWCF/mywcf.svc"

In JavaScript called the method 'GetSerivceCharge' as

var x = new thetest.Backoffice.IBackofficeService();
var y = x.GetSerivceCharge(res);
function res(result) {
    alert(result);
}

it results as follows:

Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSerivceCharge' failed with the following error: Not Found

Server Error in '/webWCF' Application.


HTTP Error 404 - Not Found.


A: 

Isn't this a cross domain issue? I see that your WCF web service is hosted in IIS and accessible through http://localhost/testWCF/mywcf.svc while your web application is using the ASP.NET development server which means it is hosted on http://localhost:SOME_PORT/webWCF.

AFAIK, AJAX is used when you want to invoke a web service from javascript. Due to cross domain restrictions you need to have the web service and the web application hosted on the same domain, or create a some proxy/bridge that will delegate calls to the web service.

Darin Dimitrov
A: 

Try typing the web service URL directly into your browser's address bar and see what happens.

John Saunders
A: 

Maybe it's this dumb: GetSerivceCharge is misspelled. Try GetServiceCharge. And if that's not it, you should post your web method's signature.

Jacob
A: 

I am totally confused. I am able to access the http://localhost/testWCF/mywcf.svc in browser. I get Metadata page.

How to access it using javascript .I created proxy correctly. the method GetSerivceCharge() is the actual spelling i am using for my convenience.

how to get access to the WCF methods. IIS 1. WCF service --> testWCF 2. web application-->webWCF

given in scriptmanager servicereference as "http://localhost/testWCF/mywcf.svc"

created proxy as var x = new thetest.Backoffice.IBackofficeService(); var y = x.GetSerivceCharge(res); function res(result) { alert(result); }

when i trace in x i get the methods. but as far as y is concerned it states not found + server Error in /webWCF

when I host the Service inside webWCF I am able to consume it , but i dont want WCF and Site together.

I AM ASKING THE WAY TO CONSUME THE WCF SERVICE HOSTED IN IIS AS SEPARATE APPLICATION

A: 

I think you need to add a reference to your WCF in your project.

If you are using VS 2008 try adding a reference to your web service: In solution explorer right click on your project. Then select Add Service Reference. Then click on discover in the dialog that pops up and you should be able to find your WCF service.

shawn deutch
A: 

Hey balajisw, did the issue resolved? I'm having the same issue. Can you please post how it resolved.