1

I have an WCF Data Service in .NET and I am consuming this service with datajs in Phonegap. I am trying to implement authentication as decribed here: http://goo.gl/0xQvC, and sending credentials with OData.read method. When I read credentials in the service with HttpContext.Current.Request.Headers["Authorization"], I found they are empty. What I am doing wrong?

Service Code:

[ServiceBehavior( IncludeExceptionDetailInFaults = true )]
    public class TeyunaDataService : DataService< Meteora.TeyunaServices.Models.TeyunaContext >
    {
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("Clientes", EntitySetRights.AllRead );
            config.SetEntitySetAccessRule("Transacciones", EntitySetRights.All);

            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            config.UseVerboseErrors = true;
        }

        public TeyunaDataService()
        {
            this.ProcessingPipeline.ProcessingRequest += new EventHandler<DataServiceProcessingPipelineEventArgs>(OnRequest);
        }

        void OnRequest(object sender, DataServiceProcessingPipelineEventArgs e)
        {
            var auth = HttpContext.Current.Request.Headers["Authorization"]; //This is empty                
        }
    }
}

Javascript Client code:

OData.read({ requestUri: url, user: "pruebausr", password: "passprb" },    
    function (data, request) {
        // ... code to procesing data (It works fine)

    },  function(err) {
            $.mobile.hidePageLoadingMsg();
            alert("Error al obtener clientes. " + err.message);
    }
);  

Service web.config here: https://gist.github.com/3746043

I am using: WCF Data Services 5. IIS Express.

DeanOC
  • 7,142
  • 6
  • 42
  • 56
Jorge
  • 67
  • 9

0 Answers0