Search code examples
c#asp.net.netwcfaccess-denied

Access denied - while calling wcf service


I have a wcf service and I am calling it from another website.

The service is doing some decoding job.

The problem happening is :

For a few vehicle, the data is decoded very well, but for a few vehicle is is showing error.

Error code : 500 Error Message : Failed Authentication + Access denied

I have added a screen shot of the error.

NOTE : For some vehicle it is working fine. enter image description here

AS it is working for a few vehicle, I dont think it is an issue with code of decoding.

Please suggest what could be the issue here..

Code to access the service is :

function ResetValues(infoType)
{
    var $jDecode = jQuery.noConflict();
    var decoderUrl = $jDecode("input[id*=hdnVINDecoderURL]").val();
    var vin = $jDecode("input[id*=txtVIN]").val().toUpperCase();
    var styleId = null;
    var trim = $jDecode("#lbTrimRecords").val();

    if(trim != null)
    {
        styleId = trim.substring(trim.lastIndexOf("(") + 1, trim.lastIndexOf(")"));
    }

    //Declaring parameter to be passed to the called function.
    var paramList = '{"vin":"'+vin+'","styleID":"'+styleId+'","infoType":"'+infoType+'"}';

    //To show the loading image
    document.getElementById('imgLoading').style.visibility = 'visible';

    try
    {
        $jDecode.ajax({
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            url: decoderUrl + 'GetFactoryInformation/' + vin + '/' + styleId + '/' + infoType,
            //data: paramList,
            dataType: 'jsonp',
            success: function(data) {
                dataObject = data;

Solution

  • The reason was a null value was coming and it was throwing exception.