Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services web服务调用中有一个“";“出去”;参数_Web Services - Fatal编程技术网

Web services web服务调用中有一个“";“出去”;参数

Web services web服务调用中有一个“";“出去”;参数,web-services,Web Services,web服务调用具有“out”参数是否不常见?若然,原因为何 我正在使用C#web服务,webserive消费者也将使用C#app。是的,因为web服务应该被视为接收消息(请求)并输出结果(输出) “out”参数表示您希望返回原始请求消息的修改版本…这真的没有意义。如果需要有多个输出,则需要考虑如何将这些值打包到单个响应消息中。是的,您需要将返回的内容捆绑到单个对象(通常是响应对象)中 请参见如果您在ASP.Net web服务中引用的是C#级别的out参数,我认为这一点都不奇怪。out参数将成为响

web服务调用具有“out”参数是否不常见?若然,原因为何


我正在使用C#web服务,webserive消费者也将使用C#app。

是的,因为web服务应该被视为接收消息(请求)并输出结果(输出)


“out”参数表示您希望返回原始请求消息的修改版本…这真的没有意义。如果需要有多个输出,则需要考虑如何将这些值打包到单个响应消息中。

是的,您需要将返回的内容捆绑到单个对象(通常是响应对象)中


请参见

如果您在ASP.Net web服务中引用的是C#级别的out参数,我认为这一点都不奇怪。out参数将成为响应元素的子元素。下面是一个简短的web服务示例,其中有一个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>
POST/SampleWebServiceV1.asmx HTTP/1.1
主机:本地主机
内容类型:text/xml;字符集=utf-8
内容长度:长度
SOAPAction:“http://begen.name/xml/namespace/2009/10/samplewebservicev1/WebMethodWithOutParameters"
反应如下:

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>
HTTP/1.1200正常
内容类型:text/xml;字符集=utf-8
内容长度:长度
你好
网状物
注意:这并不会使这个问题的其他答案无效,因为他们都是从web服务级别而不是C#级别来考虑的。

web服务没有“out参数”,也没有这样的参数。更具体地说,对于soapweb服务(不是唯一的一种),您可以使用请求和响应XML。在某些平台上,响应XML的一部分可能会映射到out参数,但除非您为您的环境提供更多细节,否则很难比这更具体。