'Zeep Client WSDL Request Unexpected Keyword Argument

I'm trying to write a request to a SOAP API based upon an EntityId. I was unable to pull the services listed using python -mzeep because there is a certificate/key that I need to access the WSDL. I did however find this https://stackoverflow.com/a/50093489/2607773 that helped me to get this:

{'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)'} 
                    }
                }
            }
        }
    }
  }
} 

This is my code that I'm using to try and query the SOAP API for the 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)

I get the following error when I try this code:

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

Not sure where I am going wrong as far as this request, but I think it might be a simple error that I am not seeing as far as when I am trying to query the EntityId. I am open to any ideas at this point.



Solution 1:[1]

Ended up figuring this out on my own since I was not using a dictionary for my request like I should have.

This is what ended up working for me:

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))

Solution 2:[2]

Its easy and simple you can edit your code using my simple example about visa cards

client = Client("https://example.com/CARDS/STWS?wsdl")
req_data = {
    "StPimsApiPartnerKey": "your-api-partner-key",
    "AccessToken": "your-access-token",
    "CardNumber": "your-card-number",
    "CardExDate": "your-expire-date",
    "CardHolderName": "your-holder-name",
    "CardCVV": "your-card-cvv",
    "PhoneNumber": "your-phone-number",
} # should be dict dont use ** for send data like **req_data

result = client.service.partnerRegisterCardIPS(req_data)
print(result)

I think it's very helpfull for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Perdue
Solution 2 Muhammadalive