[已解决问题] 怎么在多个webservice引用中只生成一个代理类
提问时间: 2008-04-29 18:17
悬赏分:30 浏览:179 次

例如我有两个webservice (service1,service2),有个一类叫Product,我在两个webserice中都使用了AddProduct(Product domainObject)方法;现在的问题是我添加了webservice引用后会生成两个代理类(Service1.Product,Service2.Product),怎么只生成一个代理类啊


最佳答案
看MSDN的这篇文章:
 Shareing Types
http://msdn.microsoft.com/en-us/library/aa480505.aspx
2008/4/30 13:18:08 回答者:deerchao


提问者对于答案的评价:多谢了,不知道还有没有比较好的方法。 如果再次更新web引用就还要重新更改文件,太麻烦了
其它回答(1)
你把生成出来的代码拷贝出来,修改之后放到一个文件里面就好了吧~~那个代理类的也可以手动指定一下.
2个月前   回答者:沙加 - 老鸟四级
评论
2个月前   飄lá┽蕩去 :
受教了,不过还是很麻烦,不是很智能
2个月前   飄lá┽蕩去 :
Proxy Type Sharing
ASP.NET Web Services now supports proxy type sharing. This feature allows you to share identical types from different Web services within the client-side proxy class. For example, you can take a type instance returned from one web service and pass it to another, and vice versa. 

In this sample, a product invoice is returned from the Ordering Center. The user then wishes to update the ship date on the order. To do so, the user passes the same ProductInvoice instance to the Shipping Center, which updates the order and returns the modified product invoice. 

How do you identify identical types? Identical types have the same type name and namespace, and also share the same schema type definition. 

In this sample we indicate that types should be shared by putting the wsdl and discomap from each service in the 'App_WebReferences' directory. If you wish to use wsdl.exe instead to create your client proxy here is the command to share types between TypeSharingService1 and TypeSharingService2: 

<!-- To share types, use the /sharetypes flag with wsdl.exe.  For example (all in one line): -->
     
wsdl.exe /sharetypes 
http://localhost/QuickstartV20/webservices/Samples/TypeSharing/cs/Server/TypeSharingService1.asmx
http://localhost/QuickstartV20/webservices/Samples/TypeSharing/cs/Server/TypeSharingService2.asmx

   您需要登录以后才能回答!
我的问题    我要提问


快到期问题

> 问题排行榜

有不合适内容,建议去除