0

I tried to create a zeep client and use it by two methods.

1) I tried to keep everything in a single module . i created the zeep client object and it was working fine while using a payload. 2) I created a method which returns a zeep client object for a wsdl. I tried to use this a way as method 1) But getting the below error. zeep.exception.Fault : Incoming message could not be authenticated. No valid credentials found Can someone please advise what I am missing here which causes this error. My second approach is like this. \\ def zeepClient(wsdl): ## do all here and return zeep client object. return client #Now in another module I do call that above method like this Client=othermodule.zeepClient(mywsdl) Payload={my payload} Client.service.myservice(**Payload) \\

If I do this , I get above error.But if my above piece of code and my method for zeepClient are all in same place. I am not getting error. Not sure . What that Returned Client object is missing.

crazypaladin
  • 453
  • 4
  • 7
  • 17

1 Answers1

0

You must provide credentials to the session and then make a request like here

from requests import Session
from requests.auth import HTTPBasicAuth  # or HTTPDigestAuth, or OAuth1, etc.
from zeep import Client
from zeep.transports import Transport

session = Session()
session.auth = HTTPBasicAuth(user, password)
client = Client('http://my-endpoint.com/production.svc?wsdl',
    transport=Transport(session=session))
theone1one
  • 1,510
  • 3
  • 20
  • 27
  • Hi. Thanks for coming back. I do use cookies and the problem mainly here is if I add my payload in same module . It works. But if I do something like this main it fails. Editing my main question with some sort of sample code for second approach – crazypaladin Sep 20 '19 at 13:39
  • Hi. I found the issue. Client.transport.session.cookies not propagating when used as method. Any idea how I can make this work?. Whole idea is to make things reusablewithnless repetitive code. – crazypaladin Sep 20 '19 at 14:28
  • i am not sure how , but the issue got fixed today . even i dont see much difference in code to find error.(cant share exact code due to security terms) Bad part is i am not able to find the error. please downvote me . My bad . cant down vote myself . earlier cookies were not propagating. But now its working fine. I am not able to find the reason why the cookies data was missing earlier , but is there now. – crazypaladin Sep 20 '19 at 20:45