<?php// Pull in the NuSOAP coderequire_once('lib/nusoap.php');// Create the client instance$client = new nusoap_client('https://api.channeladvisor.com/ChannelAdvisorAPI/v1/inventoryService.asmx?WSDL', true );// Check for an error$err = $client->getError();if ($err){ // Display the errorecho 'Constructor error' . $err . '';// At this point, you know the call that follows will fail}$developerKey = 'developerKey';$password = 'Password';$headers = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/"><soapenv:Header><web:APICredentials><web:DeveloperKey>'.$developerKey.'</web:DeveloperKey><web:Password>'.$password.'</web:Password></web:APICredentials></soapenv:Header><soapenv:Body><web:RequestAccess><web:localID>localID</web:localID></web:RequestAccess></soapenv:Body></soapenv:Envelope>';// Call the SOAP method$result = $client->call('Ping', array(), false, false, $headers);// Check for a faultif ($client->fault){echo 'Fault';print_r($result);echo '';}else {// Check for errors$err = $client->getError();if ($err){ // Display the errorecho 'Error' . $err . ''; }else{ // Display the resultecho 'Result';print_r($result);echo ''; }}// Display the request and responseecho '<h2>Request</h2>';echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';echo '<h2>Response</h2>';echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';// Display the debug messagesecho '<h2>Debug</h2>';echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>'; ?>
POST /ChannelAdvisorAPI/v7/AdminService.asmx HTTP/1.0 Host: api.channeladvisor.com User-Agent: NuSOAP/0.9.5 (1.123) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "http://api.channeladvisor.com/webservices/RequestAccess" Content-Length: 996 <?xml version="1.0" encoding="ISO-8859-1"?><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:Header> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/"> <soapenv:Header> <web:APICredentials> <web:DeveloperKey>DeveloperKey</web:DeveloperKey>
<web:Password>Password</web:Password>
</web:APICredentials> </soapenv:Header> <soapenv:Body> <web:RequestAccess> <web:localID>AccountId/profile ID</web:localID> </web:RequestAccess> </soapenv:Body> </soapenv:Envelope> </SOAP-ENV:Header><SOAP-ENV:Body><RequestAccess xmlns="http://api.channeladvisor.com/webservices/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
HTTP/1.1 200 OK Cache-Control: private, max-age=0 Transfer-Encoding: chunked Content-Type: text/xml; charset=utf-8 Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 X-ServerName: RDU-APPWEB-04 X-Powered-By: ASP.NET
Date: Fri, 07 Mar 2014 09:30:28 GMT