2016-08-15 138 views
1

我正在测试不同Web服务调用的性能,并想知道如何指定在响应中返回哪些字段。我在想,如果我只查询某些字段,会返回更少的信息,因此响应时间会更快。我怎样才能完成这种格式?Web服务调用返回

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 

xmlns:ns="http://schemas.hp.com/SM/7" xmlns:com="http://schemas.hp.com/SM/7/Common" xmlns:xm="http://www.w3.org/2005/05/xmlmime"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <ns:RetrieveChangeTaskListRequest> 
     <ns:model> 

     <ns:keys query="AssignedTo = &quot;drake&quot; and planned.start &gt; '03/01/2016' and planned.start &lt; tod()" ></ns:keys> 
     <ns:instance></ns:instance> 

    </ns:model> 
    </ns:RetrieveChangeTaskListRequest> 
</soapenv:Body> 
</soapenv:Envelope> 

回答

0

由于SOAP返回的完整对象的所有字段都完好无损,因此无法执行SOAP查询。

但是,如果你想缩小有效载荷的大小,你可以尝试启用gzip压缩,如果web服务器支持它,你会得到一个很好的微小响应。实例如SoapClient的:

$soapclient = new SoapClient($uri, array(
    'soap_version' => SOAP_1_1, 
    'trace' => 1, 
    'exceptions' => true, 
    'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP 
) 
); 

然后你可以检查头,看看是否响应做$soapclient->__getLastRequestHeaders()的请求,并$soapclient->__getLastResponseHeaders()为响应压缩。

在请求标题中,您应该看到:Accept-Encoding: gzip, deflate和响应标题:Content-Encoding: gzip以及Transfer-Encoding: chunked,并且您知道它的工作原理。

相关问题