.NET SOAP常见类型 [英] .NET SOAP Common types

查看:138
本文介绍了.NET SOAP常见类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有创建Web服务时指定类型的使用方式?具体地讲,我希望能够使用相同类型的客户端和服务器,以减少code复制

Is there a way when creating web services to specify the types to use? Specifically, I want to be able to use the same type on both the client and server to reduce duplication of code.

在简单的例子:

    public class Name
    {
        public string FirstName {get; set;}
        public string Surname { get; set; }

        public override string ToString()
        {
            return string.Concat(FirstName, " ", Surname);
        }
    }

我不希望有重新code片的功能,在我的课。另一件事是,存在的操纵客户端这个类将无法正常工作时产生将是一个不同类型的客户端类中的任何code。

I don't want to have recode pieces of functionality in my class. The other thing is that any code that exists that manipulates this class won't work client side as the client side class that is generated would be a different type.

推荐答案

好吧,我看知道,这已经让你不实际上应该这样对SOAP的一部分明确的设计决策。我发现下面的页面这解释了原因:

Okay, I see know that this has been an explicit design decision on the part of SOAP so you're not actually supposed to this. I found the following page that explains why:

服务共享模式和契约,   不是阶级。服务交互仅凭   他们的前$ P $结构通过pssion   通过模式和行为   合同。该服务的合同   描述的消息的结构   以上顺序约束   消息。的手续   EX pression允许机验证   传入消息。机   验证传入消息   可以保护服务的   完整。合同和模式必须   保持稳定一段时间,所以建筑   他们灵活是重要的。

Services share schema and contract, not class. Services interact solely on their expression of structures through schemas and behaviors through contracts. The service's contract describes the structure of messages and ordering constraints over messages. The formality of the expression allows machine verification of incoming messages. Machine verification of incoming messages allows you to protect the service's integrity. Contracts and schemas must remain stable over time, so building them flexibly is important.

尽管如此,还有其他两种可能性:

Having said that there are two other possibilities:

  1. 生成在Visual Studio或使用Wsdl.exe用的Web引用。然后进入到生成的Reference.cs(或.vb)文件,明确地删除该类型。然后重定向到你想要的位于其他组件类型。
  2. 您可以由Wsdl.exe用在客户端和/ sharetypes参数共享Web服务之间的类型。

这篇关于.NET SOAP常见类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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