使用参数通过php从SAP调用SAP webservice

时间:2014-08-18 07:39:24

标签: php web-services sap

我知道如何从php调用SAP webservice,但是如何根据我的请求发送参数?

我尝试了以下内容:

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

  #Specify WSDL
  $WSDL = "http://xxxxxx/sap/bc/srt/wsdl/bndg_E417CA96FB8A5FF1B4A8000C293C9303/wsdl11/allinone/standard/document?sap-client=100";

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

  $HEAD_DATA = new stdClass();
  $HEAD_DATA->Material = 'WM-999996';
  $HEAD_DATA->IndSector = 'M';
  $HEAD_DATA->MatlType = 'FERT';
  $HEAD_DATA->BasicView = 'X';

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

  #Call Operation (Function). Catch and display any errors
  try
  {
     $result = $client->StandardMaterialSaveData($params);
  }
  catch (SoapFault $exception)
  {
      print "***Caught Exception***\n";
      print_r($exception);
      print "***END Exception***\n";
      die();
  }

  #Out the results
  print_r($result);

但是它给了我以下错误:SOAP-ERROR:编码:对象没有' HeadData'属性

我认为以下几行是错误的:

  $HEAD_DATA = new stdClass();
  $HEAD_DATA->Material = 'WM-999996';
  $HEAD_DATA->IndSector = 'M';
  $HEAD_DATA->MatlType = 'FERT';
  $HEAD_DATA->BasicView = 'X';

任何人都可以帮助我并告诉我如何正确地将HEAD_DATA变量添加到webservice调用中吗?

0 个答案:

没有答案