Question

Je suis en train de faire un appel non-WSDL en PHP (5.2.5) comme celui-ci. Je suis sûr que je manque quelque chose simple. Cet appel a un paramètre, une chaîne, appelée « fuseau horaire »:

    $URL = 'http://www.nanonull.com/TimeService/TimeService.asmx';

    $client = new SoapClient(null, array(
        'location' => $URL,
        'uri'      => "http://www.Nanonull.com/TimeService/",
        'trace'    => 1,
        ));

// First attempt:
// FAILS: SoapFault: Object reference not set to an instance of an object
   $return = $client->__soapCall("getTimeZoneTime",
       array(new SoapParam('ZULU', 'timezone')),
       array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
    );

// Second attempt:
// FAILS: Generated soap Request uses "param0" instead of "timezone"
   $return = $client->__soapCall("getTimeZoneTime",
       array('timezone'=>'ZULU' ),
       array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
   );

Merci pour toutes suggestions
-Dave

Était-ce utile?

La solution 2

Merci. Voici l'exemple complet qui fonctionne maintenant:

$URL = 'http://www.nanonull.com/TimeService/TimeService.asmx';

$client = new SoapClient(null, array(
    'location' => $URL,
    'uri'      => "http://www.Nanonull.com/TimeService/",
    'trace'    => 1,
    ));

$return = $client->__soapCall("getTimeZoneTime",
   array(new SoapParam('ZULU', 'ns1:timezone')),
   array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
);

Autres conseils

La solution @ Dave C ne fonctionne pas pour moi. En regardant autour, je suis venu avec une autre solution:

$URL = 'http://www.nanonull.com/TimeService/TimeService.asmx';

$client = new SoapClient(null, array(
    'location' => $URL,
    'uri'      => "http://www.Nanonull.com/TimeService/",
    'trace'    => 1,
    ));

$return = $client->__soapCall("getTimeZoneTime",
   array(new SoapParam(new SoapVar('ZULU', XSD_DATETIME), 'timezone')),
   array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
);

Espérons que cela peut aider quelqu'un.

Le problème se situe quelque part dans le manque d'information d'espace de noms dans le paramètre. J'ai utilisé le premier cas de votre exemple, car il était le plus proche de ce que je suis venu avec.

Si vous modifiez la ligne:

array(new SoapParam('ZULU', 'timezone')),

à:

array(new SoapParam('ZULU', 'ns1:timezone')),

il devrait vous donner le résultat que vous attendiez.

Vous pouvez essayer d'ajouter un autre appel array() autour de vos params comme ceci:

$params = array('timezone'=>'ZULU' );
$return = $client->__soapCall("getTimeZoneTime",
    array($params),
    array('soapaction' => 'http://www.Nanonull.com/TimeService/getTimeZoneTime')
);

Je ne peux pas tester cela, mais vous pouvez.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top