Невозможно принять данные с помощью python suds - PullRequest
3 голосов
/ 21 ноября 2011

Я пытаюсь получить данные в Attivio (Active Intelligence Engine), используя suds в python. Идентификатор документа, имя поля введены успешно. Но значение fieldValue не заполняется. Вот код Python:

from suds.client import Client
url = "http://localhost:17000/ws/bean.attivioIngestWebService/com.attivio.webservice.service.IngestApi?wsdl"
client = Client(url)
cfg = client.factory.create('sessionConfig')
cfg.commitInterval = 1
sessionId = client.service.connect(cfg)
doc = client.factory.create('attivioDocument')
doc._id = "Doc1"

text = client.factory.create('Field')
text._name = "text"
textval = client.factory.create('fieldValue')
textval.value = "Test document text"
text.values = [textval]

doc.fields = [text]
print doc
try:
    client.service.feed(sessionId, [doc])
    client.service.commit(sessionId)
except Exception as e:
  print e

UPDATE: Смотрите разницу между .net и python SOAP ниже. Поскольку <value> определяется как anyType, suds не помещает в него информацию о типе, и AIE не может обработать его правильно. Это, возможно, корень проблемы. Есть идеи как это исправить?

.net

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<feed xmlns="http://webservice.attivio.com/">
<sessionId xmlns="">704@10.7.3.7_r437gs-f879-4c58-9da5-45erf7as88ex</sessionId>
<docs readOnly="false" id="dotnet" xmlns="">
<fields name="title">
<values>
**<value xsi:type="xsd:string">Hello dot net</value>**
</values>
</fields>
</docs>
</feed>
</s:Body>
</s:Envelope>POST /ws/bean.attivioIngestWebService/com.attivio.webservice.service.IngestApi HTTP/1.1

питон

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservice.attivio.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:feed>
         <sessionId>401@192.168.1.100_fnwsf5b5218-9159-4a8f-987a</sessionId>
         <docs id="Doc1">
            <fields name="text">
               <values>
                  **<value>Test document text</value>**
               </values>
               <metadata/>
            </fields>
            <mode/>
         </docs>
      </ns1:feed>
   </ns0:Body>
</SOAP-ENV:Envelope>
...