我们正在尝试将我们的代码与SMS提供程序集成。 他们提供了一个SOAP API但我们遇到了一个问题,我们无法弄清楚原因。很遗憾,SMS提供商也无法回答我们的问题。
所以这就是问题所在:
我们正在尝试调用' SaveNewSchedulSendSms_Daily 'API:
class ScheduleSend_Daily
{
public $Id;
public $MessageBody;
public $FromDate;
public $FromDate_Date;
public $FromDate_Time;
public $ToDate;
public $ToDate_Date;
public $ToDate_Time;
public $Time;
public $SmsLineID;
public $MobileNumbers;
public $IsFlash;
public $IsChecked;
public $SendType;
public $SmsSendType;
}
$ScheduleSend_Daily = new ScheduleSend_Daily();
$ScheduleSend_Daily->Id = '-1';
$ScheduleSend_Daily->MessageBody = $SMS_TEXT;
$ScheduleSend_Daily->FromDate = $DATE_TIME[0].'T00:00:00';
$ScheduleSend_Daily->FromDate_Date = $DATE_TIME[0];
$ScheduleSend_Daily->FromDate_Time = '00:00:00';
$ScheduleSend_Daily->ToDate = $DATE_TIME[0].'T23:59:59';
$ScheduleSend_Daily->ToDate_Date = $DATE_TIME[0];
$ScheduleSend_Daily->ToDate_Time = '23:59:59';
$ScheduleSend_Daily->Time = $DATE_TIME[0].'T'.$DATE_TIME[1].':00';
$ScheduleSend_Daily->SmsLineID = LINE_NUMBER;
$ScheduleSend_Daily->MobileNumbers = array (doubleval(USER_NUMBER));
$ScheduleSend_Daily->IsFlash = 0;
$ScheduleSend_Daily->IsChecked = 0;
$ScheduleSend_Daily->SendType = 'SendOnSchedule_Daily';
$ScheduleSend_Daily->SmsSendType = 'SendOnSchedule_Daily';
$client = new SoapClient('http://ip.sms.ir/ws/SendReceive.asmx?wsdl');
$params = array (
'userName' => SMS_USERNAME,
'password' => SMS_PASSWORD,
'DailyScheduleSend' => $ScheduleSend_Daily);
$result = $client->SaveNewSchedulSendSms_Daily($params);
注意:他们要求我们将日期时间发送为'yyyy-mm-ddThh:mm:ss'
这将导致以下错误
stdClass Object
(
[SaveNewSchedulSendSms_DailyResult] => -10
[message] => Object reference not set to an instance of an object.
)
那么,是什么导致了这个?
由于
更新
我已将缺少的参数添加到对象中。 感谢@PratikSoni指出这一点。 它还需要'IsChecked'参数,这很奇怪!
现在我收到以下错误:
PHP Fatal error: Uncaught SoapFault exception: [soap:Client] System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (2, 344). ---> System.OverflowException: Value was either too large or too small for an Int32. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read9_ScheduleSend_Daily(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read33_SaveNewSchedulSendSms_Daily() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer20.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingSt
答案 0 :(得分:0)
您传递的参数不正确,参数数量应与soap调用中的要求相同。
以下是您必须传递的所有参数的列表。
<s:element minOccurs="1" maxOccurs="1" name="SmsLineID" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="MobileNumbers" type="tns:ArrayOfLong"/>
<s:element minOccurs="1" maxOccurs="1" name="SmsSendType" type="tns:SMSSentTypes"/>
<s:element minOccurs="1" maxOccurs="1" name="Time" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="IsFlash" type="s:boolean"/>
<s:element minOccurs="1" maxOccurs="1" name="ToDate" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="FromDate" type="s:dateTime"/>
<s:element minOccurs="0" maxOccurs="1" name="MessageBody" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="Id" type="s:long"/>
<s:element minOccurs="0" maxOccurs="1" name="SendType" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="FromDate_Time" type="tns:TimeSpan"/>
<s:element minOccurs="1" maxOccurs="1" name="ToDate_Time" type="tns:TimeSpan"/>
<s:element minOccurs="0" maxOccurs="1" name="FromDate_Date" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ToDate_Date" type="s:string"/>
请记住,名称是您要从您身边传递的参数。