views:

957

answers:

1

I'm trying to make a WCF service that will work with JSON-P (long-story short, we have to call the web-service cross-domain and receive a call-back, so I need it to work with JSON-P).

I found a code-sample on MSDN (http://msdn.microsoft.com/en-us/library/cc716898.aspx). If I extract the ZIP file and navigate to Samples\WCFWFCardSpace\WCF\Extensibility\Ajax\JSONP\CS, I get a project in which certain bindings and extensions have been created, which would give WCF the capability of spitting out a call to a JS function after it returns the JSON.

Unfortunately, when I try to copy this code and implement it in my project it doesn't work.

I get the following error:

Configuration binding extension 'system.serviceModel/bindings/jsonpBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

It's as if the developers at Microsoft left out some vital piece of code that's required for this to work, and I'm not sure what they left out or what it's meant to do.

Has anyone had experience using WCF with JSON-P?

If there's a way to get this sample project working, I'm all-ears.

If there's an alternative way to do cross-domain web-service calls from Javascript to WCF, I'm also interested.

+1  A: 

Can you include your web.config file in your question?

The message that you are receiving is due to either a non-existent or invalid extensions element in your web.config.

verify the following

<system.serviceModel>
  <!-- client, behavior, and bindings -->   
  <extensions>
    <bindingElementExtensions>
      <add name="jsonpMessageEncoding"
           type="Namespace, Assembly, Version=X.X.X.X, Culture=neutral, PublicKeyToken=null"/>
    </bindingElementExtensions>
  </extensions>    
</system.serviceModel>
bendewey
nice answer, fixed my issue just now++
redsquare