读书人

关于构建“Web 服务”的有关问题.

发布时间: 2011-12-31 23:50:30 作者: rapoo

关于构建“Web 服务”的问题...
我是VB.Net的初学者。
最近在看“VB.Net入门经典”,感觉收益匪浅。
我看到第20章的“构建Web服务”的相关内容是有点困惑,所以来此向各位高手请教。

我按照书上的例子代码(是一个“图片服务器服务”的例子),服务器部分的程序已经创建好了,而且也测试成功了。但是当我做到“图片服务器客户程序”时就有问题了,客户端程序运行后抛出异常...

客户程序代码如下:
(代码主要内容就是把Web服务器里面的3个放有图片的文件夹的名字加载到Windows_Form上的ComboBox里面)

Public Class Form1
Inherits System.Windows.Forms.Form


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'get the pictrues...
Try
'create a connection to the service...
Dim service As New PictureService.Service

'get a list of the folders...
Dim folderNames() As String
folderNames = service.GetPictureFolders

'go through the list and add each name...
Dim folderName As String
For Each folderName In folderNames
cboFolders.Items.Add(folderName)
Next

Catch ex As Exception
HandleException(ex)
End Try
End Sub

'HandleException-handle a Web service exception...
Private Function HandleException(ByVal e As Exception)
'loop through the inner exceptions...
Do While Not e.InnerException Is Nothing
e = e.InnerException
Loop

'report the problem...
MessageBox.Show( "An exception occured. " & e.Message)
End Function
End Class

运行后抛出的异常信息是“HTTP Status 401:Access Denied request false!”且文件夹的名字没有加载进去...



请高手赐教...

[解决办法]
Access Denied ~~~~~~
No necessary right to access that server.

读书人网 >VB Dotnet

热点推荐