H
Herman Geldenhuys
Hey.
Im trying to post some variables to an URL, but I get an error saying that
my XML is parsed incorrectly. I know that it is not. At closer inspection
I found out that some module in Python must be screwing up my request when
I try to send it.
Previously the code worked fine, but the problem occured when I included
the proxy/authentication code, so that must be what is messing around with
my request.
I substituted the original URL with a Zope script to post variable and
send them back to see what I get, testing it with and without the Proxy
code.
Here is the code:
#==========================
import urllib2
infoRequest = "<GETCLIENTSERVICES/>"
# VARIABLES TO SEND... it is the ArcXMLRequest that's going haywire!
params = urllib.urlencode({'ArcXMLRequest': infoRequest,
'JavaScriptFunction':'processXML',
'RedirectURL':'',
'BgColor':'#000000',
'FormCharset':'ISO-8859-1'})
proxy_info = {'port': 8080,
'host': '172.16.13.9',
'user': 'username',
'pass': 'password'}
proxy_support = urllib2.ProxyHandler({"http" :
"http://%(user)s:%(pass)s@%(host)s:%(port)s" %
proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)
req = urllib2.Request('http://serverX/debugScript', params) # Zope
server, or ARCIMS Server
u = urllib2.urlopen(req)
print u.read()
#===========================
http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERVICES/>"
but instead I get :
"<GETCLIENTSERVICES/%"
When I send "<GETCLIENTSERVICES/>\n\n" instead of "<GETCLIENTSERVICES/>",
I get back "<GETCLIENTSERVICES/>\n%" as a result.
If I'm not clear enough about the problem, please shout. Help will be
appreciated!!
Thanks
Herman
Im trying to post some variables to an URL, but I get an error saying that
my XML is parsed incorrectly. I know that it is not. At closer inspection
I found out that some module in Python must be screwing up my request when
I try to send it.
Previously the code worked fine, but the problem occured when I included
the proxy/authentication code, so that must be what is messing around with
my request.
I substituted the original URL with a Zope script to post variable and
send them back to see what I get, testing it with and without the Proxy
code.
Here is the code:
#==========================
import urllib2
infoRequest = "<GETCLIENTSERVICES/>"
# VARIABLES TO SEND... it is the ArcXMLRequest that's going haywire!
params = urllib.urlencode({'ArcXMLRequest': infoRequest,
'JavaScriptFunction':'processXML',
'RedirectURL':'',
'BgColor':'#000000',
'FormCharset':'ISO-8859-1'})
proxy_info = {'port': 8080,
'host': '172.16.13.9',
'user': 'username',
'pass': 'password'}
proxy_support = urllib2.ProxyHandler({"http" :
"http://%(user)s:%(pass)s@%(host)s:%(port)s" %
proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)
req = urllib2.Request('http://serverX/debugScript', params) # Zope
server, or ARCIMS Server
u = urllib2.urlopen(req)
print u.read()
#===========================
http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERVICES/>"
but instead I get :
"<GETCLIENTSERVICES/%"
When I send "<GETCLIENTSERVICES/>\n\n" instead of "<GETCLIENTSERVICES/>",
I get back "<GETCLIENTSERVICES/>\n%" as a result.
If I'm not clear enough about the problem, please shout. Help will be
appreciated!!
Thanks
Herman