(超难)如何在WebService 生成的代理类中,把自定义对象上面的特性(Attrubte)包含到代码中呢?

stardicky 2005-07-23 01:49:23
如何在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 {
}
}

为什么看不到,我定义的属性呢?
...全文
160 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
athossmth 2005-08-01
  • 打赏
  • 举报
回复
关注一下
kaixin110 2005-07-29
  • 打赏
  • 举报
回复
看看IssueVision吧
fq_ln 2005-07-29
  • 打赏
  • 举报
回复
gz
thinkc 2005-07-26
  • 打赏
  • 举报
回复
在某些情况下,由 WSDL.exe 生成的代理类会使用一种不常见的命名方法,将对象强制转换成服务说明中指定的类型。因此,代理类中的生成类型可能不是开发人员想要或预期的类型。例如,当 WSDL.exe 在服务说明中遇到 ArrayList 类型时,它将在生成的代理类中创建一个 Object 数组。若要确保对象类型转换正确,请打开包含生成的代理类的文件,将所有不正确的对象类型更改成所需的对象类型。

12,163

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧