不。它的工作方式是,当您向项目添加引用时,它查询给定的服务URL,并通过SOAP通过XML创建特定服务的所有类和方法的列表。
如果向服务中添加了其他方法,则只需要删除并读取引用。
将引用添加到项目,然后导入命名空间。
Imports ReportingServiceInterface.ReportingService2005_WebService
然后通过这个类的实例调用WebService方法。
见下文:
Public Shared Sub CreateDataSource(ByVal strPath As String, ByVal strDataSourceName As String, ByVal strConnectionString As String, ByVal strDescription As String, ByVal strUserName As String, ByVal strPassword As String)
Dim rs As ReportingService2005 = New ReportingService2005
rs.Credentials = ReportingServiceInterface.GetMyCredentials(strCredentialsURL)
rs.Timeout = ReportingServiceInterface.iTimeout
rs.Url = ReportingServiceInterface.strReportingServiceURL
Dim dsdDefinition As DataSourceDefinition = New DataSourceDefinition
dsdDefinition.CredentialRetrieval = CredentialRetrievalEnum.Store
dsdDefinition.ConnectString = strConnectionString
dsdDefinition.Enabled = True
dsdDefinition.EnabledSpecified = True
dsdDefinition.Extension = "SQL"
dsdDefinition.ImpersonateUserSpecified = False
dsdDefinition.UserName = strUserName ' "UserName"
dsdDefinition.Password = strPassword ' "Password"
dsdDefinition.Prompt = Nothing
dsdDefinition.WindowsCredentials = False
'Dim PropertyArray As ReportingService2005_WebService.Property() = New ReportingService2005_WebService.Property(0) {}
'PropertyArray(0) = New ReportingService2005_WebService.Property
'PropertyArray(0).Name = "Description"
'PropertyArray(0).Value = "Automatically added DataSource"
Dim PropertyArray() As ReportingService2005_WebService.Property = { _
New ReportingService2005_WebService.Property() With {.Name = "Description", .Value = "Automatically added DataSource"} _
}
Try
If String.IsNullOrEmpty(strDescription) Then
rs.CreateDataSource(strDataSourceName, strPath, False, dsdDefinition, Nothing)
Else
PropertyArray(0).Value = strDescription
rs.CreateDataSource(strDataSourceName, strPath, False, dsdDefinition, PropertyArray)
End If
Catch ex As System.Web.Services.Protocols.SoapException
Console.WriteLine(ex.Detail.InnerXml.ToString())
End Try
End Sub ' End Sub CreateDataSource