【问题标题】:Zeep Client WSDL Request Unexpected Keyword ArgumentZeep 客户端 WSDL 请求意外的关键字参数
【发布时间】:2021-04-05 23:01:35
【问题描述】:

我正在尝试根据 EntityId 向 SOAP API 写入请求。 我无法提取使用 python -mzeep 列出的服务,因为我需要访问 WSDL 的证书/密钥。然而,我确实找到了这个https://stackoverflow.com/a/50093489/2607773,它帮助我得到了这个:

{'Blah': {'WSHttpBinding_IBlah': 
    {'operations': {'EntitySearch': 
        input': {'request': {'optional': True, 'type': 
                    {'EntityId': {'optional': False, 'type': 'Long(value)'}, 
                     'LName': {'optional': True, 'type': 'String(value)'}, 
                     'FName': {'optional': True, 'type': 'String(value)'} 
                    }
                }
            }
        }
    }
  }
} 

这是我用来尝试在 SOAP API 中查询 EntityId 的代码:

from requests import Session
from zeep import Client
from zeep.transports import Transport
from zeep.wsa import WsAddressingPlugin
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
import certifi
import http.client
from OpenSSL import crypto
from zeep.wsse.signature import Signature
import xmlsec
import pprint

test_filename = 'C:\\Users\\Me\\Desktop\\test.pem'
session = Session()
session.cert = (test_filename)
client = Client('https://blah.blahblah.local:90/Blah.ProxyService/Blah.svc?singleWsdl',transport=Transport(session=session))
result = client.service.EntitySearch(EntityId = 100000)

尝试此代码时出现以下错误:

TypeError: {http://HSDService}EntitySearch() got an unexpected keyword argument 'EntityId'. Signature: `request: {EntityId: xsd:long, LName: xsd:string, FName: xsd:string}`

就这个请求而言,我不确定我哪里出错了,但我认为这可能是一个简单的错误,当我尝试查询 EntityId 时我没有看到。在这一点上,我对任何想法持开放态度。

【问题讨论】:

    标签: python-3.x soap wsdl zeep


    【解决方案1】:

    最终我自己解决了这个问题,因为我没有像我应该的那样使用字典来满足我的要求。

    这就是最终对我有用的东西:

    test_filename = 'C:\\Users\\Me\\Desktop\\test.pem'
    session = Session()
    session.cert = (test_filename)
    session.verify = False
    client = Client('https://blah.blahblah.cloudapp.azure.com:90/blah.ProxyService/BlahSvc.svc?singleWsdl',transport=Transport(session=session))
    request_data = { #'EntityId': 100000
                    }
    print(client.service.EntitySearch(request_data))
    

    【讨论】:

      猜你喜欢
      • 2014-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      • 2023-03-29
      • 2019-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多