用给定的wsdl从php调用webservice

时间:2013-01-23 17:13:59

标签: php xml soap wsdl

嗨,请告诉我如何获得reposnse

我有一个wsdl,我想通过它调用awebservice 虽然使用soapUI我可以获得reposnse而不是throgh php

我也在提供需要制作的xml请求

 <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header    /><soapenv:Body>
  <q2:OneOffDeductionRequestMsg
   xmlns:q0="http://www.huawei.com/bme/accountmgr"
   xmlns:q1="http://www.huaweiommon"
   xmlns:q2="http://www.accountmgrmsg">
   <RequestHeader>
   <q1:CommandId>OneOffDeduction</q1:CommandId>

   <q1:Version>1</q1:Version>
   <q1:TransactionId/>
   <q1:SequenceId>1</q1:SequenceId>

 <q1:RequestType>Event</q1:RequestType>
   <q1:SessionEntity>
  <q1:Name>NET</q1:Name>
  <q1:Password>084912FA9733C4A0115D</q1:Password>
 <q1:RemoteAddress>10.176.122.2</q1:RemoteAddress>
</q1:SessionEntity>
<q1:SerialNo>192741328589162212</q1:SerialNo>
</RequestHeader>
<OneOffDeductionRequest>
<q0:SubscriberNo>XXXXXX73</q0:SubscriberNo>
<q0:OperationID>4059999</q0:OperationID>
<q0:AdditionalInfo>VNET</q0:AdditionalInfo>
<q0:DeductAmt>100</q0:DeductAmt>
<q0:MinMeasureId>101</q0:MinMeasureId>
</OneOffDeductionRequest>
</q2:OneOffDeductionRequestMsg>
</soapenv:Body></soapenv:Envelope>

以下是使用它的PHP代码:

<?php

  $RequestHeader = array( 
           'CommandId' => 'OneOffDeduction',
    'Version' => '1',
    'TransactionId' => '34234',
    'SequenceId'  =>  '1',
    'RequestType' => 'EVENT',    
    'SerialNo' => '1527013286284589162212');


   $SessionEntity =array(
    'Name'      =>    'V', 
            'Password'  =>    'v',
        'RemoteAddress' =>'10.0.0.0');


 $wsdl ="http://eAccountMgrService?wsdl";
 $client = new SoapClient($wsdl);

  $param =array('SubscriberNo'=>'54321',
 'OperationID' =>'4059999',
 'AdditionalInfo'=>'VAS2NET',
 'DeductAmt'=>'10',
 'MinMeasurId'=>'101');

 var_dump($client);

  $Result = $client->__call('OneoffDeduction',array( 
            'CommandId' => 'OneOffDeduction',
    'Version' => '1',
    'TransactionId' => '34234',
    'SequenceId'  =>  '1',
    'RequestType' => 'ET',    
    'SerialNo' => '1527',
  'sessionEntity' =>array(
    'Name'      =>    'V', 
            'Password'  =>    'v',
        'RemoteAddress' =>'10.0.0.0')));
  var_dump($Result);

  echo $client->__getLastRequest();

 $Response = $client->__call('OneoffDeduction',array('SubscriberNo'=>'54321',
'OperationID' =>'4059999',
' AdditionalInfo'=>'VAET',
 'DeductAmt'=>'10',
'MinMeasurId'=>'101'));

   echo $client->__getLastRequest();
   ?>

1 个答案:

答案 0 :(得分:0)

在您的代码干燥和组织之前,调试问题并不容易/可能。

由于您定义了从未使用的变量,因此您可能会对哪些变量实际发送到API感到困惑 - 例如$params似乎从未以任何形式发送

建议您refer to the soapClient docs确保您传递的是正确的列表。