Я пытаюсь поговорить с веб-службой SOAP, используя SUDS и Python. После долгих возни с изучением Python (да, я новичок в этом) и выработкой того, как использовать SUDS, я столкнулся с проблемой.
Сигнатура веб-метода, который я вызываю, согласно suds,
(FWTCaseCreate){
ClassificationEventCode = None
Priority = None
Title = None
Description = None
Queue = None
DueDate = None
AssociatedObject =
(FWTObjectBriefDetails){
ObjectID =
(FWTObjectID){
ObjectType = None
ObjectReference[] = <empty>
}
ObjectDescription = None
Details = None
Category = None
}
Form =
(FWTCaseForm){
FormField[] = <empty>
FormName = None
FormKey = None
}
Internal = None
InteractionID = None
XCoord = None
YCoord = None
}
Поэтому я использую SUDS для создания нужных мне классов и отправки их методу. Однако я получаю сообщение об ошибке. Итак, я включил вход в систему и вижу, что отправляемый XML неверен, что вызывает ошибку десериализации. Пакет SOAP выглядит следующим образом
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.CRM.com/wsdl/FLTypes" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security>
<wsse:BinarySecurityToken>eaadf1ddff99a8</wsse:BinarySecurityToken>
</wsse:Security>
</SOAP-ENV:Header>
<ns1:Body>
<ns0:FWTCaseCreate>
<ClassificationEventCode>
<ClassificationEventCode>2000023</ClassificationEventCode>
<Priority>1</Priority>
<Title>testing</Title>
<Description>testing</Description>
<Queue/>
<Internal>True</Internal>
<XCoord>356570</XCoord>
<YCoord>168708</YCoord>
</ClassificationEventCode>
</ns0:FWTCaseCreate>
</ns1:Body>
As you can see there is a 'ClassificationEventCode' element around all the other elements, this should not be there. If I cut and paste this xml into SOAPUI and first remove this element and then post it directly to the web service it works successfully.
Вот код, который я использую для вызова
client = Client(url)
#Add a header for the security
ssnns = ('wsse', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd')
ssn = Element('BinarySecurityToken', ns=ssnns).setText(binaryKey)
ssn1 = Element('Security',ns=ssnns)
ssn1.append(ssn)
client.set_options(soapheaders=ssn1)
newCase = client.factory.create('ns1:FWTCaseCreate')
classEventCode = client.factory.create('ns1:FWTEventCode')
classEventCode.value = 2000023
newCase.ClassificationEventCode = classEventCode
newCase.Priority = 1
#optional
newCase.AssociatedObject = None
#optional
newCase.Form = None
#optional
newCase.Internal = None
#optional
newCase.InteractionID = None
#optional
newCase.DueDate = None
#optional
newCase.Queue = None
newCase.Title = 'Title'
newCase.Description = 'description'
newCase.XCoord = '356570'
newCase.YCoord = '168708'
caseID = client.service.createCase(newCase)
У кого-нибудь есть идеи, почему это происходит? Я предполагаю, что SUDS считает, что это должно быть там на основе WSDL.
Спасибо.