Web Service throws 401 Error when consumed

Discussion in 'ASP .Net' started by Sanjay, Nov 18, 2003.

  1. Sanjay

    Sanjay Guest

    I have written a web service to return information from the database. This
    works and the data is returned in XML format from the database and displayed
    on the web page as well when this web service called getsampledata is
    invoked. Now I create a web page and created a webservice using the web
    reference technique in the VS .NET to consume this web service. The web
    page (application), web server, web service and database are on the same
    box. Here is where my problems start. I keep getting this error message
    reproduced here.

    System.Net.WebException: The request failed with HTTP status 401: Access
    Denied. at
    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
    Message message, WebResponse response, Stream responseStream, Boolean
    asyncCall) at
    System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    methodName, Object[] parameters) at
    WebPageWebServiceTest.HPSD.Service1.GetSampleData() in
    C:\Inetpub\wwwroot\WebPageWebServiceTest\Web
    References\HPSD\Reference.cs:line 40 at
    WebPageWebServiceTest.WebForm1.Button1_Click(Object sender, EventArgs e) in
    c:\inetpub\wwwroot\webpagewebservicetest\webform1.aspx.cs:line 69

    Name of the web page trying to consume the webservice =
    WebPageWebServiceTest
    Name of the webservice HPSD.Service1.GetSampleData().


    I have played around with the web config file and have the following working
    web.conifg parameters
    <authentication mode="None" />

    <identity impersonate="true" />

    Same parameters on both the web.config files ie on the web service and web
    page(application). The database has aspnet configured as a user. The
    following line is the connection string details on the webservice

    sqlConnectionString="Provider=SQLOLEDB.1;integratedsecurity=SSPI;Persist
    Security Info=False;Initial Catalog=XXX_DEV;Data Source=XXXX;

    I just am not able to get past the error noted above.

    I am wondering if anyone else has run into this problem. Any pointers/tips
    much appreciated.

    Thanks

    Sanjay
     
    Sanjay, Nov 18, 2003
    #1
    1. Advertising

  2. Do you have anonymous access turned on for your web application? Here is a
    knowledge base article that addresses this situation and may help:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;811318


    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Shell/UI
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "Sanjay" <> wrote in message
    news:3fb96917$...
    > I have written a web service to return information from the database. This
    > works and the data is returned in XML format from the database and

    displayed
    > on the web page as well when this web service called getsampledata is
    > invoked. Now I create a web page and created a webservice using the web
    > reference technique in the VS .NET to consume this web service. The web
    > page (application), web server, web service and database are on the same
    > box. Here is where my problems start. I keep getting this error message
    > reproduced here.
    >
    > System.Net.WebException: The request failed with HTTP status 401: Access
    > Denied. at
    >

    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
    > Message message, WebResponse response, Stream responseStream, Boolean
    > asyncCall) at
    > System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    > methodName, Object[] parameters) at
    > WebPageWebServiceTest.HPSD.Service1.GetSampleData() in
    > C:\Inetpub\wwwroot\WebPageWebServiceTest\Web
    > References\HPSD\Reference.cs:line 40 at
    > WebPageWebServiceTest.WebForm1.Button1_Click(Object sender, EventArgs e)

    in
    > c:\inetpub\wwwroot\webpagewebservicetest\webform1.aspx.cs:line 69
    >
    > Name of the web page trying to consume the webservice =
    > WebPageWebServiceTest
    > Name of the webservice HPSD.Service1.GetSampleData().
    >
    >
    > I have played around with the web config file and have the following

    working
    > web.conifg parameters
    > <authentication mode="None" />
    >
    > <identity impersonate="true" />
    >
    > Same parameters on both the web.config files ie on the web service and

    web
    > page(application). The database has aspnet configured as a user. The
    > following line is the connection string details on the webservice
    >
    > sqlConnectionString="Provider=SQLOLEDB.1;integratedsecurity=SSPI;Persist
    > Security Info=False;Initial Catalog=XXX_DEV;Data Source=XXXX;
    >
    > I just am not able to get past the error noted above.
    >
    > I am wondering if anyone else has run into this problem. Any

    pointers/tips
    > much appreciated.
    >
    > Thanks
    >
    > Sanjay
    >
    >
    >
     
    Chris Jackson, Nov 18, 2003
    #2
    1. Advertising

  3. Sanjay

    Sanjay Guest

    Re: Web Service throws 401 Error when consumed - Works now !!

    Thank you Chris
    That took care of that problem. Really apprecate your help.
    Now to figure out how to get the xml data out of the dataset and bind to the
    datagrid.
    Thanks again.
    Sanjay

    "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
    news:%23R%...
    > Do you have anonymous access turned on for your web application? Here is a
    > knowledge base article that addresses this situation and may help:
    >
    > http://support.microsoft.com/default.aspx?scid=kb;en-us;811318
    >
    >
    > --
    > Chris Jackson
    > Software Engineer
    > Microsoft MVP - Windows Shell/UI
    > Windows XP Associate Expert
    > --
    > More people read the newsgroups than read my email.
    > Reply to the newsgroup for a faster response.
    > (Control-G using Outlook Express)
    > --
    >
    > "Sanjay" <> wrote in message
    > news:3fb96917$...
    > > I have written a web service to return information from the database.

    This
    > > works and the data is returned in XML format from the database and

    > displayed
    > > on the web page as well when this web service called getsampledata is
    > > invoked. Now I create a web page and created a webservice using the

    web
    > > reference technique in the VS .NET to consume this web service. The

    web
    > > page (application), web server, web service and database are on the

    same
    > > box. Here is where my problems start. I keep getting this error message
    > > reproduced here.
    > >
    > > System.Net.WebException: The request failed with HTTP status 401:

    Access
    > > Denied. at
    > >

    >

    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
    > > Message message, WebResponse response, Stream responseStream, Boolean
    > > asyncCall) at
    > > System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    > > methodName, Object[] parameters) at
    > > WebPageWebServiceTest.HPSD.Service1.GetSampleData() in
    > > C:\Inetpub\wwwroot\WebPageWebServiceTest\Web
    > > References\HPSD\Reference.cs:line 40 at
    > > WebPageWebServiceTest.WebForm1.Button1_Click(Object sender, EventArgs e)

    > in
    > > c:\inetpub\wwwroot\webpagewebservicetest\webform1.aspx.cs:line 69
    > >
    > > Name of the web page trying to consume the webservice =
    > > WebPageWebServiceTest
    > > Name of the webservice HPSD.Service1.GetSampleData().
    > >
    > >
    > > I have played around with the web config file and have the following

    > working
    > > web.conifg parameters
    > > <authentication mode="None" />
    > >
    > > <identity impersonate="true" />
    > >
    > > Same parameters on both the web.config files ie on the web service and

    > web
    > > page(application). The database has aspnet configured as a user. The
    > > following line is the connection string details on the webservice
    > >
    > > sqlConnectionString="Provider=SQLOLEDB.1;integratedsecurity=SSPI;Persist
    > > Security Info=False;Initial Catalog=XXX_DEV;Data Source=XXXX;
    > >
    > > I just am not able to get past the error noted above.
    > >
    > > I am wondering if anyone else has run into this problem. Any

    > pointers/tips
    > > much appreciated.
    > >
    > > Thanks
    > >
    > > Sanjay
    > >
    > >
    > >

    >
    >
     
    Sanjay, Nov 18, 2003
    #3
  4. Re: Web Service throws 401 Error when consumed - Works now !!

    You can bind to any class that supports the IEnumerable interface:

    dataGrid.DataSource = dataSet;
    dataGrid.DataBind();

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Shell/UI
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "Sanjay" <> wrote in message
    news:...
    > Thank you Chris
    > That took care of that problem. Really apprecate your help.
    > Now to figure out how to get the xml data out of the dataset and bind to

    the
    > datagrid.
    > Thanks again.
    > Sanjay
    >
    > "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
    > news:%23R%...
    > > Do you have anonymous access turned on for your web application? Here is

    a
    > > knowledge base article that addresses this situation and may help:
    > >
    > > http://support.microsoft.com/default.aspx?scid=kb;en-us;811318
    > >
    > >
    > > --
    > > Chris Jackson
    > > Software Engineer
    > > Microsoft MVP - Windows Shell/UI
    > > Windows XP Associate Expert
    > > --
    > > More people read the newsgroups than read my email.
    > > Reply to the newsgroup for a faster response.
    > > (Control-G using Outlook Express)
    > > --
    > >
    > > "Sanjay" <> wrote in message
    > > news:3fb96917$...
    > > > I have written a web service to return information from the database.

    > This
    > > > works and the data is returned in XML format from the database and

    > > displayed
    > > > on the web page as well when this web service called getsampledata is
    > > > invoked. Now I create a web page and created a webservice using the

    > web
    > > > reference technique in the VS .NET to consume this web service. The

    > web
    > > > page (application), web server, web service and database are on the

    > same
    > > > box. Here is where my problems start. I keep getting this error

    message
    > > > reproduced here.
    > > >
    > > > System.Net.WebException: The request failed with HTTP status 401:

    > Access
    > > > Denied. at
    > > >

    > >

    >

    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
    > > > Message message, WebResponse response, Stream responseStream, Boolean
    > > > asyncCall) at
    > > > System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    > > > methodName, Object[] parameters) at
    > > > WebPageWebServiceTest.HPSD.Service1.GetSampleData() in
    > > > C:\Inetpub\wwwroot\WebPageWebServiceTest\Web
    > > > References\HPSD\Reference.cs:line 40 at
    > > > WebPageWebServiceTest.WebForm1.Button1_Click(Object sender, EventArgs

    e)
    > > in
    > > > c:\inetpub\wwwroot\webpagewebservicetest\webform1.aspx.cs:line 69
    > > >
    > > > Name of the web page trying to consume the webservice =
    > > > WebPageWebServiceTest
    > > > Name of the webservice HPSD.Service1.GetSampleData().
    > > >
    > > >
    > > > I have played around with the web config file and have the following

    > > working
    > > > web.conifg parameters
    > > > <authentication mode="None" />
    > > >
    > > > <identity impersonate="true" />
    > > >
    > > > Same parameters on both the web.config files ie on the web service

    and
    > > web
    > > > page(application). The database has aspnet configured as a user. The
    > > > following line is the connection string details on the webservice
    > > >
    > > >

    sqlConnectionString="Provider=SQLOLEDB.1;integratedsecurity=SSPI;Persist
    > > > Security Info=False;Initial Catalog=XXX_DEV;Data Source=XXXX;
    > > >
    > > > I just am not able to get past the error noted above.
    > > >
    > > > I am wondering if anyone else has run into this problem. Any

    > > pointers/tips
    > > > much appreciated.
    > > >
    > > > Thanks
    > > >
    > > > Sanjay
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Chris Jackson, Nov 19, 2003
    #4
  5. Sanjay

    Sanjay Guest

    Re: Web Service throws 401 Error when consumed - Works now !!

    Actually Chris I knew that and the web service is working now like a charm.
    But thanks for the reply anyway.
    Sanjay

    PS I have a new question posted on this newsgroup which might 'ahem'
    require your expertise/attention.


    "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
    news:%...
    > You can bind to any class that supports the IEnumerable interface:
    >
    > dataGrid.DataSource = dataSet;
    > dataGrid.DataBind();
    >
    > --
    > Chris Jackson
    > Software Engineer
    > Microsoft MVP - Windows Shell/UI
    > Windows XP Associate Expert
    > --
    > More people read the newsgroups than read my email.
    > Reply to the newsgroup for a faster response.
    > (Control-G using Outlook Express)
    > --
    >
    > "Sanjay" <> wrote in message
    > news:...
    > > Thank you Chris
    > > That took care of that problem. Really apprecate your help.
    > > Now to figure out how to get the xml data out of the dataset and bind to

    > the
    > > datagrid.
    > > Thanks again.
    > > Sanjay
    > >
    > > "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
    > > news:%23R%...
    > > > Do you have anonymous access turned on for your web application? Here

    is
    > a
    > > > knowledge base article that addresses this situation and may help:
    > > >
    > > > http://support.microsoft.com/default.aspx?scid=kb;en-us;811318
    > > >
    > > >
    > > > --
    > > > Chris Jackson
    > > > Software Engineer
    > > > Microsoft MVP - Windows Shell/UI
    > > > Windows XP Associate Expert
    > > > --
    > > > More people read the newsgroups than read my email.
    > > > Reply to the newsgroup for a faster response.
    > > > (Control-G using Outlook Express)
    > > > --
    > > >
    > > > "Sanjay" <> wrote in message
    > > > news:3fb96917$...
    > > > > I have written a web service to return information from the

    database.
    > > This
    > > > > works and the data is returned in XML format from the database and
    > > > displayed
    > > > > on the web page as well when this web service called getsampledata

    is
    > > > > invoked. Now I create a web page and created a webservice using

    the
    > > web
    > > > > reference technique in the VS .NET to consume this web service.

    The
    > > web
    > > > > page (application), web server, web service and database are on the

    > > same
    > > > > box. Here is where my problems start. I keep getting this error

    > message
    > > > > reproduced here.
    > > > >
    > > > > System.Net.WebException: The request failed with HTTP status 401:

    > > Access
    > > > > Denied. at
    > > > >
    > > >

    > >

    >

    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
    > > > > Message message, WebResponse response, Stream responseStream,

    Boolean
    > > > > asyncCall) at
    > > > > System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    > > > > methodName, Object[] parameters) at
    > > > > WebPageWebServiceTest.HPSD.Service1.GetSampleData() in
    > > > > C:\Inetpub\wwwroot\WebPageWebServiceTest\Web
    > > > > References\HPSD\Reference.cs:line 40 at
    > > > > WebPageWebServiceTest.WebForm1.Button1_Click(Object sender,

    EventArgs
    > e)
    > > > in
    > > > > c:\inetpub\wwwroot\webpagewebservicetest\webform1.aspx.cs:line 69
    > > > >
    > > > > Name of the web page trying to consume the webservice =
    > > > > WebPageWebServiceTest
    > > > > Name of the webservice HPSD.Service1.GetSampleData().
    > > > >
    > > > >
    > > > > I have played around with the web config file and have the following
    > > > working
    > > > > web.conifg parameters
    > > > > <authentication mode="None" />
    > > > >
    > > > > <identity impersonate="true" />
    > > > >
    > > > > Same parameters on both the web.config files ie on the web service

    > and
    > > > web
    > > > > page(application). The database has aspnet configured as a user. The
    > > > > following line is the connection string details on the webservice
    > > > >
    > > > >

    > sqlConnectionString="Provider=SQLOLEDB.1;integratedsecurity=SSPI;Persist
    > > > > Security Info=False;Initial Catalog=XXX_DEV;Data Source=XXXX;
    > > > >
    > > > > I just am not able to get past the error noted above.
    > > > >
    > > > > I am wondering if anyone else has run into this problem. Any
    > > > pointers/tips
    > > > > much appreciated.
    > > > >
    > > > > Thanks
    > > > >
    > > > > Sanjay
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Sanjay, Nov 20, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S3lsZSBCYWxleQ==?=

    401 Unauthorized error in local web service

    =?Utf-8?B?S3lsZSBCYWxleQ==?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,379
    =?Utf-8?B?S3lsZSBCYWxleQ==?=
    Aug 3, 2005
  2. Replies:
    5
    Views:
    352
    Raymond
    Aug 20, 2006
  3. www
    Replies:
    0
    Views:
    315
  4. www
    Replies:
    1
    Views:
    437
  5. Paganoni
    Replies:
    2
    Views:
    104
    Robert Klemme
    Mar 27, 2009
Loading...

Share This Page