duanhuan8983 2012-10-04 15:08
浏览 41
已采纳

使用PHP SoapClient时,参数错误

I'm trying to call to a SOAP WebService using PHP SoapClient, connecting with a WSDL and all is fine and dandy. But when I pass my parameters to make my call, I realized (using "__getLastRequest()") that the params wasn't placed inside my "MyFunction" but rather outside..

PHP code:

$client = new SoapClient("http://wsdlurl.com?WSDL", array("trace" => 1));
$soapMessage = array(
    'DealerCode' =>         'Val0',
    'AscNumber' =>          'Val1',
    'CustOrderNumber' =>    'Val2',
    'OrderDate' =>          'Val3',
    'OrderType' =>          'Val4',
    'ModelCode' =>          'Val5',
    'ObjectName' =>         'Val6',
    'BrandName' =>          'Val7',
    'SerialNumber' =>       'Val8',
    'Name' =>               'Val9',
    'Address' =>            'Val10',
    'PostalCode' =>         'Val11',
    'Town' =>               'Val12',
    'TelephoneNR' =>        'Val13',
    'EmailAddress' =>       'Val14',
    'Company' =>            'Val15',
    'DoorCode' =>           'Val16',
    'CustFaultDescription' => 'Val17',
    'InWarranty' =>         'Val18',
    'PurchaseDate' =>       'Val19',
    'FaultCode' =>          'Val20',
    'GeneralMessage' =>     'Val21'
);

$result = $client->__soapCall('MyFunction', $soapMessage);
$request = $client->__getLastRequest();

Results in this request being sent??

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.url.com/">
  <SOAP-ENV:Body>
    <ns1:MyFunction/>
    <param1>Val1</param1>
    <param2>Val2</param2>
    <param3>Val3</param3>
    <param4>Val4</param4>
    <param5>Val5</param5>
    <param6>Val6</param6>
    <param7>Val7</param7>
    <param8>Val8</param8>
    <param9>Val9</param9>
    <param10>Val10</param10>
    <param11>Val11</param11>
    <param12>Val12</param12>
    <param13>Val13</param13>
    <param14>Val14</param14>
    <param15>Val15</param15>
    <param16>Val16</param16>
    <param17>Val17</param17>
    <param18>Val18</param18>
    <param19>Val19</param19>
    <param20>Val20</param20>
    <param21>Val21</param21>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
  • 写回答

1条回答 默认 最新

  • drr47973 2012-10-10 06:31
    关注

    Turns out you need to include the entire call in the body.. Sounds self explanatory now!

    $soapMessage = array(
      'MyFunction' => 
      array(
        'order' =>
        array(
          'DealerCode' => 'Val1',
          'AscCode' => 'Val2',
        ),
      ),
    )
    $result = $client->__soapCall('MyFunction', $soapMessage);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀