我正在尝试使用SUDS和Python与SOAP web服务交谈。在学习Python(是的,我是新手)和研究如何使用sud之后,我遇到了一个问题。
suds说,我调用的web方法的签名是
(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>
如你所见 '分类事件代码' 元素周围的所有其他元素,这不应该存在。如果我将这个xml剪切并粘贴到SOAPUI中,然后首先删除这个元素,然后直接将其发布到web服务,那么它将成功工作。
这是我用来打电话的代码
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。
谢谢。
目前没有回答
相关问题 更多 >
编程相关推荐