我是 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 < 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)
有人可以帮助我吗?提前致谢。