Наполнение GridView из веб службы?

dedyyshka
Дата: 27.05.2008 09:05:00
Доброго дня.
В VS2005 создал проект веб сайта, подключил web references: "reportservice" (MS Report Server 2005)
На форму кинул ObjectDataSource, при настройке выбрал объект ReportServer.ReportingService в качестве метода для селекта выбрал ListChildren, указал дефолтные параметры.
Если запустить страницу на выполнение то всё гуд.
Добавил GrigView, указал в качестве датасорса настроеный ObjectDataSource.
Код страницы:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="ListChildren"
TypeName="ReportServer.ReportingService">
<SelectParameters>
<asp:Parameter DefaultValue="/" Name="Item" Type="String" />
<asp:Parameter DefaultValue="true" Name="Recursive" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
<br />
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1">
</asp:GridView>

Если выполнить теперь то ругается на строку 888:

Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

Source Error:


Line 886: [return: System.Xml.Serialization.XmlArrayAttribute("CatalogItems")]
Line 887: public CatalogItem[] ListChildren(string Item, bool Recursive) {
Line 888: object[] results = this.Invoke("ListChildren", new object[] {
Line 889: Item,
Line 890: Recursive});



Подскажите где грабли...
Vladimir T
Дата: 20.06.2008 14:00:57
Посмотрите пожалуйста:

http://forums.aspfree.com/net-development-11/the-request-failed-with-http-status-401-unauthorized-11744.html

Похоже что там есть решение Вашей проблемы:

You have two choices:

1. Enable anonymous access.
You can do this by:
a. In Administrative Tools double click on IIS.
b. Right click on the Web Service you have developed.
c. Click on Properties.
d. Click on Directory Security Tab.
e. In Authontication & Security Box, click on Edit Button.
f. Click on Enable anonymous access.

2. Authenticate yourself to the Web Service.

I'm assuming that you added a reference to the Web Service in your
Windows Application, Windows Service, Web Application or Console
Application. Also, I'll assume that the name of the Web Service is WS.

WS.Service1 svc = new WS.service1();
svc.Credentials = new System.Net.NetworkCredential("myUserId",
"myPassword");
svc.PreAuthenticate = true;
try{int sum = svc.Sum(1, 1);}catch(Exception ex){Console.WriteLine(
ex.Message)}

1. Hope this helps.
Владимир Тришин

http://programmer-kharkov.com