P
P
PGSky2019-08-19 06:37:59
PHP
PGSky, 2019-08-19 06:37:59

How to properly connect via PHP SOAP to the booking-manager API?

Hello. I decided to connect the output of yachts through the Booking-Manager.com API. SOAP must be used.
The site itself is on Wordpress, and the hosting is Beget, but it doesn't matter, because. before connecting all this, I decided to at least try to test how it works, through a test file, the code is as follows (as in the documentation with minor additions):

class MMKStruct {
 /**
 * Constructor
 *
 * @param $a ­ array of parameters
 * @ret void
 */
 	public function __construct($a) {
 		$i = 0;
 		foreach ($a as $var => $val) {
 			$varName = 'in' . $i;
 			$this->$varName = $val;
 			$i++;
 		}
 	}
}
// Specify url
$wsdl = 'https://www.booking-manager.com/cbm_web_service2/services/CBM?wsdl';
$arrContextOptions=array("ssl"=>array( "verify_peer"=>false, "verify_peer_name"=>false,'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT)); 
$options = array(
        'exceptions'=>true,
        'trace'=>1,
        'cache_wsdl'=>WSDL_CACHE_NONE,
        'stream_context' => stream_context_create($arrContextOptions),
    'keep_alive' => false,
);
$soapClient = new SoapClient($wsdl, $options);

try {
  $struct = new MMKStruct(array(Здесь ID пользователя-Компании,'Здесь E-mail','Здесь Пароль','635','2019', 'true',0));
  $result = $soapClient->__soapCall('getAvailabilityInfo',array($struct));
  if(isset($result->out)) {
    $xml = $result->out;
    echo $xml;
  }
  var_dump($result);
}
catch (Exception $e) {
  print_r($e->getMessage());
  print_r($soapClient->__getLastRequest());
  print_r($soapClient->__getLastResponse());
}

As a result, I got an error 500 (on the getResources function, it is not in the code here) in the browser. I replaced the function (because I’m still testing and the moment with the 500 error can be fixed later, I thought that it receives too much data, but I may not understand how SOAP specifically works) with getAvailabilityInfo (you can see it in the code). There is no error 500, but for that there was an error "soap:ServerIllegal access to entity"
Please tell me the solution or direction where to look (by error "soap:ServerIllegal access to entity" and if possible by error 500).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hanneman, 2019-08-21
@PGSky

I endure in response: there is no technical error, since, using your real authorization parameters, everything works. As for error 102, this is a functional logical error on the server side - it does not like the value of company 635, since simply substituting a company with an identifier of 634, everything works on a technical level and the answer is returned correctly (check what is wrong with company 635):
PS Remove the real authorization data from the subject and from your code response (just in case).
Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:cbm="http://cbm.mmk.com">
    <soapenv:Header/>
    <soapenv:Body>
        <cbm:getAvailabilityInfo>
            <cbm:in0>2547</cbm:in0>
            <cbm:in1>[email protected]</cbm:in1>
            <cbm:in2>yourPassword</cbm:in2>
            <cbm:in3>634</cbm:in3>
            <cbm:in4>2019</cbm:in4>
            <cbm:in5>false</cbm:in5>
            <cbm:in6>1970-01-01T03:00:00</cbm:in6>
        </cbm:getAvailabilityInfo>
    </soapenv:Body>
</soapenv:Envelope>

Answer:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
        <ns1:getAvailabilityInfoResponse xmlns:ns1="http://cbm.mmk.com">
            <ns1:out><![CDATA[<root company_id="634" checktime="1566366427662">
<reservation id="1806870766300634" resourceid="279865120000100634" status="Reservation" blocksavailability="1" datefrom="2018-12-31" dateto="2019-01-14" basefrom="85" baseto="85" optionexpirydate="2018-08-22" created="2018-08-15" lastmodified="2018-08-15" companyid="634" />
<reservation id="2090990766300634" resourceid="1684801290000100634" status="Reservation" blocksavailability="1" datefrom="2019-02-04" dateto="2019-02-07" basefrom="85" baseto="85" optionexpirydate="2019-02-05" created="2019-02-04" lastmodified="2019-02-04" companyid="634" />
<reservation id="2206700766300634" resourceid="1684387260000100634" status="Canceled" blocksavailability="0" datefrom="2019-12-13" dateto="2019-12-25" basefrom="85" baseto="85" optionexpirydate="2019-06-05" created="2019-05-28" lastmodified="2019-06-06" companyid="634" />
<reservation id="1818390766300634" resourceid="279866040000100634" status="Reservation" blocksavailability="1" datefrom="2019-03-16" dateto="2019-03-26" basefrom="85" baseto="85" optionexpirydate="2018-08-23" created="2018-08-16" lastmodified="2018-08-16" companyid="634" />
<reservation id="2198150766300634" resourceid="2178580766300634" status="Canceled" blocksavailability="0" datefrom="2019-08-17" dateto="2019-08-24" basefrom="85" baseto="85" optionexpirydate="2019-05-26" created="2019-05-20" lastmodified="2019-05-27" companyid="634" />
</root>]]></ns1:out>
        </ns1:getAvailabilityInfoResponse>
    </soap:Body>
</soap:Envelope>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question