大家经常在写php调用webservice短信接口的时候,遇到过,服务器未能识别 HTTP 头 SOAPAction 的值 这样的错误,找了很长的时间,可能找不到错误在什么地方,我也曾经遇到过类似的情况,后来经过调试,终于解决了,以下是经过调试后的源码,分享给大家
需要一个soap这样的一个东东,需要的,可以在网上下载哦,在这里我就不提供了.
<?php
//短信接口提供商:http://www.56dxw.com
//短信接口测试程序
//$url = "http://jiekou.56dxw.com/sms/HttpInterface.aspx";
$webService_url = "http://jiekou.56dxw.com/WebServiceInterface.asmx";
$comid= "123"; //企业ID
$username= "WEWQE"; //用户名
$userpwd= "2567W657S"; //密码
$smsnumber= "1061"; //所用平台
$handtel= "1302536963"; //手机号
$sendcontent= "测试成功!success!"; //内容限制为70个字,小灵通60个字
$sendtime= ""; //定时时间
header("content-type:textml;charset=utf-8");
require_once('lib/nusoap.php');
$soap = new soapclient($webService_url.'?WSDL', true); //web service 地址
$soap->soap_defencoding = 'utf-8';
$soap->decode_utf8 = false;
$result = $soap ->call("SendNote",array("handtels" => $handtel,"_content"=>$sendcontent, "userName"=> $username , "password"=>$userpwd , "cid"=>$comid, "_sendtime"=>"" , "_smsnumber"=>$smsnumber ));
if ($soap->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $soap->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}