什么是PHP soap multiall等效于.net调用Magento API v2


What is PHP Soaps multiCall equivalent to .NET call for Magento API v2

我很高兴地将一个端点连接到我的。net项目中,制作了包装器类,一切都很好。(我尽可能多地使用PHP教程进行翻译),我遇到了一个巨大的瓶颈,我不确定如何解决…我找不到任何像样的信息。

所以…

在PHP中可以使用

$calls = array( 
    array( 'catalog_product.info', 166 ), 
    array( 'catalog_product.info', 167 ), 
    array( 'catalog_product.info', 168 ), 
); 
$results = $soap->multiCall( $session_id, $calls ); 

在一个电话中,我将获得3个产品,为我节省了70%的HTTP开销。

在。net中我使用这个
   Dim productReturn As MS.catalogProductReturnEntity
   Private myMagento As MS.Mage_Api_Model_Server_V2_HandlerPortType = New MS.Mage_Api_Model_Server_V2_HandlerPortTypeClient
   productReturn = myMagento.catalogProductInfo(SessionID, productId, storeView, requestAttr, Nothing)

,返回一项扩展信息。.NET中的Service引用

Function catalogProductInfo(ByVal sessionId As String, ByVal product
As String, ByVal storeView As String, ByVal attributes As
MagentoBridge2.MS.catalogProductRequestAttributes, ByVal
productIdentifierType As String) As
MagentoBridge2.MS.catalogProductReturnEntity
Member of MagentoBridge2.MS.Mage_Api_Model_Server_V2_HandlerPortType

不接受产品数组。

那么如何在。net中使用PHP中使用的multiCall ?

点击>更多细节

你需要在你的magento服务器的根目录下放一个PHP文件,看起来像这样

<?php
$id_start = $_GET['start'];
$id_end = $_GET['end'];
// Magento login information 
$mage_url = 'http://www.YOURSITE.co.uk/api/?wsdl=1'; 
$mage_user = 'USERNAME'; 
$mage_api_key = 'PASSWORD'; 
// Initialize the SOAP client 
$soap = new SoapClient( $mage_url ); 
// Login to Magento 
$session_id = $soap->login( $mage_user, $mage_api_key );
    $calls = array(); 
    for ($id_start; $id_start <= $id_end; $id_start++)
        {
        array_push($calls, array( 'catalog_product.info', $id_start ));
        }
    $results = $soap->multiCall( $session_id, $calls ); 
    echo json_encode($results);
?>

吧!单一的 !!!!!!!!!!!!然后在。net中,你就有了这样一个漂亮的函数!

Function getHTTPStream() As String
        Dim myh As HttpWebRequest = HttpWebRequest.Create("http://www.YOURSITE.co.uk/prod.php?start=20&end=80")
        myh.Timeout = 30000
        myh.UserAgent = "Test"
        Dim myR As HttpWebResponse = myh.GetResponse()
        Dim myEnc As Encoding = Encoding.GetEncoding(1252)
        Dim mySr As StreamReader = New StreamReader(myR.GetResponseStream(), myEnc)
        Return mySr.ReadToEnd()
    End Function

注意i通过start=20;这是它将开始的ID和end=80

TADAAAAAAAAAAAAAAAAAAAAAa…

现在你需要在。net中做的就是将JSON转换成一个表。例如使用THIS你知道吗?我现在可以在Visual Studio .NET中每秒请求100个产品的完整扩展信息! Whoooooooooohoooooooooo ! !之前,我花了3个产品一秒钟在多线程请求中做单独的调用。好大的进步。

谢谢大家的帮助。(蟋蟀在远处)