python - 在python方法中转换C#方法

时间:2018-03-27 19:54:57

标签: python django xml zeep

我是Python的新手,我试图制作这个C#方法

protected void read(){
string[] attributes = new string[16];
        attributes[0] = "ref_num";
        attributes[1] = "tenant.name";
        attributes[2] = "request_by.first_name";
        attributes[3] = "request_by.first_name";
        attributes[4] = "customer.first_name";
        attributes[5] = "customer.last_name";
        attributes[6] = "customer.id";
        attributes[7] = "category.sym";
        attributes[8] = "status.sym";
        attributes[9] = "group.last_name";
        attributes[10] = "zreporting_met.sym";
        attributes[11] = "assignee.combo_name";
        attributes[12] = "open_date";
        attributes[13] = "close_date";
        attributes[14] = "description";
        attributes[15] = "summary";
        int sid = soap.login("user", "pass");
        string objectType = "cr";
        string whereClause = "ref_num = '15967'";
        int maxRows = -1;
        //Valor de tiempo en Epoch
        var epoch = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
        //Transforma en valor de fecha humana
        string _epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(epoch).ToShortDateString();
        ArrayList resultado = new ArrayList();
        XmlDocument xml = new XmlDocument();
        try
        {
            string _selectResponse = soap.doSelect(sid, objectType, whereClause, maxRows, attributes);
            xml.LoadXml(_selectResponse);
            XmlNodeList nodeList = xml.GetElementsByTagName("AttrValue");
            for (int i = 0; i < nodeList.Count; i++)
            {
                resultado.Add(nodeList[i].InnerXml);
            }
            soap.logout(sid);
        }
        catch (Exception l)
        {
            Console.Write(l.Message);
        }
}

这个方法很完美,在python中我暂时还有这个

class WebService:

soap = 'webservice url'

client = Client(soap)

sid = client.service.login("user","pass")
attributes = ["ref_num", "open_date"]
objectType = "cr"
whereClause = "open_date > 1519862400 AND open_date &lt; 1522368000"
maxRows = -1
tickets = client.service.doSelect(sid, objectType, whereClause, -1, attributes)
print(tickets)
logout = client.service.logout(p)

使用zeep连接到Web服务

我所拥有的错误是属性数组,登录方法,但是当我尝试使用doSelect()方法时,它说:

zeep.exceptions.ValidationError: Missing element string (doSelect.attributes)
有人可以帮帮我吗?提前谢谢。

0 个答案:

没有答案