.net 代理类上需要WebServiceBindingAttribute
我创建了一个基于soap的web服务,并创建了一个名为SetclientCredential的函数 它使用Microsoft.Web.Services3.Security.Tokens.UsernameToken设置客户端凭据 下面给出了代码示例:.net 代理类上需要WebServiceBindingAttribute,.net,web-services,.net,Web Services,我创建了一个基于soap的web服务,并创建了一个名为SetclientCredential的函数 它使用Microsoft.Web.Services3.Security.Tokens.UsernameToken设置客户端凭据 下面给出了代码示例: <SoapDocumentMethod(Action:="http://tempuri.org/SetClientCredential", _ RequestNamespace:="http://tempuri.org/", _ Reque
<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作为新的Microsoft.Web.Services3.WebServicesClientProtocol
有人知道问题出在哪里吗
谢谢我不想让人觉得我在指出一些愚蠢的事情,但是代理类是否定义了相应的WebServiceBindingAttribute 在C#中是这样的:
[WebServiceBindingAttribute(Name = "TempName", Namespace = "http://tempuri.org/")]
public class WSProxyClass : Microsoft.Web.Services3.WebServicesClientProtocol
{
//Forgive me, I'm not a VB person.
我认为应该是这样
[System.Web.Services.WebServiceBindingAttribute(Name=“ServiceName”,Namespace=”“)]这不是问题,而是陈述。
[WebServiceBindingAttribute(Name = "TempName", Namespace = "http://tempuri.org/")]
public class WSProxyClass : Microsoft.Web.Services3.WebServicesClientProtocol
{
//Forgive me, I'm not a VB person.