简体   繁体   中英

PHP Soap client call

I am desperate. I am trying to call soap request from php like this xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:hot="http://hotelconcepts.com/">   <soapenv:Header>
  <hot:Authentication>
     <!--Optional:-->
     <hot:User>?</hot:User>
     <!--Optional:-->
     <hot:Password>?</hot:Password>
     <!--Optional:-->
     <hot:CrsProperty>?</hot:CrsProperty>
     <!--Optional:-->
     <hot:VendorId>?</hot:VendorId>
     <!--Optional:-->
     <hot:Version>?</hot:Version>
  </hot:Authentication>   
</soapenv:Header>   
<soapenv:Body>
  <hot:CwiPackageAvailabilityDetails>
     <!--Optional:-->
     <hot:PropertyCode>?</hot:PropertyCode>
     <!--Optional:-->
     <hot:Packages>
        <!--Zero or more repetitions:-->
        <hot:string>?</hot:string>
     </hot:Packages>
     <hot:StartDate>?</hot:StartDate>
     <hot:EndDate>?</hot:EndDate>
     <!--Optional:-->
     <hot:Adults>0</hot:Adults>
     <!--Optional:-->
     <hot:Children>0</hot:Children>
     <!--Optional:-->
     <hot:Infants>0</hot:Infants>
     <!--Optional:-->
     <hot:Nights>0</hot:Nights>
  </hot:CwiPackageAvailabilityDetails>

I am trying something like this, but i don´t know how to imitate this xml request by php soap client.

    $client = new SoapClient($this->wsdl);

    $headers = array(
        "Authentication" => array(
            "User" => $this->user,
            "Password" => $this->pass,
            "CrsProperty" => $this->crsProperty
        )
    );

    $client->__setSoapHeaders($headers);

    /* Set your parameters for the request */
    $params = array(
        "User" => $this->user,
        "Password" => $this->pass,
        "CrsProperty" => $this->crsProperty,
        "PropertyCode" => $this->propertyCode,
        "StartDate" => $startDate,
        "EndDate" => $endDate,
        "Adults" => $adults,
        "Children" => $children,

    );
    try {
        /* Invoke webservice method with your parameters, in this case: Function1 */
        $response = $client->__soapCall("CwiPackageAvailabilityDetails", array($params, $headers));
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
        echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
    /* Print webservice response */
    var_dump($response);
}

But i get only this message: Server was unable to process request. ---> Not authenticated for property

Thank you for any help

I would strongly advise you to use the PackageGenerator as if the header is well declared in the WSDL, then you'll have the appropriate method to set it before sending the request. Every parameter is represented by a generated class such as every operation within a proper ServiceType class.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM