https authentication failing
by Bruce Edge
I'm having a problem with https basic authentication
Is there something I'm doing wrong here?
security = Security()
token = UsernameToken('username', 'password')
security.tokens.append(token)
url = 'https://targetboc:8443/service-war/dpmcore?wsdl'
c = Client(url, wsse=security)
print c.service
# OK so far
c.service.getOemKey(wsse=security)
# fails with
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "wsenv.py", line 22, in <module>
c.service.getOemKey(wsse=security)
File "suds/client.py", line 240, in __call__
return target.call(*args, **kwargs)
File "suds/client.py", line 379, in call
return method(*args, **kwargs)
File "suds/client.py", line 240, in __call__
return target.call(*args, **kwargs)
File "suds/client.py", line 422, in call
return client.invoke(args, kwargs)
File "suds/client.py", line 480, in invoke
result = self.send(msg)
File "suds/client.py", line 504, in send
reply = transport.send(request)
File "suds/transport/https.py", line 64, in send
return HttpTransport.send(self, request)
File "suds/transport/http.py", line 78, in send
fp = self.__open(u2request)
File "suds/transport/http.py", line 99, in __open
return self.urlopener.open(u2request)
File "/usr/lib/python2.6/urllib2.py", line 383, in open
response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 401, in _open
'_open', req)
File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 1138, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/usr/lib/python2.6/urllib2.py", line 1105, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 111] Connection refused>
>>>
I tried the beta with the same result.
I know the service is OK because I can do this:
curl -ku username:password
https://localhost:8443/service-war/dpmcore/getOemKey
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getOemKeyResponse
xmlns="http://lsi.com/dpm/core/types"
xmlns:ns2="http://lsi.com/dpm/types"><oemKey>LSI</oemKey></getOemKeyResponse></soap:Body></soap:Envelope>
Thanks, Bruce
14 years, 10 months
Re: FW: [Fedora-suds-list] https authentication failing
by Bruce Edge
Here's the output with debugging turned up. The end result is still:
Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>*This
request requires HTTP authentication ().*
Also, if I use client = Client(url+"?wsdl") as you suggested, then the
"?wsdl" string is repeated twice, so I dropped that.
I get the same result using
client = Client(url, wsse=security)
and
client = Client(url, username="name", password="password")
The print client.service still works, but the method call (getOemKey)
doesn't.
Note the funky formatting is from ipython.
In [40]: client.service.getOemKey()
DEBUG:suds.client:sending to (
https://kaan-01.wlv.lsi.com:8443/service-war/dpmcore?wsdl) <- correct url
message:
<SOAP-ENV:Envelope xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext..."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit..."
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>dpm</wsse:Username>
<wsse:Password>password</wsse:Password>
<wsse:Nonce>43901aefc25cc1bd455e7d3cc3c58d7b</wsse:Nonce>
<wsu:Created>2009-06-21T06:53:14.146074</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body/>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'"
http://lsi.com/dpm/core/getOemKey"', 'Content-Type': 'text/xml'}
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext..."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit..."
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>dpm</wsse:Username>
<wsse:Password>password</wsse:Password>
<wsse:Nonce>43901aefc25cc1bd455e7d3cc3c58d7b</wsse:Nonce>
<wsu:Created>2009-06-21T06:53:14.146074</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body/>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
<html><head><title>Apache Tomcat/6.0.18 - Error report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP Status 401 - </h1><HR size="1"
noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b>
<u></u></p><p><b>description</b> <u>This request requires HTTP
authentication ().</u></p><HR size="1" noshade="noshade"><h3>Apache
Tomcat/6.0.18</h3></body></html>
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/import/gin/bedge/dev_kaan/Apps/ws/test/<ipython console> in <module>()
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in __call__(self,
*args, **kwargs)
238 def __call__(self, *args, **kwargs):
239 target = self.__wrapped__
--> 240 return target.call(*args, **kwargs)
241
242 def __str__(self):
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in call(self, *args,
**kwargs)
377 """
378 method = self.resolve(self.name(), strict=False)
--> 379 return method(*args, **kwargs)
380
381
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in __call__(self,
*args, **kwargs)
238 def __call__(self, *args, **kwargs):
239 target = self.__wrapped__
--> 240 return target.call(*args, **kwargs)
241
242 def __str__(self):
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in call(self, *args,
**kwargs)
420 return (500, e)
421 else:
--> 422 return client.invoke(args, kwargs)
423
424 def faults(self):
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in invoke(self,
args, kwargs)
478 self.method.qname, timer)
479 timer.start()
--> 480 result = self.send(msg)
481 timer.stop()
482 metrics.log.debug(
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in send(self, msg)
509 else:
510 log.error(self.last_sent())
--> 511 result = self.failed(binding, e)
512 return result
513
/import/gin/bedge/dev_kaan/Apps/ws/test/suds/client.pyc in failed(self,
binding, error)
566 return (status, None)
567 if self.options.faults:
--> 568 raise Exception((status, reason))
569 else:
570 return (status, None)
Exception: (401, u'Unauthorized')
Again, here's the full code:
import suds
from suds.wsse import *
from suds.client import Client
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
security = Security()
token = UsernameToken('username', 'password')
security.tokens.append(token)
url = 'https://kaan-01.wlv.lsi.com:8443/service-war/dpmcore?wsdl'
client = Client(url, wsse=security)
print client.service
client.wsdl.service.setlocation(url)
client.service.getOemKey(wsse=security)
-Bruce
On Sat, Jun 20, 2009 at 11:29 PM, Edge, Bruce <Bruce.Edge(a)lsi.com> wrote:
>
> ________________________________________
> From: David Norton [david(a)nortoncrew.com]
> Sent: Saturday, June 20, 2009 3:15 PM
> To: Edge, Bruce
> Subject: Re: [Fedora-suds-list] https authentication failing
>
> Try turning up debugging:
>
>
> import logging
> logging.basicConfig(level=logging.INFO)
>
>
>
> logging.getLogger('suds.client').setLevel(logging.DEBUG)
>
>
> That should tell you what URL it is trying to connect to when it makes the
> getOemKey() call.
>
> David
>
> On Jun 20, 2009, at 4:21 PM, Edge, Bruce wrote:
>
> If that was the problem wouldn't the client instantiation fail?
> I'm able to inatantiate a client and do a:
> print client.service
> But then any methods called on the service fail.
>
> -Bruce
>
> Sent from my iPhone
>
> On Jun 20, 2009, at 8:46 AM, David Norton <david(a)nortoncrew.com<mailto:
> david(a)nortoncrew.com>> wrote:
>
> Hello Bruce,
>
> Does the WSDL specify a different URL for the service? I have had to use
> the following code because the WSDLs I'm using specify "localhost:8080":
>
> client = Client(url+"?wsdl")
> client.wsdl.service.setlocation(url)
>
> Best,
> David Norton
>
> On Jun 19, 2009, at 8:02 PM, Bruce Edge wrote:
>
> I'm having a problem with https basic authentication
>
> Is there something I'm doing wrong here?
>
> security = Security()
> token = UsernameToken('username', 'password')
> security.tokens.append(token)
> url = '<https://targetboc:8443/service-war/dpmcore?wsdl>
> https://targetboc:8443/service-war/dpmcore?wsdl'
> c = Client(url, wsse=security)
> print c.service
>
> # OK so far
>
> c.service.getOemKey(wsse=security)
>
> # fails with
>
> Traceback (most recent call last):
> File "<input>", line 1, in <module>
> File "wsenv.py", line 22, in <module>
> c.service.getOemKey(wsse=security)
> File "suds/client.py", line 240, in __call__
> return target.call(*args, **kwargs)
> File "suds/client.py", line 379, in call
> return method(*args, **kwargs)
> File "suds/client.py", line 240, in __call__
> return target.call(*args, **kwargs)
> File "suds/client.py", line 422, in call
> return client.invoke(args, kwargs)
> File "suds/client.py", line 480, in invoke
> result = self.send(msg)
> File "suds/client.py", line 504, in send
> reply = transport.send(request)
> File "suds/transport/https.py", line 64, in send
> return HttpTransport.send(self, request)
> File "suds/transport/http.py", line 78, in send
> fp = self.__open(u2request)
> File "suds/transport/http.py", line 99, in __open
> return self.urlopener.open(u2request)
> File "/usr/lib/python2.6/urllib2.py", line 383, in open
> response = self._open(req, data)
> File "/usr/lib/python2.6/urllib2.py", line 401, in _open
> '_open', req)
> File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
> result = func(*args)
> File "/usr/lib/python2.6/urllib2.py", line 1138, in https_open
> return self.do_open(httplib.HTTPSConnection, req)
> File "/usr/lib/python2.6/urllib2.py", line 1105, in do_open
> raise URLError(err)
> URLError: <urlopen error [Errno 111] Connection refused>
> >>>
>
> I tried the beta with the same result.
>
> I know the service is OK because I can do this:
>
> curl -ku username:password <
> https://localhost:8443/service-war/dpmcore/getOemKey>
> https://localhost:8443/service-war/dpmcore/getOemKey
> <soap:Envelope xmlns:soap="<http://schemas.xmlsoap.org/soap/envelope/>
> http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getOemKeyResponse
> xmlns="<http://lsi.com/dpm/core/types>http://lsi.com/dpm/core/types"
> xmlns:ns2="<http://lsi.com/dpm/types>http://lsi.com/dpm/types
> "><oemKey>LSI</oemKey></getOemKeyResponse></soap:Body></soap:Envelope>
>
>
> Thanks, Bruce
> _______________________________________________
> fedora-suds-list mailing list
> <mailto:fedora-suds-list@redhat.com>fedora-suds-list(a)redhat.com<mailto:
> fedora-suds-list(a)redhat.com>
> https://www.redhat.com/mailman/listinfo/fedora-suds-list
>
>
>
14 years, 10 months
Lack off Female Lirbido
by Braddy
aLck of Female Liibido (www meds30 org)
Statlion Owner Kills Rival in Ghas price Fight
14 years, 10 months
The oLve Hotels of Jaapn
by Moat Dobies
The Lhove Hotels off Japan (www meds70 net)
Statue offf Dennis the Menace Stolen
14 years, 10 months
Re: [Fedora-suds-list] Processing Complex Returns
by Tim Sawyer
Thanks Jeff.
Oddly, this works on one of my tests:
lResponseParameter = lWebService.execute()
self.assertEqual(lResponseParameter.Person.ID, '196868')
self.assertEqual(lResponseParameter.Person.Firstname, 'Harry')
self.assertEqual(lResponseParameter.Person.Surname, 'Smith')
but not another
lResponseParameter = lWebService.execute()
self.assertEqual(lResponseParameter.ApplicationTrace.Application, False)
self.assertEqual(lResponseParameter.ApplicationTrace.CCode, False)
Not really sure why, I've kind of ignored this for now. I'll see how it
goes as I develop more tests, see if I can pin down exactly when it
happens.
I'm using execute() to call suds's server.TxnName method, passing in the
correct parameters. I'm actually trying to write a wrapper so that I can
run these tests both with suds and with iron python as a .net client.
It's working for basic services, and I'm slowly trying to test some more
complex ones.
I'm now struggling with array type calls. With my iron python tests, I do
the following in my test to create a list of AgreementStatus objects to
pass to the web service:
lWebService = self.loadWsdl('pdi-web-services.CheckDecision')
lWebService.UserName = 'user'
lWebService.Password = 'password'
lWebService.SecurityToken = None
lAgreementStatus = lWebService.create('AgreementStatus')
lAgreementStatus.AgreementNumber = 'CPP245231'
lWebService.AgreementStatusList = (lAgreementStatus,)
lResponseParameter = lWebService.execute()
With suds this produces XML that looks like this:
<ns0:CheckDecisionCallParameter>
<ns0:AgreementStatusList>
<ns0:AgreementNumber>CPP245231</ns0:AgreementNumber>
<ns0:Decision xsi:nil="true"/>
<ns0:FailureDateTime xsi:nil="true"/>
<ns0:FailureReason xsi:nil="true"/>
</ns0:AgreementStatusList>
<ns0:Password>user</ns0:Password>
<ns0:SecurityToken xsi:nil="true"/>
<ns0:UserName>password</ns0:UserName>
</ns0:CheckDecisionCallParameter>
Which appears to be missing the container XML for each item in the
AgreementStatusList. I'd expect to see:
<ns0:AgreementStatusList>
<ns0:AgreementStatus>
<ns0:AgreementNumber>CPP245231</ns0:AgreementNumber>
as a structure, which is what OxygenXML editor produces when I have it
look at the WSDL and generate XML for the web service call.
How can I get this? (hopefully without changing my test code so that it
breaks the iron python tests!)
Thanks,
Tim.
---------- Forwarded Message ----------
Subject: Re: [Fedora-suds-list] Processing Complex Returns
Date: Tuesday 16 Jun 2009
From: Jeff Ortel <jortel(a)redhat.com>
To: Tim Sawyer <list.suds(a)calidris.co.uk>
Hey Tim,
Suds provides an objectification of the XML defined for the service
(method) parameters and returned objects. So, in this case it looks like
the method returns an ApplicationTrace object (based on the information
you provided). Assuming you've assigned this to a variable such as:
>
> trace = client.service.getApplicationTrace(...)
>
Then, trace looks like this:
>
> print trace
>
(ApplicationTrace){ <-------- The () indicates that class.
Application = False
CCode = False
CCodeLevel = "0"
Concurrency = False
Gateway = False
GatewayPerformance = False
Performance = False
PLSQLCode = False
Security = False
TraceOverrideList = ""
}
So, the following should work:
>
> self.assertEqual(trace.Application, True) >
-or-
>
> If trace.Application:
> print "The application is true"
>
.. And so on.
Hopes this helps,
Jeff
Tim Sawyer wrote:
> Hi Folks,
>
> I have a web service that returns the following:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <SOAP:Envelope
> xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
> <SOAP:Body>
> <tns:GetApplicationTraceResponseParameter
> xmlns:tns="http://ws.company.com/wsdl"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><tns:Application
> Trace> <tns:Application>false</tns:Application>
> <tns:CCode>false</tns:CCode>
> <tns:CCodeLevel>0</tns:CCodeLevel>
> <tns:Concurrency>false</tns:Concurrency>
> <tns:Gateway>false</tns:Gateway>
> <tns:GatewayPerformance>false</tns:GatewayPerformance>
> <tns:Performance>false</tns:Performance>
> <tns:PLSQLCode>false</tns:PLSQLCode>
> <tns:Security>false</tns:Security>
> <tns:TraceOverrideList/></tns:ApplicationTrace>
> </tns:GetApplicationTraceResponseParameter>
> </SOAP:Body>
> </SOAP:Envelope>
>
> I'm trying to write a test, using suds, of this web service. I'm
> calling the web service, and then doing this to the results, which isn't
working:
>
> self.assertEqual(lResponseParameter.ApplicationTrace.Application,
> False) self.assertEqual(lResponseParameter.ApplicationTrace.CCode,
> False)
> self.assertEqual(lResponseParameter.ApplicationTrace.CCodeLevel, '0')
> self.assertEqual(lResponseParameter.ApplicationTrace.Concurrency,
> False) self.assertEqual(lResponseParameter.ApplicationTrace.Gateway,
> False)
> self.assertEqual(lResponseParameter.ApplicationTrace.GatewayPerformanc
> e,
> False)
> self.assertEqual(lResponseParameter.ApplicationTrace.PLSQLCode, False)
> self.assertEqual(lResponseParameter.ApplicationTrace.Security, False)
>
> The error I get is:
>
> AttributeError: 'function' object has no attribute 'Application'
>
> I think it appears to think that ApplicationTrace is an __init__ function?
>
> logging.info(lResponseParameter.ApplicationTrace)
>
> gives:
>
> INFO:root:<bound method ApplicationTrace.__init__ of (ApplicationTrace){
> Application = False
> CCode = False
> CCodeLevel = "0"
> Concurrency = False
> Gateway = False
> GatewayPerformance = False
> Performance = False
> PLSQLCode = False
> Security = False
> TraceOverrideList = ""
> }>
>
> so the data does appear to be there.
>
> Any clues as to what I'm not understanding anyone?
>
> Cheers,
>
> Tim.
>
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list(a)redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list
-------------------------------------------------------
14 years, 10 months
an SAX exception when create SUDS Client
by Daniel
hi list,
I am running SUDS 0.3.5 with python 2.6 on Windows, and sometimes got
following errors when creating Client:
File "ylbcrawler.py", line 69, in process_page
crawler = wscrawler.WSCrawler(WS_URL, AGENT, logger)
File "D:\work\code\IndexGen\scratch1\chaowan\Lab\marmot\wscrawler.py",
line 14, in __init__
self.ws_client = Client(self.ws_url)
File "build\bdist.win32\egg\suds\client.py", line 106, in __init__
File "build\bdist.win32\egg\suds\wsdl.py", line 171, in __init__
File "build\bdist.win32\egg\suds\sax\parser.py", line 123, in parse
File "C:\Python26\lib\xml\sax\__init__.py", line 33, in parse
parser.parse(source)
File "C:\Python26\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "C:\Python26\lib\xml\sax\xmlreader.py", line 125, in parse
self.close()
File "C:\Python26\lib\xml\sax\expatreader.py", line 217, in close
self.feed("", isFinal = 1)
File "C:\Python26\lib\xml\sax\expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
File "C:\Python26\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: /tmp/suds\suds-831200760.http:1:0: no
element found
Then WSCrawler is used in another application, where its new instances will
be created many times.
This exception often arises after some successful creations.
It seems error when parsing by the tmp file's content.
The Client is created as this:
class WSCrawler(object):
def __init__(self, ws_url, agent, logger):
self.ws_url = ws_url
self.agent = agent
self.retry = 0
self.MAX_RETRY = 5
self.ws_client = Client(self.ws_url)
self.logger = logger
self.ws_url is a web service address published by C# app, which is like "
http://xxx.xxx.xx.xxx/Service1.asmx?wsdl".
Thanks,
Chao
14 years, 10 months
arrayType tag not being added
by Darrell Fuhriman
I'm trying to use the soap service provided here:
https://node.deq.state.or.us/PNWHostTest/node.asmx?WSDL
Using the code below, I am able to authenticate, but when I call
GetStations, I get an error back from the server.
I've tracked the problem down to a missing tag on the 'parameters'
attribute.
I'm getting:
<parameters xsi:type="ns2:ArrayOfString" ">
And what I should be getting is:
<parameters xsi:type="ns2:ArrayOfString" SOAP-
ENC:arrayType="ns2:string[31]">
(complete query is attached)
I'm using the current SVN version, though I've also tried 0.3.5.
class DEQDB:
def __init__(self):
url = 'https://node.deq.state.or.us/PNWHostTest/node.asmx?WSDL'
self.client = Client(url)
self.username = 'XXXXX'
self.password = 'YYYYY'
self.token=''
def authenticate(self):
self.token=self.client.service.Authenticate(userId=self.username,
credential = self.password,authenticationMethod = 'basic')
if self.token == '':
raise AuthenticationError,"Invalid credentials passed to remote"
def stationList(self):
params=self.client.factory.create('ArrayOfString')
params
.item
=
['1
','300
','','','','','','','','','','','','','','','','','','','','','','','','','','','','','']
print params
list
=
self
.client
.service.Query(securityToken=self.token,request='GetStations',rowId=0,
maxRows = 10,parameters=params)
return list
deq=DEQDB()
deq.authenticate()
print deq.stationList()
If I specify params._arrayType= 'ns2:string[31]', then the tag
appears, but without the SOAP-ENC, or any other namespace prefix,
which still causes an error on the other side.
Any suggestions on how to make this work?
Darrell
14 years, 10 months