• Post Reply Bookmark Topic Watch Topic
  • New Topic

What this POST does ?  RSS feed

 
Forest Beekeeper
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Java experts.

As I am novice to this area I am trying to understand what following example is doing.

We wanted to use standard HTTP Adapter for our ERP software but not sure if it supports exactly this type of call.
ERP Vendor says that standard HTTP Adapter only supports POST and XML payload passed in a Message Body.

Provider gave us example in Java but we really wanted to use ERP HTTP adapter for this to avoid custom development.
So is code below in fact passing XML Payload in message body or not ? Or do they pass XML as part of the URL ?

HttpsURLConnection api_url = (
HttpsURLConnection)new URL("https","api.ourhost.com",443,"/page.asp").openConnection();
api_url.setSSLSocketFactory(factory);
api_url.setRequestMethod("POST");
api_url.setDoOutput(true);
api_url.setUseCaches(false);
api_url.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
api_url.connect();
DataOutputStream out = new DataOutputStream(api_url.getOutputStream());
String customer_id = "12345";
String str_rdat = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<request><req_id>83945003</req_id><req_data></req_data></request>";
String str_data = "cid=" + customer_id + "&rdat=" + URLEncoder.encode(str_rdat, "UTF-8");
out.writeBytes(str_data);
out.flush();
out.close();

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's passing the XML in the body of the HTTP request.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!