我正在使用本地WSDL进行服务调用。当服务方法预期有一个参数时,我很好地传递/检索数据,但是当方法需要2个或更多参数时,它会出错。具有讽刺意味的是,当我尝试传递2个或更多参数时,它表示它只需要1.方法establishIdentity需要2个参数(processId = string& identityAttributes = object由以下代码中的属性组成。)我已经包含传递1和2参数的错误。
<?php
set_time_limit(0);
require_once('nusoap.php');
require_once('BenefitSOAP.php');
$client = new SoapClient('C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP.wsdl', array('trace' => 1));
$procID = (array)$client->start(array("prefix"=>""));
$newStringID = implode(null, $procID); //
$exchange = $client->exchangeOptions($procID);
$identityAttributes = new IdentityAttributes();
$identityAttributes->ssn = 41441414;
$identityAttributes->firstName = 'John2';
$identityAttributes->lastName = 'Doe2';
$identityAttributes->gender = 'MALE';
$identityAttributes->birthDate = NULL;
echo "TYPE: ".gettype($newStringID);
echo "NS: ".$newStringID;
$identity = $client->establishIdentity($newStringID); //LINE 33
//$identity = $client->establishIdentity($newStringID, $identityAttributes); OR LINE 33//establishIdentity expects 2 parameters (processId = string, identityAttributes = object)
$end = $client->stop($procID);
?>
传递1个参数时出错:
TYPE:stringNS:223205
致命错误:未被捕获的SoapFault 异常:[HTTP]错误获取http 标题 C:\瓦帕\ WWW \ SugarCE \ testSOAPShawn.php:33 堆栈跟踪:#0 [内部功能]: SoapClient-&GT; _ doRequest( ' _call(' establishIdenti ...', 数组)#2 C:\瓦帕\ WWW \ SugarCE \ testSOAPShawn.php(33): SoapClient-&GT; establishIdentity( '223205')&GT; &GT; #3 {main}抛出C:\ wamp \ www \ SugarCE \ testSOAPShawn.php 在第33行
传递2个参数时出错:
TYPE:stringNS:237506
致命错误: 未捕获的SoapFault异常: [soapenv:服务器] javax.xml.ws.WebServiceException: com.ibm.websphere.sca.ServiceRuntimeException: 解析本机时发生错误 data:错误消息是: java.lang.IllegalArgumentException异常: 参数计数不匹配:期待 1项,但得到更多..引起: java.lang.IllegalArgumentException异常: 参数计数不匹配:期待 1项,但得到更多:引起:An 解析本机时发生错误 data:错误消息是: java.lang.IllegalArgumentException异常: 参数计数不匹配:期待 1项,但得到更多..引起: java.lang.IllegalArgumentException异常: 参数计数不匹配:期待 1项,但得到更多。在 C:\瓦帕\ WWW \ SugarCE \ testSOAPShawn.php:33 堆栈跟踪:#0 [内部功能]: SoapClient-&GT; __通话( 'establishIdenti ......', 数组)#1 C:\瓦帕\ WWW \ SugarCE \ testSOAPShawn.php(33): SoapClient-&GT; establishIdentity( '237506', 对象(IdentityAttributes))#2 {main} 投入 C:\ WAMP \ WWW \ SugarCE \ testSOAPShawn.php 在第33行
非常感谢任何和所有的帮助!
答案 0 :(得分:0)
回答:由于WSDL包含complexType,我需要传递一个包含processId和identityAttributes的参数。这是我的PHP代码:
$identityAttributes = new IdentityAttributes();
$identityAttributes->ssn = 41441414;
$identityAttributes->firstName = 'John2';
$identityAttributes->lastName = 'Doe2';
$identityAttributes->gender = 'MALE';
$identityAttributes->birthDate = NULL;
$temp = new stdClass();
$temp->processId = $newStringID;
$temp->identityAttributes = $identityAttributes;
echo "TYPE: ".gettype($newStringID);
echo "NS: ".$newStringID;
$identity = $client->establishIdentity($temp);
var_dump($identity);
$end = $client->stop($procID);