Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exact same request works in browser but not in my app!!!  RSS feed

 
Alexandre Folgueras
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, I have an application that posts requests through an https connection to a web server. When everything goes well, the server is supposed to send me an xml file. Once my String is encoded and ready to be sent, it looks something like this:


InputSegments=%3c%3fxml+version%3d%221.0%22+encoding%3d%22UTF-8%22%3f%3e%3cCNCustTransmitToEfx+



So when I send it, I receive an error from the server saying that the request is incorrect. But when I copy paste the request String to the browser, it works great!!! So I can't figure out what is wrong here... I am posting my function hoping that somebody will be able to help me:




Your help will be greatly appreciated!

Alex

[ UD: added code tags ]
[ January 20, 2006: Message edited by: Ulf Dittmer ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks more like an I/O question; I'll move the thread to the I/O and Streams forum. Please find it there, and continue the discussion.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the browser issues a GET request, while your code issues a POST. Maybe the server doesn't accept POSTs?
 
Sameer Damle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just wanted to point out



your securedUrl variable is not initialised to any value....

could this be a problem???
 
Alexandre Folgueras
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your replys, it is very appreciated!

First, I've tried to set the method to GET, but it still does not work... Second, for the securedURL variable that does not seem to be instantiated, it actually is, the method is part of a thread and all necessary variables were initialized before starting the thread...

The requests actually "talks" to the server because I'm able to read the error message the server gives me on the BufferedReader. It says ( Invalid input segments". The company who owns the server cannot offer me any support, but they told me that if I get this error, it's that I am not posting the request correctly ( the error is not the content of the request but the way I send it )

If you guys have anymore ideas, it would be greatly appreciated!

Thank you,
Alex
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try not encoding your request. That encoding is just for URLs, but if you're posting XML, you should send ">", "<", " " etc. unchanged.
 
Alexandre Folgueras
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server's doc actually says that I must encode the data, including the XML. But after reading your post, I tried not to encode it but it still does not work...

But if I copy the exact same encoded String that I am sending to the OutputStreamWriter and send it to the browser, it works!

Anymore ideas?

Thank you!!!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try a product like Jakarta Commons HttpClient, which takes care of details that you and I probably don't even know about.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!