I wrote the following ws for test and I'm trying to access it...
class WebService(WebServicesRoot):
@wsexpose([str])
@tg.identity.require(tg.identity.not_anonymous())
@wsvalidate(str)
def ws_comuni(self,code=None):
return 'param: %s'%code or '?'
--using the browser-------------------------------
alfa.pippo.com/webservices/ws_test?code=MO
<at this point tg shows the login.kid, I enter the credentials and after
that it shows me the result:>
<result>param: MO</result>
--------------------using suds---------------------
# -*- coding: utf-8 -*-
from suds.transport.http import HttpAuthenticated
from suds.client import Client
url_server = 'http://alfa.pippo.com/webservices/soap/api.wsdl'
def conn(url):
t = HttpAuthenticated(username='username', password='password')
client = Client(url, transport=t)
return client
client = conn( url=url_server)
print client
for r in client.service.ws_test(code='MO'):
print r
--result-------------------------------------------
$ python ws_test.py
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build:
R699-20100913
Service ( WebService ) tns="http://alfa.pippo.com/webservices/soap/"
Prefixes (1)
ns0 = "http://alfa.pippo.com/webservices/soap/types"
Ports (1):
(WebService_PortType)
Methods (1):
ws_test(xs:string code, )
Types (1):
ns0:String_Array
No handlers could be found for logger "suds.client"
Traceback (most recent call last):
File "/home/jose/buildout/bin/python", line 76, in <module>
execfile(__file__)
File "test1", line 21, in <module>
for r in client.service.ws_test(code='MO' ):
File "/home/jose/buildout/eggs/suds-0.4-py2.6.egg/suds/client.py",
line 542, in __call__
return client.invoke(args, kwargs)
File "/home/jose/buildout/eggs/suds-0.4-py2.6.egg/suds/client.py",
line 602, in invoke
result = self.send(soapenv)
File "/home/jose/buildout/eggs/suds-0.4-py2.6.egg/suds/client.py",
line 649, in send
result = self.failed(binding, e)
File "/home/jose/buildout/eggs/suds-0.4-py2.6.egg/suds/client.py",
line 708, in failed
raise Exception((status, reason))
Exception: (403, u'Forbidden')
---------------------------------------------------------------------
I can't realize how to pass the credentials to it.
Jose Soares wrote:
Hi all,
I'm trying to expose a webservice but I don't know how to protect it.
I can't understand how ws authentication works.
I tried using the decorator:
@tg.identity.require(tg.identity.not_anonymous())
but in this case the authentication form asks user to enter data using
the keyboard.
I can't realize how to do this by skipping the authentication form.
Thanks for any help.
j
ps:
I'm using turbogears1
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.