Sorry, I forgot the underscore in http_headers in "the set th cookie" part

*client.http_headers['Cookie'] = client.response['set-cookie']*

Regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Wed, Mar 19, 2014 at 1:50 PM, Mariano Reingart <reing...@gmail.com>wrote:

> This should work:
>
> *# call the autentication remote method:*
>
>
> *client.call('init',('host','localhost'),('port','4859'),('user','CRSPRIXXXXX),('password','XXXX'),('pnumber','XXXX'),('db','XXXXXX'),('encoding',None),('titlePageSize',10),('indexPageSize',10))
> *
>
> *# set the cookie*
>
>  *client.http headers['Cookie'] = client.response['set-cookie']*
>
> *# call the methods that need the cookie:*
>
> *client.call('executeQuery',('query','[/doc/@nrecord]=00503459'))*
>
> Please confirm if that work, so I can add it to pysimplesoap library
>
> Best regards,
>
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com
>
>
> On Wed, Mar 19, 2014 at 12:29 PM, piero crisci <piero.cri...@gmail.com>wrote:
>
>> *this is the client obj*
>> client = SoapClient(
>> location=location_wsdl,
>> wsdl=wsdl,
>> ns = ns,
>> sessions=True,
>> trace=True,
>> http_headers={'Authorization': "Basic %s" %
>> auth},username=username,password=password)
>> client['AuthHeaderElement'] = {'Authorization': "Basic %s" % auth}
>> client['http_header'] = {'Authorization': "Basic %s" % auth}
>>
>> *This is the the 'init' call*
>>
>> client.call('init',('host','localhost'),('port','4859'),('user','CRSPRIXXXXX),('password','XXXX'),('pnumber','XXXX'),('db','XXXXXX'),('encoding',None),('titlePageSize',10),('indexPageSize',10))
>>
>> *And this is the 'init' response*
>>
>> {'status': '200', 'transfer-encoding': 'chunked', 'set-cookie':
>> 'JSESSIONID=4EDBE009B6A581E6023B9203365BF1EC; Path=/3diws', 'server':
>> 'Apache-Coyote/1.1', 'date': 'Wed, 19 Mar 2014 15:23:24 GMT',
>> 'content-type': 'text/xml;charset=utf-8'}
>>
>> *This is the the 'executeQuery' call*
>> client.call('executeQuery',('query','[/doc/@nrecord]=00503459'))
>>
>> *This is the response to the 'ExecuteQuery' call*
>> {'status': '500', 'transfer-encoding': 'chunked', 'set-cookie':
>> 'JSESSIONID=ECC4905C2D52F7456F4968E2C30D6639; Path=/3diws', 'server':
>> 'Apache-Coyote/1.1', 'connection': 'close', 'date': 'Wed, 19 Mar 2014
>> 15:25:26 GMT', 'content-type': 'text/xml;charset=utf-8'}
>>
>>
>>
>> Il giorno mercoledì 19 marzo 2014 15:25:45 UTC+1, Mariano Reingart ha
>> scritto:
>>>
>>> Could you send me the content of client.response (http headers)?
>>> Maybe it is returning a cookie or something equivalent
>>> Then, you can update client.http_headers with them and it should work
>>>
>>> Best regards,
>>>
>>> Mariano Reingart
>>> http://www.sistemasagiles.com.ar
>>> http://reingart.blogspot.com
>>>
>>>
>>> On Wed, Mar 19, 2014 at 7:40 AM, piero crisci <piero....@gmail.com>wrote:
>>>
>>>> Hi mariano i still got some problem
>>>> I solved the problem with the basic authentication but i still have
>>>> some problem on calling webservice.
>>>> The webservice infact need a first call for the db connection ('init' )
>>>> After this call you can call the other services.
>>>> I made this code :
>>>>
>>>> from pysimplesoap.client import SoapClient
>>>> from pysimplesoap.client import SoapClient, SimpleXMLElement
>>>> location_wsdl = " *http://docway.demo.3di.it
>>>> <http://docway.demo.3di.it>*/3diws/services/eXtraWay<http://docway.demo.3di.it/3diws/services/eXtraWay>
>>>> "
>>>> wsdl =  *http://docway.demo.3di.it/ <http://docway.demo.3di.it/>*/
>>>> 3diws/services/eXtraWay?wsdl<http://10.55.38.247:8080/3diws/services/eXtraWay?wsdl>
>>>> "
>>>> namespace_wsdl = " 
>>>> *http://docway.demo.3di.it/*<http://www.google.com/url?q=http%3A%2F%2Fdocway.demo.3di.it%2F3diws%2Fservices%2FeXtraWay%3Fwsdl&sa=D&sntz=1&usg=AFQjCNFAe47af7Nlfx1k8KJR8x-hsRTOAg>
>>>> 3diws/services/eXtraWay<http://10.55.38.247:8080/3diws/services/eXtraWay>
>>>> "
>>>> import base64
>>>> username='admin'
>>>> password='xxxx'
>>>>
>>>> auth = base64.b64encode('%s:%s' % (username, password))
>>>> client = SoapClient(location = location_wsdl, wsdl=wsdl,
>>>> *sessions=True,* namespace=namespace_wsdl,
>>>> http_headers={'Authorization': "Basic %s" % auth},username=username,
>>>> password=password)
>>>> client['AuthHeaderElement'] = {'Authorization': "Basic %s" % auth}
>>>>
>>>> client.send('init',xml=xml_init)
>>>> client.send('executeQuery',xml=xml_execute_query)
>>>>  When i call the 'executeQuery' i got as response that the connection
>>>> is not established. The connection should be established with the 'Init'
>>>> call .
>>>> I got the same problem with SOAPUI but i managed to solve the problem
>>>> activating the option "Maintain HTTP Session"
>>>> Even putting sessions = True is not solving the problem
>>>> Thank for help
>>>> Piero
>>>>
>>>> Il giorno martedì 18 marzo 2014 07:26:35 UTC+1, Mariano Reingart ha
>>>> scritto:
>>>>
>>>>> Hi piero:
>>>>>
>>>>> The first choice to connect to a webservice that requires username &
>>>>> password (add_credentials), you will httplib2 installed:
>>>>>
>>>>> https://code.google.com/p/httplib2
>>>>>
>>>>> Then you could do:
>>>>>
>>>>> client = SoapClient(location = location_wsdl,sessions=True,us
>>>>> ername='admin',password='xxxxxx')
>>>>>
>>>>> Also, assuming your webservice supports basic auth, you could pass
>>>>> the Authentication http header directly (it shouldn't need to install
>>>>> external library):
>>>>>
>>>>> import base64
>>>>> auth = base64.b64encode('%s:%s' % (username, password)).replace('\n',
>>>>> '')
>>>>>
>>>>> client = SoapClient(location = location_wsdl, sessions=True,
>>>>> http_headers={'Authorization': "Basic %s" % auth})
>>>>>
>>>>> Let me know if this solves your issue,
>>>>>
>>>>> Best regards
>>>>>
>>>>>
>>>>> Mariano Reingart
>>>>> http://www.sistemasagiles.com.ar
>>>>> http://reingart.blogspot.com
>>>>>
>>>>>
>>>>> On Mon, Mar 17, 2014 at 6:02 PM, piero crisci <piero....@gmail.com>wrote:
>>>>>
>>>>>>  Hello i am trying to connect to this wsdl:
>>>>>> http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl
>>>>>> It requires http basic authentication  and i am using pysimplesoap
>>>>>> 1.10 and i tried this configuration:
>>>>>>
>>>>>> from pysimplesoap.client import SoapClient
>>>>>> location_wsdl = "http://docway.demo.3di.it/3diws/services";
>>>>>> wsdl = "http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl";
>>>>>> client = SoapClient(location = 
>>>>>> location_wsdl,sessions=True,http_headers={'username':
>>>>>> 'admin', 'password': 'xxxx'},username='admin',password='xxxxxx')
>>>>>>
>>>>>> I got this error
>>>>>> Traceback (most recent call last):
>>>>>>   File "<stdin>", line 1, in <module>
>>>>>>   File "build\bdist.win32\egg\pysimplesoap\client.py", line 133, in
>>>>>> __init__
>>>>>>   File "build\bdist.win32\egg\pysimplesoap\client.py", line 469, in
>>>>>> wsdl_parse
>>>>>>   File "build\bdist.win32\egg\pysimplesoap\helpers.py", line 71, in
>>>>>> fetch
>>>>>>   File "build\bdist.win32\egg\pysimplesoap\transport.py", line 121,
>>>>>> in request
>>>>>>   File "C:\python27\lib\urllib2.py", line 406, in open
>>>>>>     response = meth(req, response)
>>>>>>   File "C:\python27\lib\urllib2.py", line 519, in http_response
>>>>>>     'http', request, response, code, msg, hdrs)
>>>>>>   File "C:\python27\lib\urllib2.py", line 444, in error
>>>>>>     return self._call_chain(*args)
>>>>>>   File "C:\python27\lib\urllib2.py", line 378, in _call_chain
>>>>>>     result = func(*args)
>>>>>>   File "C:\python27\lib\urllib2.py", line 527, in http_error_default
>>>>>>     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
>>>>>> urllib2.HTTPError: HTTP Error 401: Unauthorized
>>>>>>
>>>>>> It seems like the basic authenitcation is not supported. am I wrong?
>>>>>> How i need to change the wsdl call? And how i can use a session to
>>>>>> send different call?
>>>>>> Thx for help!
>>>>>>
>>>>>> --
>>>>>> Resources:
>>>>>> - http://web2py.com
>>>>>> - http://web2py.com/book (Documentation)
>>>>>> - http://github.com/web2py/web2py (Source code)
>>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "web2py-users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to web2py+un...@googlegroups.com.
>>>>>>
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
>>>> Resources:
>>>> - http://web2py.com
>>>> - http://web2py.com/book (Documentation)
>>>> - http://github.com/web2py/web2py (Source code)
>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "web2py-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to web2py+un...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to