我能够将本地WSDL用于PHP,并成功传递/返回基本数据,但是当我尝试传入与WSDL中的复杂类型相对应的对象时,我收到以下错误:
SoapFault异常:[soapenv:Server] 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:\ WAMP \ WWW \ SugarCE \ testSOAPShawn.php:65 堆栈跟踪:#0 [内部功能]: SoapClient-> __通话( 'establishIdenti ......', 数组)#1 C:\瓦帕\ WWW \ SugarCE \ testSOAPShawn.php(65): SoapClient-> establishIdentity(对象(stdClass的), 对象(stdClass))#2 {main}
以下是WSDL的片段:
<xsd:element name="establishIdentity">
−
<xsd:complexType>
−
<xsd:sequence>
−
<xsd:element name="processId" nillable="true" type="xsd:string">
−
<xsd:annotation>
−
<xsd:documentation>
Identifies a specific instance of the dialogue process. Returned from the start() operation.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
−
<xsd:element name="identityAttributes" nillable="true" type="bons1:IdentityAttributes">
−
<xsd:annotation>
−
<xsd:documentation>
Key identifying attributes of a program participant.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
以下是我的代码,其中包含错误发生的注释:
<?php
set_time_limit(0);
require_once('nusoap.php');
$client = new SoapClient('C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP.wsdl', array('trace' => 1));
$start = $client->__soapCall('start', array(new SoapParam((string)'GenesisID', 'prefix')),
array('soapaction' => 'C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP\start'));
$processID = $start;
$exchange = $client->__soapCall('exchangeOptions', array(new SoapParam($processID, 'processId')),
array('soapaction' => 'C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP\exchangeOptions'));
$identityAttributes = new StdClass();
$identityAttributes->IdentityAttributes = new StdClass();
$identityAttributes->IdentityAttributes->ssn = 41441414;
$identityAttributes->IdentityAttributes->firstName = 'John2';
$identityAttributes->IdentityAttributes->lastName = 'Doe2';
$identityAttributes->IdentityAttributes->gender = 'MALE';
$identityAttributes->IdentityAttributes->birthDate = null;
try{
$identity = $client->establishIdentity($processID, $identityAttributes); //ERROR
} catch (SoapFault $f){
echo "ERROR!";
}
$end = $client->__soapCall('stop', array(new SoapParam($processID, 'processId')),
array('soapaction' => 'C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP\stop'));
?>
非常感谢任何帮助!感谢。
答案 0 :(得分:2)
establishIdentity函数只需要一个参数,你传递两个参数。从过去使用SOAP和PHP开始,我发现通常需要将complexTypes作为数组传递。
我建议尝试将调用establishIdentity的行更改为以下
$identity = $client->establishIdentity(
array(
"processId"=>$processID,
"identityAttributes"=>$identityAttributes
)
);