Dashboard > ChannelAdvisor Developer Network > ... > Code Samples > Ping Examples
Log In   View a printable version of the current page.
Added by Andy Berryman, last edited by Andy Berryman on Sep 09, 2008  (view change)
Labels: 
(None)




Raw XML


POST /ChannelAdvisorAPI/v1/CartService.asmx HTTP/1.1
Host: api.0002.dev.channeladvisor.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://api.channeladvisor.com/webservices/Ping"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <APICredentials xmlns="http://api.channeladvisor.com/webservices/">
      <DeveloperKey>string</DeveloperKey>
      <Password>string</Password>
    </APICredentials>
  </soap:Header>
  <soap:Body>
    <Ping xmlns="http://api.channeladvisor.com/webservices/" />
  </soap:Body>
</soap:Envelope>

C# .Net


CartService svc1 = new CartService();
APICredentials credentials = new APICredentials();
credentials.DeveloperKey = "developerkey";
credentials.Password = "password";
svc1.APICredentialsValue = credentials;
APIResultOfString result = svc1.Ping();
Console.WriteLine("Call Result Data:{0}", result.ResultData);


PHP with NuSoap Toolkit


<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('https://api.channeladvisor.com/ChannelAdvisorAPI/v1/inventoryService.asmx?WSDL', true );
// Check for an error
$err = $client->getError();
if ($err)
{      // Display the error      echo 'Constructor error' . $err . '';      // At this point, you know the call that follows will fail  }
$developerKey = 'developerKey';
$password = 'password';
$headers = '
        <APICredentials xmlns="http://api.channeladvisor.com/webservices/">
        <DeveloperKey>'.$developerKey.'</DeveloperKey>
        <Password>'.$password.'</Password>
        </APICredentials>
        ';
// Call the SOAP method
$result = $client->call('Ping', array(), false, false, $headers);
// Check for a fault
if ($client->fault)
       echo 'Fault';
    print_r($result);
    echo '';  }
else {
    // Check for errors
    $err = $client->getError();
    if ($err)
{          // Display the error          echo 'Error' . $err . '';      }
else
{          // Display the result          echo 'Result';

        print_r($result);
    echo '';      }
}
// Display the request and response
echo '<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 messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>'; ?>

Ruby with soap4r 1.5.5


-- install soap4r
gem install soap4r
-- create client
ruby wsdl2ruby --wsdl https://api.channeladvisor.com/ChannelAdvisorAPI/v1/CartService.asmx?WSDL --type client --force
-- this generates the following files:
CartServiceClient.rb
default.rb
defaultdriver.rb
defaultMappingRegistry.rb
-- Create a new test.rb file, with this Ruby code:
#!/usr/bin/env ruby
require 'rubygems'
require_gem 'soap4r'
require 'defaultDriver.rb'
require 'soap/header/simplehandler'
class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
 APICredentialsName = XSD::QName.new('http://api.channeladvisor.com/webservices/', 'APICredentials')
  DeveloperKeyName = XSD::QName.new('http://api.channeladvisor.com/webservices/', 'DeveloperKey')
  PasswordName = XSD::QName.new('http://api.channeladvisor.com/webservices/', 'Password')
  def initialize(userid, passwd)
    super(APICredentialsName)
    @userid = userid
    @passwd = passwd
  end
  def on_simple_outbound

{PasswordName => @passwd, DeveloperKeyName => @userid}
  end
end
endpoint_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v1/orderService.asmx'
obj = CartServiceSoap.new(endpoint_url)
# run ruby with -d to see SOAP wiredumps.
obj.wiredump_dev = STDERR if $DEBUG
obj.headerhandler << ClientAuthHeaderHandler.new('developerKey', 'password')
puts obj.ping(nil)
-- run this using ruby -d test.rb
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators