Question

Im writing a console app that pulls smartserver data points using the Read function provided by the wsdl. Through suds I can successfully connect to the smartserver and print the client wsdl which gives me a list of methods and types. How can I use these methods through suds to pull data? Ive tried print client.service.List() which according to the programmer documentation of this server should give me data points, but this gives me a urlopen error [Errno 13] Permission denied. The manual provides example codes that just uses SOAP to pull the data but since I'm using suds alot of this code is streamlined and I only have to do client.service.somemethod(parameter) I have attached my code so far and the list of methods I get when I print client.

Thank you very much.

import suds
from suds.client import Client
from suds.transport.http import HttpAuthenticated
url = "http://example/WSDL/v4.0/foo.WSDL"
client = Client(url, username='foo', password='bar')

myheaders = dict(userid='foo', passwd='bar')
client.set_options(soapheaders=myheaders)
name = client.factory.create('ns0:E_xSelect')
print name
name['xSelect'] = """//Item[UCPTpointName = "Net/MB485/MAIN POWER/Fb/PowerSum"]"""
print client.service.Read(name)

what I get in console

Ports (1):
(iLON100httpPort)
Methods (8):
Clear(ns0:Item_Coll iLonItem, )
Delete(ns0:Item_Coll iLonItem, )
Get(ns0:Item_Coll iLonItem, )
InvokeCmd(ns0:Item_Coll iLonItem, )
List(ns0:E_xSelect iLonItem, )
Read(ns0:Item_Coll iLonItem, )
Set(ns0:Item_CfgColl iLonItem, )
Write(ns0:Item_DataColl iLonItem, )

Example code in the documentation to give you an idea

static void Main(string[] args)
    {
    iLON_SoapCalls.BindClientToSmartServer(); iLON_SmartServer.iLON100portTypeClient SmartServer = iLON_SoapCalls._iLON;
    // -------------- READING A DATA POINT VALUE --------------
    try
    {
    // instantiate the member object
    iLON_SmartServer.Item_Coll itemColl = new iLON_SmartServer.Item_Coll(); itemColl.Item = new iLON_SmartServer.Item[1];
    itemColl.Item[0] = new iLON_SmartServer.Dp_Data();
    // set the DP name
    itemColl.Item[0].UCPTname = "Net/LON/iLON App/Digital Output 1/nviClaValue_1";
    // set maxAge to get the updated DP value in case it has been cached for more than 10         // seconds on the Data Server (see section 4.3.4.1 for more information)     ((iLON_SmartServer.Dp_Data)(itemColl.Item[0])).UCPTmaxAge = 10; ((iLON_SmartServer.Dp_Data)(itemColl.Item[0])).UCPTmaxAgeSpecified = true;
    //call the Read Function
    iLON_SmartServer.Item_DataColl dataColl = SmartServer.Read(itemColl);
    if (dataColl.Item == null)
    {
        // sanity check.  this should not happen
        Console.Out.WriteLine("No items were returned");
    }
    else if (dataColl.Item[0].fault != null)
    {
        // error
        Console.Out.WriteLine("An error occurred.  Fault code = " +
        dataColl.Item[0].fault.faultcode +
        ".  Fault text = %s." +
        dataColl.Item[0].fault.faultstring);
    }
    else
    {
    // success
    Console.Out.WriteLine("Read is successful");
    Console.Out.WriteLine(((iLON_SmartServer.Dp_Data)dataColl.Item[0]).UCPTname + " = " +     ((iLON_SmartServer.Dp_Data)dataColl.Item[0]).UCPTvalue[0].Value + "\n");
    }
Was it helpful?

Solution

I figured out the problem. You have to open up the wsdl you are accessing through soap in an xml format and read the section named wsdl services that specify a location. Define that location in the client constructor to successfully communicate with the server. For some reason suds wasn't seeing this location in the wsdl file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top