简体   繁体   中英

How to send HTTP POST Requests from a Servlet to an external Web Service?

I am using GWT RPC to communicate between the client and the servlet, but from that same servlet, I need to send XML data through a POST HTTP Request to an External web service.

Basically, I send it some XML data, the Web Service processes it and returns some other XML Data that I will be using.

I tried using com.google.gwt.http.client.RequestBuilder but I was getting an Exception error ( java.lang.UnsatisfiedLinkError ). From what I've read, this is due because that class is a CLIENT class, and therefore cannot be used in the servlet (server-side).

What else can I use to build POST HTTP Requests?

Thanks in advance.

(Since the servlet is some java bytecode running, instead of java translated to Javascript on the client, I can basically use Java classes from the JRE/JDK)

Do NOT use any GWT specific classes in your servlet code!

why narrow the wide thing!

There are variety of APIs you can use to send HTTP requests to external servers..

If you don't like to use any external libs, then use java.net.URLConnection it is simple to use..

Or even you can use the most simpler one, Apache HTTPClient

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM