2016-07-28 119 views
1

我想通过SAP Web服务的SOAP传递一个2D数组。 但我无法通过相同的。通过SAP为SAP Webservice传递数组

我能够传递一个值,我也能够接受来自SAP的表输出。 请指导。

我试图将类型数组作为对象。

我的代码:

<?php  
    include("include/config.php"); 

    $sql = "SELECT tid,OrderNumber FROM transhistory ORDER by timestamp ASC limit 2"; 
    $result= mysqli_query($db,$sql); 
    $i=0; 
    while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) { 
     //Array based on output table 
     $pmt[$i][0] = "";      //Mandt 
     $pmt[$i][1] = $row["tid"];    //Refnum 
     $pmt[$i][2] = $row["OrderNumber"]; //Orderno 

     $i++; 
    } 

    /*Two methods I tried */ 
    $object = (object) $pmt; 
    $object = json_decode(json_encode($pmt), FALSE); 

    #Define Authentication 
    $SOAP_AUTH = array('login' => 'abc', 
         'password' => 'abc'); 

    #Specify WSDL 
    $WSDL = "working URL here"; 

    #Create Client Object, download and parse WSDL 
    $client = new SoapClient($WSDL,$SOAP_AUTH); 

    #Setup input parameters (SAP Likes to Capitalise the parameter names) 
    $params = array(
      'Zpmt' => $object 
    ); 

    #Call Operation (Function). Catch and display any errors 
    try { 
     $result = $client->ZphpOT($params); 
    } catch (SoapFault $exception) { 
     echo 'Error!Server Connectivity issue. Please try again later.'; 
     die(); 
    }  
?> 

回答

0

我不知道答案可能是为别人有用的,但通常你发送参数这样

$result = $client->ZphpOT("VARIABLE_NAME"=>$params);