Today I was challenged with creating an authenticated, cross-domain, WCF service that returns JSONP.
Using the ‘out of the box’ WCF configurations this is not possible. If you attempt to use authentication with an endpoint that allows cross-site scripting, you will recieve an error message like this -
Cross domain javascript callback is not supported in authenticated services
To get around this restriction (It’s not a bug) we can use a custom encoder factory/binding/etc…
In my application, I am using the sample JSONP library that was provided by Miscrosoft.
http://msdn.microsoft.com/en-us/library/cc716898(v=VS.90).aspx
Then added the appropriate authentication requirement in the web config.
<customBinding>
<binding name=”jsonpBinding”>
<jsonpMessageEncoding/>
<httpTransport manualAddressing=”true” authenticationScheme=”Negotiate” />
</binding>
</customBinding>
If anyone needs help with this, First try to implement the JSONP library from Microsoft and let me know if you get stuck. I’ll try to help you configure your app.
http://msdn.microsoft.com/en-us/library/cc716898(v=VS.90).aspx
I would be very interested in seeing the code/markup for this. I’m fairly green when it comes to WCF, and this would really help me fix my current issue
Thanks much,
Cory
I’ll send you an email.
Thanks much, for the help! Just as a followup, I had to include:
The (authenticationScheme=”Negotiate”) segment fixes the anonymous access issue I was having and supports NTLM Auth.
Thanks again!
Welcome. Glad I could help!
Hello,
Can you send me also your solution/code about the authentication of the WCF webservice with JSONP.
I would be very glad.
Thanks
Ringo
Try to implement the JSONP library from Microsoft and let me know if you get stuck. I’ll try to help you configure your app.
http://msdn.microsoft.com/en-us/library/cc716898(v=VS.90).aspx
When I get more time, I will create a solution that demonstrates this.