为什么一个WCF合同包括REF / out参数? [英] Why would a WCF Contract include a ref/out parameter?
问题描述
我在看别人的WCF服务合同,发现它使用一个输出参数:
client.SomeMethod(参数1,参数,出someOutParameter);
有一个很好的理由有一个输出参数,而不是将其添加到反应?
修改
这是代理生成的内容:
公共字符串createItem中(字符串合同,串音符,出串警告)
现在,如果他们需要返回一个字符串,也有一个警告,我通常会出现这样的:
公共类CreateItemResponse
{
公共字符串结果{获得;组; }
公共字符串警告{获得;组; }
}
如果有一个很好的理由,否则这种方式,并返回一个字符串,字符串作为out参数做它,我只是好奇。
有一个很好的理由有一个输出参数,而不是将其添加到反应?
未在Web服务合同。也许懒惰和不愿意定义一个额外的数据契约被用作返回类型一直是驱动力这背后的设计决定的。 退出
, REF
是.NET特定的文物。一个良好的,可互操作的服务合同不应该依赖于特定语言的文物。
I was looking at someone else's WCF service contract and noticed it was using an out parameter:
client.SomeMethod(parameter1, parameter2, out someOutParameter);
Is there a good reason for having an out parameter instead of adding it to the response?
edit
This is what the proxy generated:
public string CreateItem(string contract, string note, out string warning)
Now if they needed to return a string and also have a warning, I have usually seen it like this:
public class CreateItemResponse
{
public string Result { get; set; }
public string Warning { get; set; }
}
I was just curious if there was a good reason for not doing it this way, and doing it with a string being returned and a string as an out parameter.
Is there a good reason for having an out parameter instead of adding it to the response?
Not in a web service contract. Maybe laziness and unwillingness to define an additional data contract to be used as return type have been the driving forces behind this design decision. out
, ref
are .NET specific artifacts. A good and interoperable service contract shouldn't rely on language specific artifacts.
这篇关于为什么一个WCF合同包括REF / out参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!