PHP: WSDL, клиент веб-службы, ComplexType

Я могу использовать локальный WSDL в PHP и успешно передавать/возвращать основные данные, но когда я пытаюсь передать объекты, соответствующие сложному типу в WSDL, я получаю следующую ошибку:

Исключение 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:65 Трассировка стека: #0 [внутренняя функция]: SoapClient->__call('installIdenti...', Array) #1 C:\wamp\www\SugarCE\ testSOAPShawn.php(65): SoapClient->installIdentity(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'));

?>

Любая помощь приветствуется! Спасибо.


person user464180    schedule 16.02.2011    source источник


Ответы (1)


Для функции installIdentity требуется только один параметр, вы передаете два. Работая с SOAP и PHP в прошлом, я обнаружил, что сложные типы обычно нужно передавать как массивы.

Я бы предложил попробовать изменить строку, которая вызывает installIdentity, на следующую

$identity = $client->establishIdentity(
    array(
        "processId"=>$processID, 
        "identityAttributes"=>$identityAttributes
    )
);
person David Gillen    schedule 17.02.2011
comment
InstallIdentity ожидает только один параметр сложного типа. Этот сложный тип содержит последовательность из двух элементов: processId типа string и identityAttributes другого типа, не включенного в ваш wsdl. Вы создаете StdClass $identityAttributes, который имеет одно свойство identityAttributes, которое затем имеет различные свойства, правильно ли это? Попробуйте следующее, но опять я в темноте без полного WSDL. Опустите строку $identityAttributes->IdentityAttributes = new StdClass(); и поместите остальные в $identityAttributes->ssn = 41441414; и т. д. - person David Gillen; 18.02.2011