douche3791 2013-07-17 19:12
浏览 155

PHP SOAPClient请求问题

I am trying to call this web service http:// 115. 186. 182.11/csws/Service.asmx?op=SendSMS with following PHP code but it gives me exception Error mate in Script: Server was unable to process request. ---> Object reference not set to an instance of an object.

Will highly appreciate your help on this.

try     {       

$client = new SoapClient("http://115.186.182.11/csws/Service.asmx?wsdl"); 

$method = 'SendSMS';

$params = array(
new SoapParam('xxxxx', 'Src_nbr'),
new SoapParam('xxxxxx', 'Password'),
new SoapParam('xxxxx', 'Dst_nbr'),
new SoapParam('xxxxx', 'Mask'),
new SoapParam('Message is test message', 'Message')
);

$result = $client->__call($method,$params);

}
catch(SoapFault $e){
echo "Error mate in Script: " . $e->getMessage();
}

echo "<pre>";
var_dump($result);
echo "</pre>";

$xmlobj = simplexml_load_string($result);
print_r($xmlobj);

FOllowing is the specification...

POST /csws/Service.asmx HTTP/1.1
Host: 115.186.182.11
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/SendBulkSMS"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SendBulkSMS xmlns="http://tempuri.org/">
      <Src_nbr>string</Src_nbr>
      <Password>string</Password>
      <Dst_nbr>xmlxml</Dst_nbr>
      <Mask>string</Mask>
      <Message>string</Message>
    </SendBulkSMS>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SendBulkSMSResponse xmlns="http://tempuri.org/">
      <SendBulkSMSResult>
        <string>string</string>
        <string>string</string>
      </SendBulkSMSResult>
    </SendBulkSMSResponse>
  </soap:Body>
</soap:Envelope>
  • 写回答

1条回答 默认 最新

  • dongmeijian1716 2013-08-01 07:16
    关注

    I followed the below method finally and it is working perfect in production.

    $fields = '<?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
      <soap12:Body>
        <SendSMS xmlns="http://tempuri.org/">
          <Src_nbr>xxxx</Src_nbr>
          <Password>123</Password>
          <Dst_nbr>xxxxxxxxxx</Dst_nbr>
          <Mask>xxxk</Mask>
          <Message>Aoa, This is Test. From xxx.</Message>
          <TransactionID>11122276</TransactionID>     
        </SendSMS>
      </soap12:Body>
    </soap12:Envelope>'; 
    echo $fields;
    
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $postUrl); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, "$fields");
    $response = curl_exec($ch); 
    curl_close ($ch);
    

    In production the SMS API was using this code and code was exected more than 20 time per seconds and performance is good as-well.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog