Zeep 客户端抛出 Service has no operation 错误

Zeep client throws Service has no operation error

我正在使用 zeep 调用 SOAP 网络服务。即使该方法存在于 WSDL

中,它也会引发错误
client = Client(self.const.soap_url)
client.service.getPlansDetails(id)

我收到这个错误

AttributeError: Service has no operation 'getPlansDetails'

这是来自 python -m zeep <wsd_url>

的信息
Prefixes:
     xsd: http://www.w3.org/2001/XMLSchema
     ns0: http://tempuri.org/Imports
     ns1: http://tempuri.org
     ns2: http://schemas.datacontract.org/2004/07/Dynamics.Ax.Application
     ns3: http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.Ax.Xpp
     ns4: http://schemas.microsoft.com/dynamics/2010/01/datacontracts
     ns5: http://schemas.microsoft.com/2003/10/Serialization/Arrays
     ns6: http://schemas.microsoft.com/dynamics/2008/01/documents/Fault
     ns7: http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.AX.Framework.Services
     ns8: http://schemas.microsoft.com/2003/10/Serialization/

Global elements:
     ns2:LFCPaymentPlanDetailsContract(ns2:LFCPaymentPlanDetailsContract)
     ns7:ArrayOfInfologMessage(ns7:ArrayOfInfologMessage)
     ns7:InfologMessage(ns7:InfologMessage)
     ns7:InfologMessageType(ns7:InfologMessageType)
     ns3:XppObjectBase(ns3:XppObjectBase)
     ns5:ArrayOfKeyValueOfstringstring(ns5:ArrayOfKeyValueOfstringstring)
     ns8:QName(xsd:QName)
     ns8:anyType(None)
     ns8:anyURI(xsd:anyURI)
     ns8:base64Binary(xsd:base64Binary)
     ns8:boolean(xsd:boolean)
     ns8:byte(xsd:byte)
     ns8:char(ns8:char)
     ns8:dateTime(xsd:dateTime)
     ns8:decimal(xsd:decimal)
     ns8:double(xsd:double)
     ns8:duration(ns8:duration)
     ns8:float(xsd:float)
     ns8:guid(ns8:guid)
     ns8:int(xsd:int)
     ns8:long(xsd:long)
     ns8:short(xsd:short)
     ns8:string(xsd:string)
     ns8:unsignedByte(xsd:unsignedByte)
     ns8:unsignedInt(xsd:unsignedInt)
     ns8:unsignedLong(xsd:unsignedLong)
     ns8:unsignedShort(xsd:unsignedShort)
     ns6:AifFault(ns6:AifFault)
     ns6:ArrayOfFaultMessage(ns6:ArrayOfFaultMessage)
     ns6:ArrayOfFaultMessageList(ns6:ArrayOfFaultMessageList)
     ns6:FaultMessage(ns6:FaultMessage)
     ns6:FaultMessageList(ns6:FaultMessageList)
     ns4:CallContext(ns4:CallContext)
     ns1:LFCPaymentPlanDetailsServicesGetPlansDetailsRequest(_crmno: xsd:string)
     ns1:LFCPaymentPlanDetailsServicesGetPlansDetailsResponse(response: ns2:LFCPaymentPlanDetailsContract)
     

Global types:
     xsd:anyType
     ns2:LFCPaymentPlanDetailsContract(Amount: xsd:decimal, CRMNumber: xsd:string, CustomerName: xsd:string, CustomerRequestedType: xsd:string, ErrorMessage: xsd:string, OrderId: xsd:long, PlanType: xsd:string)
     ns7:ArrayOfInfologMessage(InfologMessage: ns7:InfologMessage[])
     ns7:InfologMessage(InfologMessageType: ns7:InfologMessageType, Message: xsd:string)
     ns7:InfologMessageType
     ns3:XppObjectBase()
     ns5:ArrayOfKeyValueOfstringstring(KeyValueOfstringstring: {Key: xsd:string, Value: xsd:string}[])
     ns8:char
     ns8:duration
     ns8:guid
     ns6:AifFault(CustomDetailXml: xsd:string, FaultMessageListArray: ns6:ArrayOfFaultMessageList, InfologMessageList: ns7:ArrayOfInfologMessage, StackTrace: xsd:string, XppExceptionType: xsd:int)
     ns6:ArrayOfFaultMessage(FaultMessage: ns6:FaultMessage[])
     ns6:ArrayOfFaultMessageList(FaultMessageList: ns6:FaultMessageList[])
     ns6:FaultMessage(Code: xsd:string, Message: xsd:string)
     ns6:FaultMessageList(Document: xsd:string, DocumentOperation: xsd:string, FaultMessageArray: ns6:ArrayOfFaultMessage, Field: xsd:string, Service: xsd:string, ServiceOperation: xsd:string, ServiceOperationParameter: xsd:string, XPath: xsd:string, XmlLine: xsd:string, XmlPosition: xsd:string)
     ns4:CallContext(Company: xsd:string, Language: xsd:string, LogonAsUser: xsd:string, MessageId: xsd:string, PartitionKey: xsd:string, PropertyBag: ns5:ArrayOfKeyValueOfstringstring)
     xsd:ENTITIES
     xsd:ENTITY
     xsd:ID
     xsd:IDREF
     xsd:IDREFS
     xsd:NCName
     xsd:NMTOKEN
     xsd:NMTOKENS
     xsd:NOTATION
     xsd:Name
     xsd:QName
     xsd:anySimpleType
     xsd:anyURI
     xsd:base64Binary
     xsd:boolean
     xsd:byte
     xsd:date
     xsd:dateTime
     xsd:decimal
     xsd:double
     xsd:duration
     xsd:float
     xsd:gDay
     xsd:gMonth
     xsd:gMonthDay
     xsd:gYear
     xsd:gYearMonth
     xsd:hexBinary
     xsd:int
     xsd:integer
     xsd:language
     xsd:long
     xsd:negativeInteger
     xsd:nonNegativeInteger
     xsd:nonPositiveInteger
     xsd:normalizedString
     xsd:positiveInteger
     xsd:short
     xsd:string
     xsd:time
     xsd:token
     xsd:unsignedByte
     xsd:unsignedInt
     xsd:unsignedLong
     xsd:unsignedShort

Bindings:
     Soap11Binding: {http://tempuri.org/}BasicHttpBinding_LFCPaymentPlanDetailsServices
     Soap11Binding: {http://tempuri.org/}serviceEndpoint

Service: RoutingService
     Port: serviceEndpoint (Soap11Binding: {http://tempuri.org/}serviceEndpoint)
         Operations:

     Port: BasicHttpBinding_LFCPaymentPlanDetailsServices (Soap11Binding: {http://tempuri.org/}BasicHttpBinding_LFCPaymentPlanDetailsServices)
         Operations:
            getPlansDetails(_crmno: xsd:string, _soapheaders={context: ns4:CallContext}) -> response: ns2:LFCPaymentPlanDetailsContract

它给出该错误的原因是因为默认情况下,zeep 绑定到第一个服务和第一个端口。但是在您的情况下,您正试图从第二个端口调用方法。所以这应该有效:

client = Client(self.const.soap_url)
plan_client = client.bind('RoutingService', 'BasicHttpBinding_LFCPaymentPlanDetailsServices')

plan_client.service.getPlansDetails(id)

如果它不起作用,请告诉我们。