2013-03-27 2 views
2

PEAR SOAP를 통해 API와 통신을 시도하고 있습니다. 다음 코드로 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 : 보다는 내가 requred 버전의 그것과 조금 더 가까이 XML의 SOAP 요청을 얻을 수있었습니다 SOAP_Client 클래스를 SOAP_WSDL 클래스를 사용하여.

<?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); 
?> 

내가 다음 위해서 var_dump에서이 XML SOAP 봉투를 당길 수 있어요 :

["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

+0

PHP의 내장 SOAP 클래스를 사용하십시오. 그것을 사용하지 않을 이유가 없습니다. – cweiske

+0

예, 불행히도 제 호스팅 회사 (fatcow)는 PHP SOAP을 지원하지 않습니다. PEAR SOAP 만 제공합니다. –

+0

@DavidMcCarran : 답변을 자유롭게 수락 할 수 있습니다. :) (귀하의 질문은 해결 된 것으로 표시됩니다.) – hakre

답변

2

내가 여기에 주어진 조언을 사용하여이 작업을 할 수 있었다 : How to generate a PHP soap client code? ..... 배 비누 generateProxyCode() 메소드를 제공하는 모든 적절한을 PEAR SOAP 호출 및 인수를 사용하여 XML SOAP 요청을 서버에 올바르게 전달할 수 있습니다. 나는 생성 된 서비스 코드에 다음 PHP 코드를 성공으로 묶었다.

<?php 
require_once 'SOAP/Client.php'; 
require_once 'wsdl_proxy.php'; 

$proxyLocations= new WebService_Site_x0020_Service_Site_x0020_ServiceSoap(); 

$site=array('int'=>23661); 
$Request = array('SourceCredentials' => array('SourceName'=>'StudioSevaYoga','Password'=>'*********','SiteIDs'=>$site),'XMLDetail'=>'Full','PageSize'=>10,'CurrentPageIndex'=>0); 

$ret=$proxyLocations->GetLocations($Request); 
print_r($Request); 
var_dump($ret); 
?>