2011-02-16 120 views
0

我能够将本地WSDL消费到PHP中,并成功传递/返回基本数据,但是当我尝试传入与WSDL中的复杂类型相对应的对象时,I出现以下错误:PHP:WSDL,Web服务客户端,ComplexType

SoapFault exception: [soapenv:Server] javax.xml.ws.WebServiceException: com.ibm.websphere.sca.ServiceRuntimeException: An error occurred while parsing native data: The error message is: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more.. Caused By: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more.: caused by: An error occurred while parsing native data: The error message is: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more.. Caused By: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more. in C:\wamp\www\SugarCE\testSOAPShawn.php:65 Stack trace: #0 [internal function]: SoapClient->__call('establishIdenti...', Array) #1 C:\wamp\www\SugarCE\testSOAPShawn.php(65): SoapClient->establishIdentity(Object(stdClass), Object(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')); 

?> 

任何援助非常感谢!谢谢。

回答

2

establishIdentity函数只需要一个参数,即传递两个参数。从过去使用SOAP和PHP,我发现complexTypes通常需要作为数组传递。

我建议你尝试改变它调用establishIdentity以下

$identity = $client->establishIdentity(
    array(
     "processId"=>$processID, 
     "identityAttributes"=>$identityAttributes 
    ) 
); 
+0

行我试图以上,并得到了以下错误: – user464180 2011-02-17 14:53:53