Python泡沫会自动附加xsi:键入到复合型

2024-10-02 00:44:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用pythonsuds调用web服务方法。在

当尝试创建一个特定的复杂类型时,SUDS会将xsi:type="ns0:DeedDto"附加到它上面。 创建除此之外的其他类型时,SUDS不会附加xsi:类型。在

这里的问题是接收端无法识别此类型,然后我得到以下(特定)错误:

WebFault: Server raised fault: 'Unable to cast object of type 'ServiceProxy.DeedDto' to type 'ServiceProxy.DeedDto[]

这是WSDL URL

以下是实际代码:

^{pr2}$

看看实际的服务:

    Service ( Service ) tns="http://tempuri.org/"
   Prefixes (3)
      ns0 = "http://schemas.datacontract.org/2004/07/Artvise.Mercury.Base.DataContracts.API"
      ns1 = "http://schemas.microsoft.com/2003/10/Serialization/"
      ns2 = "http://www.artvise.se/MercuryAPI/"
   Ports (1):
      (BasicHttpBinding_IService)
         Methods (21):
            CreateCase(xs:string apiKey, ns0:CaseDto caseDto, )
            CreateDeed(xs:string apiKey, ns0:DeedDto deedDto, )
            GetAnswerTypes(xs:string apiKey, )
            GetCase(xs:string apiKey, xs:int objectID, )
            GetCaseByIdentifier(xs:string apiKey, xs:string identifier, )
            GetCaseByRefID(xs:string apiKey, xs:string refID, )
            GetCasesByCounterpartSocialSecurityNumber(xs:string apiKey, xs:string socialSecurityNumber, xs:boolean includeDeeds, )
            GetCasesByInboxGuid(xs:string apiKey, ns1:guid inboxGuid, xs:boolean includeDeeds, )
            GetDeed(xs:string apiKey, xs:int objectID, )
            GetDeedByRefID(xs:string apiKey, xs:string refID, )
            GetDeedTypes(xs:string apiKey, )
            GetFile(xs:string apiKey, xs:int fileID, )
            GetFileByRefID(xs:string apiKey, xs:string refID, )
            GetInboxes(xs:string apiKey, )
            GetMediaTypes(xs:string apiKey, )
            GetStatuses(xs:string apiKey, )
            GetSystemMessages(xs:string apiKey, )
            SetCaseCoordinates(xs:string apiKey, xs:int objectID, ns0:CoordinatesDto coordinates, )
            SetCaseReference(xs:string apiKey, xs:int objectID, xs:string refID, )
            SetCaseStatus(xs:string apiKey, xs:int objectID, ns1:guid statusGuid, )
            Test()
         Types (27):
            ns0:AnswerTypeDto
            ns0:ArrayOfAnswerTypeDto
            ns0:ArrayOfCaseDto
            ns0:ArrayOfCounterpartDto
            ns0:ArrayOfDeedDto
            ns0:ArrayOfDeedTypeDto
            ns0:ArrayOfFileDto
            ns0:ArrayOfInboxDto
            ns0:ArrayOfMediaTypeDto
            ns0:ArrayOfStatusDto
            ns0:ArrayOfSystemMessageDto
            ns0:CaseDto
            ns0:CoordinatesDto
            ns0:CounterpartDto
            ns0:CreateObjectResult
            ns0:DeedDto
            ns0:DeedTypeDto
            ns0:FileDto
            ns0:InboxDto
            ns0:MediaTypeDto
            ns0:ObjectDto
            ns0:OperationResult
            ns0:StatusDto
            ns0:SystemMessageDto
            ns1:char
            ns1:duration
            ns1:guid

鉴于这是一个已经构建好的解决方案,我只需要添加一个,所以我需要坚持使用SUDS。 否则我可能会看别的东西。在


Tags: http类型stringtypesudsintguidobjectid
1条回答
网友
1楼 · 发布于 2024-10-02 00:44:14

我用这个(有点愚蠢)的解决方案解决了这个问题:

self.client = Client(self.wsdl, plugins=[XSIValidator()])

class XSIValidator(MessagePlugin):
    """ Handles WSDL object differences """
    def sending(self, context):
        context.envelope = context.envelope.replace(
            ' xsi:type="ns0:DeedDto"', '')

相关问题 更多 >

    热门问题