(超难)如何在WebService 生成的代理类中,把自定义对象上面的特性(Attrubte)包含到代码中呢?
如何在WebService 生成的代理类中,把自定义对象上面的特性(Attrubte)包含到代码中呢?
//-------------------------------------------------------------------------------------
using System;
namespace CookWebTest
{
public class TestAttribute : System.Attribute
{
}
[CookWebTest.Test]
public class Class1
{
public Class1()
{
}
}
}
//-------------------------------------------------------------------------
Web服务代码:
public class AService : System.Web.Services.WebService
{
public AService()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
}
..........
...........
[WebMethod]
public Class1 HelloWorld()
{
return new Class1();
}
}
//-----------------------------------------------------------------------------
客户端生成的代理类:
namespace ConsoleApplication1.localhost {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="AServiceSoap", Namespace="http://tempuri.org/")]
public class AService : System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public AService() {
this.Url = "http://localhost/CookWebTest/AService.asmx";
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/HelloWorld", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public Class1 HelloWorld() {
object[] results = this.Invoke("HelloWorld", new object[0]);
return ((Class1)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginHelloWorld(System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("HelloWorld", new object[0], callback, asyncState);
}
/// <remarks/>
public Class1 EndHelloWorld(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((Class1)(results[0]));
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")]
public class Class1 {
}
}
为什么看不到,我定义的属性呢?