I'm using a local WSDL to make service calls. I'm fine passing/retrieving data when one parameter is expected by the service method(s), but when the method expects 2 or more parameters it errors out. Ironically, when I attempt to pass 2 or more parameters it says that it only expects 1. The method establishIdentity expects 2 parameters (processId=string & identityAttributes = object made up of the properties found in the code below.) I've include the errors for passing 1 and 2 parameters.
<?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);
?>
Error when passing 1 parameter:
TYPE: stringNS: 223205
Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in C:\\wamp\\www\\SugarCE\\testSOAPShawn.php:33 Stack trace: #0 [internal function]: SoapClient->_ doRequest(' _call('establishIdenti...', Array) #2 C:\\wamp\\www\\SugarCE\\testSOAPShawn.php(33): SoapClient->establishIdentity('223205')> > #3 {main} thrown in C:\\wamp\\www\\SugarCE\\testSOAPShawn.php on line 33
Error when passing 2 parameters:
TYPE: stringNS: 237506
Fatal error: Uncaught 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:33 Stack trace: #0 [internal function]: SoapClient->__call('establishIdenti...', Array) #1 C:\\wamp\\www\\SugarCE\\testSOAPShawn.php(33): SoapClient->establishIdentity('237506', Object(IdentityAttributes)) #2 {main} thrown in C:\\wamp\\www\\SugarCE\\testSOAPShawn.php on line 33
Any and all assistance is greatly appreciated!
Answered: Since the WSDL contained a complexType, I needed to pass one parameter which contained both the processId and identityAttributes. Here is my PHP code:
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.