簡體   English   中英

PHP / WSDL / SOAP:傳遞參數時出錯

[英]PHP/WSDL/SOAP: Error passing parameters

我正在使用本地WSDL進行服務調用。 當服務方法需要一個參數時,我很好地傳遞/檢索數據,但是當方法需要2個或更多參數時,它會出錯。 具有諷刺意味的是,當我嘗試傳遞2個或更多參數時,它說它只期望1。methodIdentityIdentity期望2個參數(processId = string&identityAttributes =由下面代碼中的屬性組成的對象。)傳遞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個參數時出錯:

類型:字符串NS:223205

致命錯誤:未捕獲的SoapFault異常:[HTTP]在C:\\ wamp \\ www \\ SugarCE \\ testSOAPShawn.php:33中訪存HTTP標頭時出錯:堆棧跟蹤:#0 [內部函數]:SoapClient-> _ doRequest(' _call('EstablishmentIdenti ...',數組)#2 C:\\ wamp \\ www \\ SugarCE \\ testSOAPShawn.php(33):SoapClient-> EstablishmentIdentity('223205')>>#3 {main}放在C:\\ wamp \\ www \\第33行的SugarCE \\ testSOAPShawn.php

傳遞2個參數時出錯:

類型:字符串NS:237506

致命錯誤:未捕獲的SoapFault異常:[soapenv:Server] javax.xml.ws.WebServiceException:com.ibm.websphere.sca.ServiceRuntimeException:解析本機數據時發生錯誤:錯誤消息是:java.lang.IllegalArgumentException:不匹配參數計數:期望1項,但有更多。.原因:java.lang.IllegalArgumentException:參數計數不匹配:期望1項,但有更多。:原因:解析本機數據時發生錯誤:錯誤消息是: java.lang.IllegalArgumentException:參數計數不匹配:預期有1個項目,但是得到了更多。原因:java.lang.IllegalArgumentException:參數計數不匹配:預期有1個項目,但是得到了更多。 在C:\\ wamp \\ www \\ SugarCE \\ testSOAPShawn.php:33中的堆棧跟蹤:#0 [內部函數]:SoapClient-> __ call('EstablishmentIdenti ...',Array)#1 C:\\ wamp \\ www \\ SugarCE \\ testSOAPShawn.php(33):SoapClient-> EstablishmentIdentity('237506',Object(IdentityAttributes))#2 {main}放在第33行的C:\\ wamp \\ www \\ SugarCE \\ testSOAPShawn.php中

任何幫助都將不勝感激!

回答:由於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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM