!!继承自SoapHttpClientProtocol的类报错!!
在微软的网站上:
http://msdn.microsoft.com/zh-cn/library/system.web.services.protocols.soaphttpclientprotocol.aspx
有关于SoapHttpClientProtocol 类的介绍,在介绍中有一个C#示例:
C# 复制代码
namespace MyMath {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.Web.Services;
[System.Web.Services.WebServiceBindingAttribute(Name="MyMathSoap", Namespace="http://www.contoso.com/")]
public class MyMath : System.Web.Services.Protocols.SoapHttpClientProtocol {
[System.Diagnostics.DebuggerStepThroughAttribute()]
public MyMath() {
this.Url = "http://www.contoso.com/math.asmx";
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.contoso.com/Add", RequestNamespace="http://www.contoso.com/", ResponseNamespace="http://www.contoso.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int Add(int num1, int num2) {
object[] results = this.Invoke("Add", new object[] {num1,
num2});
return ((int)(results[0]));
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
public System.IAsyncResult BeginAdd(int num1, int num2, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("Add", new object[] {num1,
num2}, callback, asyncState);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
public int EndAdd(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((int)(results[0]));
}
}
}
我在Visual Studio 2008中创建了这个类,编译没有问题,代码中也没有错误提示。但当我双击打开时,却报了一个错:
1 Error
WebServiceBindingAttribute is required on proxy classes.
Instances of this error (1)
1. Show Call Stack
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
Help with this error
Could not find an associated help topic for this error. Check Windows Forms Design-Time error list
Forum posts about this error
Search the MSDN Forums for posts related to this error
请高手指点一二,多谢多谢!