2010-08-10 71 views
-1

我創建了一個基於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。

有誰知道問題出在哪裏。

感謝

+0

這不是一個問題,而是一個陳述。 – 2010-08-10 12:13:36

回答

1

我不想看起來像我指出一些愚蠢的,但確實Proxy類有相應的WebServiceBindingAttribute界定?

在C#中它會像這樣:

[WebServiceBindingAttribute(Name = "TempName", Namespace = "http://tempuri.org/")] 
public class WSProxyClass : Microsoft.Web.Services3.WebServicesClientProtocol 
{ 

//Forgive me, I'm not a VB person. 
0

我相信它應該是 [System.Web.Services.WebServiceBindingAttribute(NAME = 「服務名稱」,命名空間= 「http://tempuri.org/」)