Authenticated WCF service that returns JSONP

Posted: November 11, 2011 in .NET
Tags: , ,

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

Advertisement
Comments
  1. Cory says:

    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

  2. Ringo says:

    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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s