Я пытаюсь связаться с API через PEAR SOAP Я могу создать запрос SOAP со следующим кодом, но он не является полным.pear soap xml request
<?php
require_once 'SOAP/Client.php';
$client = new SOAP_Client('https://api.mindbodyonline.com/0_5/SiteService.asmx?
wsdl',true);
$options = array('namespace' => 'http://schemas.xmlsoap.org/soap/envelope/',
'trace' => 1,
'SOAPAction' => 'http://clients.mindbodyonline.com/api/0_5/GetLocations',
'Host'=> 'clients.mindbodyonline.com'
);
$ret = $client->call(
'GetLocations',
array(
'Request'=>array('SourceCredentials' => array('SourceName'=>'*****','Password'=>'*****************','siteIDs'=> array('int'=>'23661'))),'XMLDetail'=>'Full','PageSize'=>'10','CurrentPageIndex'=>'0')
,$options);
echo '<pre>'.htmlspecialchars($client->getLastRequest()).'</pre>';
?>
Это приводит к следующему запрос SOAP:
POST /0_5/SiteService.asmx HTTP/1.0
User-Agent: PEAR-SOAP @[email protected]
Host: api.mindbodyonline.com
Content-Type: text/xml; charset=UTF-8
Content-Length: 464
SOAPAction: "http://clients.mindbodyonline.com/api/0_5/GetLocations"
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns4="http://clients.mindbodyonline.com/api/0_5">
<SOAP-ENV:Body>
<ns4:GetLocations>
<Request>Array</Request></ns4:GetLocations>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Когда он должен быть в следующем формате:
POST http://clients.mindbodyonline.com/api/0_5/SiteService.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://clients.mindbodyonline.com/api/0_5/GetLocations"
Host: clients.mindbodyonline.com
Content-Length: 795
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<GetLocations xmlns="http://clients.mindbodyonline.com/api/0_5">
<Request>
<SourceCredentials>
<SourceName>{SourceName}</SourceName>
<Password>{Password}</Password>
<SiteIDs>
<int>{SiteID}</int>
</SiteIDs>
</SourceCredentials>
<XMLDetail>Bare</XMLDetail>
<PageSize>10</PageSize>
<CurrentPageIndex>0</CurrentPageIndex>
<Fields>
<string>Locations.Name</string>
<string>Locations.City</string>
</Fields>
</Request>
</GetLocations>
</soapenv:Body>
</soapenv:Envelope>
Может быть, мне нужен новый набор глаза, чтобы посмотреть на это так как я занимался этим за МНОГИЕ часы. Любые ввод или предложения будут оценены.
WSDL ссылка: https://api.mindbodyonline.com/0_5/SiteService.asmx?wsdl
UPDATE: Используя класс SOAP_WSDL, а затем SOAP_Client класс я был в состоянии получить запрос XML SOAP немного ближе к тому, что в версии из милиции.
<?php
$WSDL=new SOAP_WSDL('https://api.mindbodyonline.com/0_5/SiteService.asmx?wsdl',array (trace=>1));
$proxy=$WSDL->getProxy();
$params = array('Request'=>array('SourceCredentials' => array('SourceName'=>'StudioSevaYoga','Password'=>'******','siteIDs'=>array('int'=>'23661')),'XMLDetail'=>'Full','PageSize'=>'10','CurrentPageIndex'=>'0'));
$options=array('soapaction'=> 'http://clients.mindbodyonline.com/api/0_5/GetLocations');
$ret = $proxy->call("GetLocations",$params,$options);
var_dump($ret);
?>
Я тогда смог вытащить этот SOAP Envelope XML из var_dump:
["outgoing_payload"]=>
string(1118) "POST /0_5/SiteService.asmx HTTP/1.0
User-Agent: PEAR-SOAP @[email protected]
Host: api.mindbodyonline.com
Content-Type: text/xml; charset=UTF-8
Content-Length: 862
SOAPAction: "http://clients.mindbodyonline.com/api/0_5/GetLocations"
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<GetLocations>
<Request>
<SourceCredentials>
<SourceName xsi:type="xsd:string">StudioSevaYoga</SourceName>
<Password xsi:type="xsd:string">*****</Password>
<siteIDs>
<int xsi:type="xsd:string">23661</int></siteIDs></SourceCredentials>
<XMLDetail xsi:type="xsd:string">Full</XMLDetail>
<PageSize xsi:type="xsd:string">10</PageSize>
<CurrentPageIndex xsi:type="xsd:string">0</CurrentPageIndex></Request></GetLocations>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Я до сих пор Получать эту ошибку в var_dump, а также: сервер не смог обработать запрос. --- Ссылка на объект не установлена в экземпляр объекта
Если у кого есть глаза для вытаскивания проблем из var_dump, его можно найти здесь: Pear Soap Request Page Кажется, что он неоднократно повторял ту же информацию. Любые указания или ввод приветствуются, спасибо.
Я использую PEAR SOAP 0.9.1 и PHP 5.2
Использовать встроенный SOAP-класс PHP. Нет причин не использовать его. – cweiske
Да, я согласен, к сожалению, моя хостинговая компания (fatcow) не поддерживает PHP SOAP. Они предлагают только PEAR SOAP. –
@DavidMcCarran: Вы можете принять свой ответ :) (рекомендуется, он будет отмечать ваш вопрос как решенный!) – hakre