2016-08-15 136 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,並且您知道它的工作原理。