PHP SoapClient demande

Je suis en train d'envoyer une requête SOAP à un service de newsletter à l'aide de cette WSDL.

Voici mon PHP:

$client = new SoapClient($wsdl_url, array(
    'login' => 'myusername',
    'password' => 'mypassword',
    'trace' => true
));

$client->AddSubscriber(
    new SoapParam('MyFirstName', 'FirstName'),
    new SoapParam('MyLastName', 'LastName'),
    new SoapParam('[email protected]', 'Email')
);

Je suis l'exception:

End element 'Body' from namespace 'schemas.xmlsoap.org/soap/envelope/' expected. Found element 'LastName' from namespace ''. Line 2, position 156.

Voici ce que le service attend pour AddSubscriber:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <AuthHeader xmlns="admin.ekeryx.com">
      <Username>string</Username>
      <Password>string</Password>
      <AccountID>string</AccountID>
    </AuthHeader>
  </soap:Header>
  <soap:Body>
    <AddSubscriber xmlns="admin.ekeryx.com">
      <subscriber>
        <ID>string</ID>
        <FirstName>string</FirstName>
        <LastName>string</LastName>
        <Email>string</Email>
      </subscriber>
      <overwritable>boolean</overwritable>
    </AddSubscriber>
  </soap:Body>
</soap:Envelope>

Voici ce qui est d'être envoyées:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="tempuri.org/">
    <SOAP-ENV:Body>
        <ns1:AddSubscriber/>
            <LastName>MyLastName</LastName>
            <Email>[email protected]</Email>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Je ne suis pas très familier avec le SAVON, et j'ai été chercher de la documentation dans tous les sens, mais je n'arrive pas à trouver une très bonne référence pour ce que je suis en train de faire.

Toute orientation serait très apprécié!


Grâce. Pourriez-vous me donner un exemple? Je suis en train de regarder l'exemple sur le PHP du site qui indique:

<?php
class SOAPStruct {
    function SOAPStruct($s, $i, $f) 
    {
        $this->varString = $s;
        $this->varInt = $i;
        $this->varFloat = $f;
    }
}
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
                                     'uri'      => "http://test-uri/"));
$struct = new SOAPStruct('arg', 34, 325.325);
$soapstruct = new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPStruct", "http://soapinterop.org/xsd");
$client->echoStruct(new SoapParam($soapstruct, "inputStruct"));
?>

Vous dites que je dois créer un Abonné de la classe PHP, affecter tous les vars $this->FirstName = $first_name, etc... et puis le mettre dans un SoapVar avec le codage SOAP_ENC_OBJECT? Comment puis-je mieux représenter l'abonné structure?

Veuillez noter, j'ai enlevé le http:// de toutes les Url dans le code afin de respecter le nombre maximal de 1 lien hypertexte par la poste à la règle.

OriginalL'auteur | 2009-11-24