Служба запросов клиента Zeep не имеет ошибки при работе

#python #soap #zeep

#python #soap #zeep

Вопрос:

Я использую 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
  

Ответ №1:

Причина, по которой он выдает эту ошибку, заключается в том, что по умолчанию zeep привязывается к 1-му сервису и 1-му порту. Но в вашем случае вы пытаетесь вызвать метод со 2-го порта. Так что это должно сработать:

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

plan_client.service.getPlansDetails(id)
  

Сообщите нам, если это не сработает.