在ASP.NET Web服务实体传递 [英] Passing Entity on ASP.NET Web Service

查看:71
本文介绍了在ASP.NET Web服务实体传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是很容易的,但我想在这里做的是,我想给客户对象传递到Web服务方法。 Customer类是实体的命名空间,这是序列化的,并且我将提及我的两个ASP.NET应用程序,它调用Web服务,并通过Entity.Customer对象以及在其中的WebService接受Enity.Customer对象。

Web服务方法

  [的WebMethod]
公共无效AddCustomer(Entity.Customer C)
{}

ASP.NET的applcation

  Entity.Customer C =新Entity.Customer;
webservice.AddCustomer(C);

错误

对于最佳重载方法匹配'TestApplication.localhost.Service1.AddCustomer(TestApplication.localhost.Customer)'有一些无效参数

我试图改变Web服务接受对象,后来投的对象Customer.Entity,应用程序编译,但我是越来越XML生成错误。


解决方案

您生成使用添加Web引用的方法从Visual Studio中的Web服务方法?

这是一个编译问题的权利?你的应用程序并不想编译?刚去的方法的定义,并确保您传递相同的客户对象的方法定义指定的 - 通常生成的Web服务方法生成对象的代理版,你需要传递完全相同的类

This might be very easy, but What I am trying to do here is, I am trying to pass a Customer Object to a Web Service Method. Customer class is on Entity namespace and it is serializable, and I am adding reference to both of my ASP.NET application which calls web service and pass Entity.Customer Object and also in WebService which accepts Enity.Customer Object.

Web Service Method

[WebMethod]
public void AddCustomer(Entity.Customer c)
{}

ASP.NET Applcation

Entity.Customer c = new Entity.Customer;
webservice.AddCustomer(c);

Error

The best overloaded method match for 'TestApplication.localhost.Service1.AddCustomer(TestApplication.localhost.Customer)' has some invalid arguments

I tried changing the web service to accept Object and later cast that object to Customer.Entity, the Application compiles but I was getting XML generation errors.

解决方案

Are you generating the web service method using the 'Add Web Reference' method from within Visual Studio?

This is a compile-issue right? You application doesn't want to compile? Just go to the definition of the method and make sure you are passing the same customer object as specified in the method definition - usually the generated web service method generates a proxy version of the object and you need to pass that exact same class.

这篇关于在ASP.NET Web服务实体传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆