My solution was to add this expires like this but I'm not sure it's the best way with the newest version.

from suds.client import Client

# I created my own TimestampToken

class TimestampToken(Token):
  def __init__(self, validity=60):
      Token.__init__(self)
      self.created = datetime.now()
      self.expires = self.created+ timedelta(seconds = validity)
  def xml(self):
      root = Element("Timestamp", ns = wsuns)
      u = Element('Created', ns = wsuns)
      u.setText(date.to_iso8601(self.created))
      p = Element('Expires', ns =wsuns)
      p.setText(date.to_iso8601(self.expires))
      root.append(p)
      return root

url = "http://127.0.0.1:8080/api/AuthenticationService?wsdl"
service = Client(url)
security = Security()
# Add your security token here :-)

######

timetoken = TimestampToken(validity=60)
security.tokens.append(timetoken)
service.set_options(wsse=security)

So my service is ready to handle request.

@+++

2009/12/15 Andrews, Gavin <Gavin.Andrews@morganstanley.com>

I am trying to perform a SOAP Client call to a server which mandates WSSE Authentication.

 

Creating

 

    <wsse:Security mustUnderstand="true">

         <wsse:UsernameToken>

            <wsse:Username>username</wsse:Username>

            <wsse:Password>password</wsse:Password>

            <wsu:Created>2009-12-15T19:01:46.229259</wsu:Created>

         </wsse:UsernameToken>

 

Works well, but the server still isn’t happy as it requires the wsu:Expires element.

 

Is there a way to add expires into the UsernameToken?

 

Thanks in advance,

Gavin


NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We may monitor and store emails to the extent permitted by applicable law.


_______________________________________________
fedora-suds-list mailing list
fedora-suds-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-suds-list