2017-09-28 144 views

回答

0

在創建Web服務,只需添加參數,用戶名和密碼。例如,以下webservice將用戶名和密碼作爲字符串,與他們一起登錄到數據庫並返回數據集(未顯示打開的連接函數)。我使用TLS 1.2加密連接:

Imports System.Web.Services 
Imports System.Web.Services.Protocols 
Imports Oracle.DataAccess.Client 
Imports System.ComponentModel 
Imports System.Net.mail 
Imports System.IO 

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _ 
<System.Web.Services.WebServiceBinding ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
<ToolboxItem(False)> _ 
Public Class MyWebService 
    Inherits System.Web.Services.WebService 
     <WebMethod()> _ 
    Public Function GetData(ByVal pUsername As String, ByVal pPassword As String) As DataSet 
     Dim MyDataSet As DataSet 
     Dim MyConnection As OracleConnection = OpenConnection(pUsername, pPassword) 
     Try 
      MyDataSet = GetUserData(MyConnection, pUsername) 
      MyConnection.Close() 
      MyConnection.Dispose() 
      MyConnection = Nothing 
      Return MyDataSet 

     Catch ex As Exception 
      MyConnection.Close() 
      MyConnection.Dispose() 
      MyConnection = Nothing 
      Return New DataSet 
     End Try 
    End Function 
End Class 
+0

感謝這正是我想要做的。 – PhilCaser

相關問題