HTTP HEADER in a webservice call RRS feed

  • Question

  • I have to access a web service having a mothod namely Notificationservice and it is guarded by authentication code that requires the specification of 3 HTTP (N.B. not SOAP) Headers.The required headers are:
    Header              Expected Value
    ACCOUNTID      The unique Account ID assigned to a customer. This value will be a long Integer (64 bit) value.
    USERNAME        The user name of a valid User Account in the for the Account specified by the  ACCOUNTID header.
    PSWD               The password for the User Account specified in the USERNAME Header.

    The Notificationservice operation requires two input parameters, which serve to identify the requesting
    interface. Both input parameters are required and will be provided by us during interface provisioning.
    Parameter                             Expected Value Type                                                                                                                                    accountID                              Long integer
    InterfaceID                            GUID

    And I am try to acess the webservice method by the follwoing console application code                                                                             using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://.../WebServices/NotificationService.asmx");
    webRequest.Headers.Add("ACCOUNTID", "123");
    webRequest.Headers.Add("USERNAME", "myusername");
    webRequest.Headers.Add("PSWD", "321");

    ServiceReference1.NotificationServiceSoapClient res = new ServiceReference1.NotificationServiceSoapClient();
    ConsoleApplication1.ServiceReference1.ResidentNotification[] doc = res.GetPendingResidentNotifications(1, System.Guid.NewGuid());

    here i am getting the follwing error while executing my sample console application                                                                             Error:"The HTTP request is unauthorized with client authentication scheme 'Anonymous'.               
    The authentication header received from the server was "

    Can any one correct my code,

    Thanks, Vasantha Prabakaran
    • Moved by Paul Zhou Tuesday, November 29, 2011 5:06 AM move for better support (From:.NET Base Class Library)
    Monday, November 28, 2011 8:13 AM


  • Hai,

    We solved this issue. Here we found some parameter mismatch with the input schema. After adding the parameter correctly the issue fixed.

    But i am wondering the error says some authentication error instead of a format mismatch with the request message.It breaks my head more then a day



    Thanks, Vasantha Prabakaran

    Friday, May 4, 2012 9:16 AM