tags:

views:

1382

answers:

2

I am trying to setup a WCF service with multiple endpoints with one of the endpoints using the enableWebScript endpoint behavior so that a Javascript proxy will be created on the client (jsdebug/js).

When adding the Service Reference to my AJAX ScriptManager, the jsdebug file is not found unless the address of the endpoint is blank. The ScriptManager proxy seems to always generate a path of "MyService.svc/jsdebug" to look for the file even though my service has an address of "ajax". The proxy should generate the path as "MyService.svc/ajax/jsdebug".

Is there a setting to get the Proxy generated with the right path? My service is at the root of my website.

works:

<endpoint address="" 
  behaviorConfiguration="ajaxBehavior" 
  binding="webHttpBinding" 
  bindingConfiguration="webBinding" 
  contract="MyTest.Web.ICustomerService" />

want this (doesn't work):

<endpoint address="ajax" 
  behaviorConfiguration="ajaxBehavior" 
  binding="webHttpBinding" 
  bindingConfiguration="webBinding" 
  contract="MyTest.Web.ICustomerService" />
+1  A: 

<enableWebScript /> also known as AJAX-enabled endpoints essentially hard-codes everything to do with address so you can generate the client-side code.

The way it's hard-coded is that everything is directly relative to the .svc file.

See How to: Use Configuration to Add an ASP.NET AJAX Endpoint

The endpoint is configured at an empty address relative to the .svc file, so the service is now available and can be invoked by sending requests to service.svc/<operation> - for example, service.svc/Add for the Add operation.

For this reason, you can't mix <enableWebScript /> with UriTemplate, which takes away half the fun out of WCF in my opinion. See enableWebScript, UriTemplate, and HTTP methods.

Personally, I like to configure my URI and serve both POX and JSON, as well as SOAP. See WCF RESTful POX, JSON and SOAP Coexist.

eed3si9n
A: 

In the ScriptManager, put MyService.svc/ajax instead of MyService.svc