开发者

Problem getting claims to WCF service with Silverlight client

I have a Silverlight client application which logs开发者_StackOverflow on to an STS and gets a collection of claims in return. I use the Silverlight IdentityModel which came with the Identity Training Kit. This works fine.

The problem is when I do a service call (for getting some data), within the service I can see an identity of type IClaimsIdentity, but its claims collection is empty. The service is called by using the ClaimsIdentitySessionManager InvokeAsync method so the IssuedToken information is added to the SOAP header. The service call is executed within the context of the session manager.

I tried different kinds of code and settings, but I cannot get the claims to the service. I’ve read that it should work by using a CustomBinding, but when using it I get an error: Content Type text/xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched.

I even tried using ‘TextMessageEncoding’ instead of ‘BinaryMessageEncoding’ with different message versions, but it didn’t help.

What does this error mean and how can I solve this?

Code used to call WCF service:

private void GetWeekPlanning()
{
   var service = _ServiceManager.GetServiceDescriptionAndCheckNull(typeof(ILeisureServiceAsync), ServiceTransportType.BasicHttpBinding);

   var binding = new CustomBinding()
   {
      Elements = { new BinaryMessageEncodingBindingElement(), new HttpsTransportBindingElement() }
   };

   var proxy = new LeisureServiceAsyncProxy(binding, service.ServiceEndpointAddress);

   ClaimsIdentitySessionManager.Current.InvokeAsync(
      () =>
      {
         proxy.BeginGetActivityPlanListByDate(
            DateTime.MinValue,
            DateTime.MaxValue,
            result =>
            {
               var plans = proxy.EndGetActivityPlanListByDate(result);

               SynchronizationContext.Post(
                  callback =>
                  {                           
                     // Do something with plans
                  },
                  null);
            },
            null);
      },
    proxy.InnerChannel,
    WSTrust13Constants.KeyTypes.Bearer);
}

Code snippet from the server App.config: http://pastebin.com/7RmPQVUR

The client web.config: http://pastebin.com/Bz9W6mUj

Kind Regards,

Hans

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜