Saturday, March 24, 2012

WCF and ASP.NET 3.5 RTM integration on different sites - 404 errors

Hello,

Setup 1:

Project with WCF service in it .svc file has Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory", web.config does not include <system.ServiceModel> junk. We've got your standard config-free json service that has been hyped. VS 2008 web dev server url (simplicity sake here):http://localhost:1/service.svc

Seperate Project with ASP.NET application in it. ScriptManager has a service reference to the above svc file at (http://localhost:1/service.svc). Javascript on the page invokes a method in the service. VS 2008 web dev server url (simplicity again):http://localhost:2/webform.aspx

Runtime 1:

    JS "proxy class" is successfully downloaded from the service (http://localhost:1/service.svc/jsdebug)

    JS Object contructed from the proxy class.

    Error on invocation of service method - 404 not found!

    Fiddler says proxy class is invoking the service athttp://localhost:2/service.svc/myServiceMethod. Please note the port there, it should behttp://localhost:1 not 2! 2 is the site where the webform is being hosted at.

Config 2:

Move the WCF project onto local IIS 7.0 (Vista).

Update script reference to the service tohttp://[machinename]/serviceVD/service.svc

Runtime 2:

    JS "proxy class" is successfully downloaded from the service (http://[machinename]/serviceVD/service.svc/jsdebug)

    JS Object contructed from the proxy class.

    Error on invocation of service method - 404 not found!

    Upon inspection the proxy class is invoking the service athttp://localhost:2/serviceVD/service.svc/myServiceMethod. Please note the port there, it should behttp://[machinename]/serviceVD nothttp://localhost:2! Again the root of the url is being pulled from where the webform is being hosted.

All the references I've seen and have gotten to work include the WCF service in the same project as the webform that is calling them. How do I call remote service on another site or machine?

Not sure if it will help but it hass some good info of Asp.net Ajax with WCF by Dino Esposite
http://dotnetslackers.com/articles/ajax/JSON-EnabledWCFServicesInASPNET35.aspx

No comments:

Post a Comment