代理类需要WebServiceBindingAttribute

时间:2010-08-10 12:11:33

标签: .net web-services

我创建了一个基于SOAP的Web服务并创建了一个名为SetclientCredential的函数 使用Microsoft.Web.Services3.Security.Tokens.UsernameToken设置客户端凭据 代码示例如下:

<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

该例外指出: Dim cProxy As New Microsoft.Web.Services3.WebServicesClientProtocol。

有谁知道问题出在哪里。

由于

2 个答案:

答案 0 :(得分:2)

我不想看起来像是在指出一些愚蠢的东西但是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.

答案 1 :(得分:0)

我相信它应该是      [System.Web.Services.WebServiceBindingAttribute(Name =“ServiceName”,Namespace =“http://tempuri.org/”)]