SOAP WSDL php请求

时间:2015-02-06 17:24:10

标签: php xml soap wsdl request

我试图通过SOAP发送请求,并调用服务功能。我有WSDL文件,它返回可用的函数' s。 这是我的代码示例:

ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL &~ (E_NOTICE | E_STRICT));
ini_set("soap.wsdl_cache_enabled", 0);

$wsdl = 'source/HPSMInteractionsFromMosRu.wsdl';
$client = new SoapClient($wsdl,
    array(
        'trace' => 1,
        'exception' => 0
    ));

$res = $client->RetrieveHPSMInteractionsFromMosRuKeysList(array(
    'Portal' => 'Portal_example',
    'CK' => 'CK_example'
));

print_r($res);

这给我一个错误:

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'model' property in *my_path* Stack trace: #0 *my_path* (24): SoapClient->__soapCall('RetrieveHPSMInt...', Array) #1 {main} thrown in *my_path* on line 24

然而,如果我尝试通过SoapUI程序执行该请求,使用相同的WSDL文件,我会发出该XML请求:

    <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:RetrieveHPSMInteractionsFromMosRuKeysListRequest>
         <ns:model>
             <ns:keys>
               <ns:ID></ns:ID>
            </ns:keys>
             <ns:instance>
                <ns:Portal>Portal_example</ns:Portal>
                <ns:CK>CK_example</ns:CK>
          </ns:instance>
          </ns:model>
      </ns:RetrieveHPSMInteractionsFromMosRuKeysListRequest>
   </soapenv:Body>
</soapenv:Envelope>

我是SOAP新手。但我如何理解,我必须使用XML中的参数调用函数,并使用相关的数组。

1 个答案:

答案 0 :(得分:1)

我只使用过少量的SOAP,但因为它提到了缺少&#34;模型&#34;我认为你的请求应该是这样的:

$res = $client->RetrieveHPSMInteractionsFromMosRuKeysList(array(
    'model' => array(
        'keys' => array(
            'ID' => ''
        ),
        'instance' => array(
          'Portal' => 'Portal_example',
          'CK' => 'CK_example'
        ),
    ),
));