gpt4 book ai didi

web-services - Web 服务调用具有 "out"参数是否不寻常?

转载 作者:行者123 更新时间:2023-12-04 05:29:57 24 4
gpt4 key购买 nike

Web 服务调用具有“out”参数是否不寻常?如果是这样,为什么?

我正在使用 C# web 服务,而 webserive 消费者也将是 c# 应用程序。

最佳答案

如果您指的是 ASP.Net Web 服务中 C# 级别的 out 参数,我认为这并不奇怪。您的输出参数将简单地成为响应元素的子元素。这是一个简短的示例 Web 服务,其中包含一个具有 out 参数的 Web 方法:

[WebService(Namespace = "http://begen.name/xml/namespace/2009/10/samplewebservicev1")]
public class SampleWebServiceV1 : WebService
{
[WebMethod]
public void
WebMethodWithOutParameters(out string OutParam1, out string OutParam2)
{
OutParam1 = "Hello";
OutParam2 = "Web!";
}
}

使用上述 Web 方法,SOAP 请求如下所示:
POST /SampleWebServiceV1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://begen.name/xml/namespace/2009/10/samplewebservicev1/WebMethodWithOutParameters"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<WebMethodWithOutParameters xmlns="http://begen.name/xml/namespace/2009/10/samplewebservicev1" />
</soap:Body>
</soap:Envelope>

响应如下所示:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<WebMethodWithOutParametersResponse xmlns="http://begen.name/xml/namespace/2009/10/samplewebservicev1">
<OutParam1>Hello</OutParam1>
<OutParam2>Web!</OutParam2>
</WebMethodWithOutParametersResponse>
</soap:Body>
</soap:Envelope>

注意:这不会使这个问题的其他答案无效,因为他们都是从 Web 服务级别而不是 C# 级别考虑这一点的。

关于web-services - Web 服务调用具有 "out"参数是否不寻常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1590002/

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