我創建了一個基於SOAP的Web服務,並創建一個名爲SetclientCredential功能 其設置使用Microsoft.Web.Services3.Security.Tokens.UsernameToken 客戶端憑證的代碼示例如下:WebServiceBindingAttribute需要在代理類
<SoapDocumentMethod(Action:="http://tempuri.org/SetClientCredential", _
RequestNamespace:="http://tempuri.org/", _
RequestElementName:="GetUserNameRequest", _
ResponseNamespace:="http://tempuri.org/", _
ResponseElementName:="GetUserNameResponse"), _
WebMethod(Description:="Obtains the User Name")> _
Public Sub SetClientCredential(ByVal username As String, ByVal userpass As String)
username = "ADMIN"
userpass = "password"
Dim usernametoken As New Microsoft.Web.Services3.Security.Tokens.UsernameToken(username, userpass)
Dim cProxy As New Microsoft.Web.Services3.WebServicesClientProtocol
cProxy.SetClientCredential(usernametoken)
End Sub
然後我調試它給了例外的服務:
Dim cProxy As New Microsoft.Web.Services3.WebServicesClientProtocol
例外指出: 昏暗CPROXY作爲新Microsoft.Web.Services3.WebS ervicesClientProtocol。
有誰知道問題出在哪裏。
感謝
這不是一個問題,而是一個陳述。 – 2010-08-10 12:13:36