This chapter provides examples of how the SCI interface can be implemented in various coding languages.
This requires a "pip install suds" to get the python suds 0.4 package.
#!/bin/env python from suds.client import Client from suds.bindings import binding from suds.wsse import Security, UsernameToken library = "https://library.company.com/WebService/1.0.0" # This could be cached to a local file for efficiency wsdl = "http://library.company.com/WebService/1.0.0?WSDL" # Use SOAP 1.2 binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope') proxy = Client(url=wsdl, location=library, headers={'Content-Type': 'application/soap+xml'}) security = Security() token = UsernameToken('admin', 'password1') security.tokens.append(token) proxy.set_options(wsse=security) response = proxy.service.ping() print "Ping responded with: " print response, "\n" response = proxy.service.getRobots(libraryId = 1) print "Robots: " print response, "\n" response = proxy.service.getDevice(deviceId = response[0].parentDeviceId) print "Rail: " print response, "\n"
This is compiled with Genivia gSOAP. The recommended version is 2.8.17r. gSOAP is copyrighted by Robert A. van Engelen, Genivia, Inc.
#include <iostream> #include "soapWebServicePortBindingProxy.h" #include "WebServicePortBinding.nsmap" #include "plugin/wsseapi.h" using namespace std; static const char *library = "https://library.company.com/WebService/1.0.0"; int main(int argc, char **argv) { WebServicePortBindingProxy proxy; ns1__getLibraryComplex getLibraryComplex; ns1__getLibraryComplexResponse getLibraryComplexResp; if (soap_ssl_client_context(proxy.soap, SOAP_SSL_NO_AUTHENTICATION, NULL, NULL, NULL, NULL, NULL)) { soap_print_fault(proxy.soap, stderr); } soap_wsse_add_Security(proxy.soap); soap_wsse_add_UsernameTokenText(proxy.soap, "Id", "admin", "password1"); if(proxy.getLibraryComplex(library, NULL, &getLibraryComplex, &getLibraryComplexResp)) { proxy.soap_stream_fault(cerr); exit(-1); } cout << "Name: " << *(getLibraryComplexResp.libraryComplex->name) << endl; cout << "Ready: " << (getLibraryComplexResp.libraryComplex->ready ? "TRUE" : "FALSE") << endl; cout << "Libraries: " << getLibraryComplexResp.libraryComplex->counts->libraryCount << endl; cout << "Partitions: " << getLibraryComplexResp.libraryComplex->counts->partitionCount << endl; cout << "Devices: " << getLibraryComplexResp.libraryComplex->counts->deviceCount << endl; cout << "Drives: " << getLibraryComplexResp.libraryComplex->counts->driveCount << endl; cout << "Drive Bays: " << getLibraryComplexResp.libraryComplex->counts->driveBayCount << endl; cout << "Cells: " << getLibraryComplexResp.libraryComplex->counts->cellCount << endl; cout << "Robots: " << getLibraryComplexResp.libraryComplex->counts->robotCount << endl; soap_end(proxy.soap); }