468,133 Members | 1,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

% in POST when using URLLIB2.URLOPEN with PROXY

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

Jul 18 '05 #1
1 2758
"Herman Geldenhuys" <he**************@fusemail.com> writes:
[...]
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!!

[...]

I wonder why, given your very clear explanation of the problem, you
haven't gone the extra inch to figure out why the code (urllib2+your
code) is posting incorrect data.

Somebody here might well guess the right answer to the problem, but
why not simply find out for yourself -- you're obviously quite capable
of doing so! Get those print statements in there!

Once you've done so, please help save the world and let us know what
the problem was.
John
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by O. Koch | last post: by
2 posts views Thread by Andre Bocchini | last post: by
4 posts views Thread by bmiras | last post: by
reply views Thread by Lee, Dustin | last post: by
reply views Thread by Pieter Edelman | last post: by
1 post views Thread by est | last post: by
1 post views Thread by Magnus.Moraberg | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.