我目前正在从我似乎无法正常工作的表单发出 SOAP 请求。我已经检查并仔细检查了我的测试值是否正确,并且似乎根本没有任何区别。
我得到:
“错误:0 服务器无法处理请求。---> 值不能为空。参数名称:g”
每当我尝试提交到 SOAP api 时。这是我的代码(它在 Joomla MVC 组件结构中,所以我将挑选相关代码):
这是我的控制器表单,它从表单中获取输入字段并将它们放入一个数组中以发送到 SOAP api:
public function submitForm1 () {
$input = JFactory::getApplication()->input;
$postVar = array();
//$time = date("m-d- G-i-s", $_POST['dob']);
$postVar['title'] = $input->get('title', null, 'string');
$postVar['firstname'] = $input->get('firstname', null, 'string');
$postVar['lastname'] = $input->get('lastname', null, 'string');
$postVar['email'] = $input->get('email', null, 'string');
$postVar['mobile'] = $input->get('mobile', null, 'string');
$postVar['home'] = $input->get('home', null, 'string');
//'dob' needs to be amended
$postVar['dob'] = date("Y-m-d",strtotime(time()));
$postVar['addline1'] = $input->get('addline1', null, 'string');
$postVar['addline2'] = $input->get('addline2', null, 'string');
$postVar['addline3'] = $input->get('addline3', null, 'string');
$postVar['town'] = $input->get('town', null, 'string');
$postVar['county'] = $input->get('county', null, 'string');
$postVar['postcode'] = $input->get('postcode', null, 'string');
$postVar['gender'] = $input->get('gender', null, 'string');
//'membertype' needs to be amended
$postVar['membertype'] = "test";
$postVar['gymguid'] = $input->get('gymguid', null, 'string');
$postVar['rateguid'] = $input->get('rateguid', null, 'string');
//These questions need to be amended
$postVar['WheredidyouhearaboutFitspace'] = "test";
$postVar['Whydoyouwantojointhegym'] = "test";
$postVar['socialfacebook'] = "test";
$postVar['socialtwitter'] = "test";
$postVar['socialfoursquare'] = "test";
//These dd details need to be amended
$postVar['DDrefnum'] = "test";
$postVar['promoguid'] = "test";
$postVar['DDfirstpayment'] = date("Y-m-d",strtotime(time()));
$postVar['StartofCurrentCon'] = date("Y-m-d",strtotime(time()));
$postVar['DDdayofmonth'] = 0; //Int
if(isset($postVar['student'])) {
$postVar['student'] = $input->get('student', null, 'int');;
} else {
$postVar['student'] = 0;
}
$postVar['PT'] = 0;
$postVar['ContactOptOut'] = 0;
$postVar['gyminductiondeclined'] = 0;
$postVar['Pinrequired'] = 0;
$model = $this->getModel('signup');
$model->submitForm1($postVar);
}
以及调用相应 SOAP 函数的模型函数:
public function submitForm1($postVar) {
$client = $this->createSoapRequest();
$url = 'https://webservice.com/MHservice.asmx?WSDL';
$options["connection_timeout"] = 25;
$options["location"] = $url;
$options['trace'] = 1;
$options['style'] = SOAP_RPC;
$options['use'] = SOAP_ENCODED;
$client = new SoapClient($url, $options);
$response = $client->FITaddupdatemember($postVar);
}
如您所见,我已确保所有字段都输入了真实或测试数据,并且该方法存在。此外,所有必填字段均已必填。我不知道为什么这不起作用,谷歌搜索也无法解决我的问题。现在已经一两天了,希望有人能在这里提供帮助!谢谢詹姆斯