• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to fix HttpsURLConnection POST XML request?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys!

Is my first time using HttpsURLConnection  and I've been trying to send a XML request but I'm getting 500 code as response and  the response message returns NULL.
I read that this could be encoding problems and I tried to set some connection properties but in all tests it kept returning 500 and null message.
OBS: When I get the same URL and the same xml message and test it via SoapUI it works fine.

Do you know if I'm missing some property?

XML example:


HttpsURLConnection:


Thank you.
 
Saloon Keeper
Posts: 7573
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5xx errors are server-side errors - check the server log files for any hints of what may be going wrong.
 
Tim Moores
Saloon Keeper
Posts: 7573
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see no "flush" or "close" happening on the outgoing streams. That's generally required.
 
Saloon Keeper
Posts: 27705
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Briefly, a "500" response for a Java webapp almost always means that the application code threw an Exception. Hence the need to check the server log for the receiving application.

And woe to those who write webapps that catch Exceptions and silently eat them..  
 
Marshal
Posts: 4468
567
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Tim that this looks like a server-side problem.

I ran basically your same code against httpbin.org and there were no issues.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic