gpt4 book ai didi

c# - Service Reference 为 ServiceStack 生成不正确的代理

转载 作者:行者123 更新时间:2023-11-30 22:26:15 24 4
gpt4 key购买 nike

我有一个服务堆栈服务,在同一个命名空间中包含以下请求和响应类

public class GetContactMasterData
{

}

public class GetContactMasterDataResponse
{
public IdDescription[] EntityTypes { get; set; }
public IdDescription[] NameTypes { get; set; }
public IdDescription[] AddressTypes { get; set; }
public ResponseStatus MyResponseStatus { get; set; }
}

我使用 soapUI 成功测试了该服务。这是回应

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">    
<s:Body>
<GetContactMasterDataResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
<AddressTypes>
<IdDescription>
<Description>Home</Description>
<Id>1</Id>
</IdDescription>
...
</AddressTypes>
<EntityTypes>
<IdDescription>
<Description>Corporation</Description>
<Id>1</Id>
</IdDescription>
...
</EntityTypes>
<MyResponseStatus i:nil="true" />
<NameTypes>
<IdDescription>
<Id>4</Id>
<Description>Other</Description>
</IdDescription>
...
</NameTypes>
</GetContactMasterDataResponse>
</s:Body>
</s:Envelope>

当我创建一个控制台应用程序来测试此服务时,服务引用会生成一个代理对象。 intellisense 是这样引导你调用 GetContactMasterData 方法的

GetContactMasterData(出 IdDescription[],出 ResponseStatus myResponseStatus,出 IdDescription[] NameTypes):IdDescription[] addressTypes

我的问题是:为什么 EntityTypes 和 NameTypes 成为输出参数,而 addressTypes 成为方法的返回类型?

最佳答案

包含在 ServiceStack 的 SOAP Support wiki 中使用 SOAP 时需要注意的限制:

Since VS.NET's Add Service Reference is optimized for consuming .asmx or WCF RPC method calls it doesn't properly support multiple return values (e.g. when you also want a ResponseStatus property) where it will generate an ugly proxy API complete with out parameters.

If you want to ensure a pretty proxy is generated you should only have 1 first-level property which contains all the data you want to return.

关于c# - Service Reference 为 ServiceStack 生成不正确的代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11974659/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com