How to make a HTTP Post request to a remote server ?
Hi Guys,
I'm new to java technology. I've a small problem with my code. All i need is to send a request to the remote server whose control is not at all in my hands with the POST method, which includes few of the parameters along with one of them is a xml formatted variable. The result of this request is an xml generated out which i want to fetch in my jsp code. I've tried it with the HTTPUrlConnection method and code for the same is below :
<%
try {
String xmlString = "<FARES><AGENCY_ID>TFI</AGENCY_ID><DEP_CITY>NYC</DEP_CITY><ARR_CITY>LON</ARR_CITY><DEP_DATE>12</DEP_DATE><DEP_MONTH>DEC</DEP_MONTH><OWRT>RT</OWRT></FARES>";
URL url = new URL("http://www.lowestairprice.com/Canada/mars.asp?WCI=Start&WCE=XMLFARES&reqMsg=Yes&");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setInstanceFollowRedirects(true);
con.setFollowRedirects(true);
con.setRequestMethod("POST");
con.setDoOutput(true);
out.println("Testing...");
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
bw.write("xmltekst=" + xmlString);
bw.flush();
bw.close();
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line = br.readLine();
String result ="";
while (line !=null) {
result += line;
line = br.readLine();
br.close();
out.println("Resultat: " + result);
} catch(Exception exc) {
exc.printStackTrace();
out.println(exc);
%>
But when i run this on browser it gives me the following error.
java.net.MalformedURLException: unknown protocol: https
Now the response they provide is thrown back with the https protocol instead of the http. How can i fetch their response in my jsp code and store it in a local variable.
If anybody can help me out in this, i would be thankful for the same.
Thanking You,
Rgds,
Gaurav
(Software Engineer)
Ultra Infotech.
Have you tried to use HttpsURLConnection instead ?
Similar Messages
-
Can you make a HTTP GET request with JSC form element?
It seems the form element in JSC make a HTTP POST request by default, but is it possible to make a HTTP GET request by the form element in JSC?
(It is worth to mention here that HTTP GET request has its distinctive advantages like you can embed the parameters in a URL and bookmark it)
Thank you very much.Jim,
I am doing the sameway as you suggested to MISS_DUKE
But have you face any problems in doing so? In otherwords its the page rendering correctly?
On requesting the same page multiple times, Every time I get the page that was rendered for the first time.
To see the correct results, I need to close the browser and check it .
see my previous queries here
http://swforum.sun.com/jive/thread.jspa?threadID=54379&messageID=208223#208223
http://swforum.sun.com/jive/thread.jspa?threadID=56440&messageID=214302#214302
http://swforum.sun.com/jive/thread.jspa?threadID=56676&messageID=214987#214987
http://swforum.sun.com/jive/thread.jspa?threadID=56390&messageID=214139#214139
And I am still expecting the answer from experts. But nobody turn arround
Thanks,
Sudhakar -
Retrieve data/files fro HTTP POST request in On-Demand process
Hello,
I would like to integrate https://github.com/blueimp/jQuery-File-Upload to my APEX 4.2 application inside XE11g. I would like to use this kind of jQuery component, multiple file upload, use Drag & Drop, image resize, size limit, filter extensions etc...
This jQuery component and also others javascript uploaders sends data files to some defined URL. Developer need to build some servlet, php script or something on server side that will read files from HTTP request and stores it somewhere.
Do you know how to do it in APEX? How can I read data from HTTP POST request in PL/SQL? Now I can only call my On-Demand application process from javascript, but I am not able to read any data from HTTP POST in it.
Can I do it in APEX, or using MOD_PLSQL?
I would like to implement this:
1) some javascript uploader will call some URL of my application and sends HTTP POST with data files
2) I will read data files from HTTP POST and store them into database
3) I will create some HTTP response for javascript uploader
Thank you for some tipsI know about that existing plugin " Item Plugin - Multiple File Upload"
But I doesn't work in IE and has only basic features. Licence for commercial use is also needed. I would like to use some existing jQuery plugin. There are many of these plugins with nice features. And only one problem is that I need to create some server side process/servlet/script.. that can recieve HTTP request, get files from it and stores them into DB. -
HTTP POST Request with XML file in
Hi @ all,
I would like to send an HTTP Request with an XML File in the body to an SAP System
I have the target URL and the a XML File.
Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
If yes can anybody give me a hint?
I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
// compose url and request and call send function
function test($productID, $categoryID) {
// create url
$PIhost = "XXX.wdf.sap.corp";
$PIport = "50080";
$PIurl = "/sap/xi/adapter_plain";
$PIurl .= "?sap-client=800";
$PIurl .= "&service=XXX";
$PIurl .= "&namespace=XXX";
$PIurl .= "&interface=Frontend_Interface";
$PIurl .= "&qos=EO";
$PIurl .= "&sap-user=XXX";
$PIurl .= "&sap-password=XXX";
// create xml
$request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
$request .= "\t<FrontendInbound>\n";
$request .= "\t\t<ProductName/>\n";
$request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
$request .= "\t\t<ProductID>".$productID."</ProductID>\n";
$request .= "\t\t<MessageID/>\n";
$request .= "\t</FrontendInbound>\n";
$request .= "</n1:FrontendInbound_MessageType>";
// send http request
postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
// send post request to PI server
function postToHost($host, $port, $path, $referer, $data_to_send) {
$fp = fsockopen($host, $port);
if($fp) {
$res="";
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: text/plain\r\n");
fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data_to_send);
while(!feof($fp)) {
$res .= fgets($fp, 128);
fclose($fp);
return $res;
Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
Thanks in advance.
Chris
Edited by: Christian Kuehne on Feb 26, 2009 4:32 PMhi friend could you please share your solution regarding this query if u got it already?
-
Extract Portal User Name From HTTP POST Request (WSRP SOAP)
How can we extract the user name from the HTTP POST Request (*WSRP SOAP*) from the Portal to the Portlet Provider (Producer)?
We are load balancing between the Portal (10.1.14.2) and the providers (OC4J 10.1.3.3) and would like to extract the user name within the load balancer so we can create session affinity based on it.
BTW, we already tried using TCP Flow but were unable to see the user name.From the documentation, it seems that you need to use
HttpURLConnection.setRequestMethod("POST"); // "GET" is the defaultalthough I have seen examples on the web without it.
Try!
Edit: Also the single quotes around userid and password may be a problem.
Use the previous poster suggestion, but do not include the single quotes.
Edited by: baftos on Aug 6, 2008 4:27 PM -
How to make Oracle HTTP server a proxy server...
I need a proxy server for Google Mini search Appliance. I have Oracle 9iAS on AIX 5.2; can someone tell me how to make Oracle HTTP server function as Proxy server?
Thanks,
JessMaybe check the below link:-
http://httpd.apache.org/docs/1.3/mod/mod_proxy.html -
Query regarding sending XML over HTTP Post request
Hello,
I am trying to send XML data from a server to client via HTTP Post request
And vice versa � receive the data by a client
Assume that the xml data looks something like
<?xml+version="1.0"?>
So my post query will look like
http://<IP Address>:<port>/
POST /MessageReceiver.jsp HTTP/1.0
Host: www.SomeHost.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 38
%3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
This information will be received by the client and converted back to xml data.
My query is - is there some library/open-source stuff that
does the process of transcoding the entity's non-ASCII characters
at the server side
and decoding the URL back to human-readable form at the client side?
i.e. I need a simple mechanism to convert
<?xml+version="1.0"?>
to
%3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
at the server side, while sending data
and do the opposite at the client side to get the xml back.
Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?
Or is there any other standard tool that checks for well-formed properties of xml?
regards,
Deepak.java.net.URLEncoder / URLDecoder?
Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?No, it's for parsing HTML. An XML parser is checking for well-formedness in any case. -
Seeing this error when retrieving data from a SharePoint list. I have full access to the list. Any help would be appreciated.
DataSource.Error: SharePoint: Request failed: The remote server returned an error: (500) Internal Server Error. (An error occurred while processing this request.)
Details:
https://xyz/_vti_bin/ListData.svc/ListName
I think I figured out how to use Fiddler. Here's the information I captured-
This is a Tunnel. Status: OPEN, Raw Bytes Out: 3,797; In: 7,604
The selected session is a HTTP CONNECT Tunnel. This tunnel enables a client to send raw traffic (e.g. HTTPS-encrypted streams or WebSocket messages) through a HTTP Proxy Server (like Fiddler).
To enable Fiddler's HTTPS-decryption feature and view decrypted traffic, click Tools > Fiddler Options > HTTPS.
Request Count: 1
Bytes Sent: 107 (headers:107; body:0)
Bytes Received: 107 (headers:107; body:0)
Tunnel Sent: 3,797
Tunnel Received: 7,604
ACTUAL PERFORMANCE
ClientConnected: 11:06:11.389
ClientBeginRequest: 11:06:11.395
GotRequestHeaders: 11:06:11.395
ClientDoneRequest: 11:06:11.395
Determine Gateway: 0ms
DNS Lookup: 176ms
TCP/IP Connect: 77ms
HTTPS Handshake: 0ms
ServerConnected: 11:06:11.649
FiddlerBeginRequest: 11:06:11.649
ServerGotRequest: 11:06:11.649
ServerBeginResponse: 00:00:00.000
GotResponseHeaders: 00:00:00.000
ServerDoneResponse: 00:00:00.000
ClientBeginResponse: 11:06:11.649
ClientDoneResponse: 11:06:11.649
Overall Elapsed: 0:00:00.254
-= Fiddler Event Log =-
See http://fiddler2.com/r/?FiddlerLog for details.
10:33:33:8092 Fiddler Running...
10:33:33:8118 Fiddler.Network.AutoProxy> AutoProxy Detection failed.
10:33:33:8118 AutoProxy failed. Disabling for this network.
10:33:33:8118 Windows 8+ AppContainer isolation feature detected.
11:01:21:4125 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4145 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4185 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4258 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4268 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4298 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4398 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4398 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4518 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4518 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4528 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:4828 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:5789 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:5820 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:5879 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:6179 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:6530 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance
11:01:21:6924 HTTPSLint> Warning: ClientHello record was 382 bytes long. Some servers have problems with ClientHello's greater than 255 bytes. https://github.com/ssllabs/research/wiki/Long-Handshake-Intolerance -
(261936172) Q general How can I access an EJB hosted on a remote server?
Q<general> How can I access an EJB hosted on a remote server?
A<general> The ability to add EJB control files enables you to access an EJB that
is deployed to the server on which your web service is running. When you select
"add EJB control" you need to supply the home and remote interfaces for the EJB
as well as the JNDI name. This does not provide you with the capability for creating
a control for a remotely hosted EJB. To use a EJB hosted on another server you
will have to provide the appropriate code within your web service itself. You
will have to programmatically gain to access the JNDI for the remote server, lookup
up the home stub and use it to create the remote stub for the EJB. Of course,
to make this work you must have the necessary client interfaces in you classpath
(home and remote interfaces) which can easliy be achieved by adding the EJB client.jar
file to the lib directory in the webservice WEB-INF folder.just define the different server path in the description xml file
<jndi-name>jnp://serverA(B)/....</jndi-name> -
When I connect to the SharePoint site that contains the lists I need to build my query from , Power Query enumerates the list and displays them in the tool. I can click on the system tables and view the records but any table
in the list I created returns this error.
I can connect fine with InfoPath
[DataSource.Error] SharePoint: Request failed: The remote server returned an error: (500) Internal Server Error. (An error occurred while processing this request.)
thank you for your help
Andrew
Hi Andrew. In order for us diagnose this issue, you'll need to capture some network traces using a tool such as Fiddler and share them by sending a Frown.
To capture a trace using Fiddler, start Fiddler, enable the Tools > Fiddler Options > HTTPS > Decrypt HTTPS traffic option, start the capture, reproduce your issue, then stop and save the capture. You can find more information here.
Once you've done that, please send a Frown through the Power Query ribbon and attach the traces.
Thanks,
Ehren -
How to make an HTTP request via SSL
Hi,
I´m using an instance of the class CL_HTTP_CLIENT to make an HTTP request to a https server. as long as it requires an SSL authentication, it returns an ICM_HTTP_SSL_ERROR error message.
How do I tell my program to ask for user´s certificate, and use it in the http request?
I´m supossed to have hundreds of users online running this application (it´s over SRM 5.0). How can I reach this?
Thanks you very much.
Federico.Hello Frederico,
>1. By creating a new client, you mean go to "Environment->SSL Client Identitites" in STRUST, right? >Can I use a previously existing one?
I meant to create a new client SSL PSE. By default in a new Netweaver abap system, you have 3 of them : ANONYM, DFAULT and WSSE.
If you need more of them, you can create them with the menu "Go to-->Environment->SSL Client Identitites".
>2. I need this PSE client to have several 'identitites', I mean, to include several certificates from all my >users. Is it possible? If it´s not; how should I do so?
It seems that you want a different certificate per user. These client certificates in STRUST are designes to identify a SAP abap system, not human users. If you have 1000 users, you will not create 1000 certificates in STRUST !
Usually, you use only 2 entries here, one for anonymous HTTPS access and one authenticated HTTPS access. It is unusual to have several different identities for the same abap server. But it might be possible : for exemple, one identity on the intranet and an other one on the Internet.
>3. When I had my new PSE client, and my HTTP RFC destination of type 'G' configured to use that >PSE client, and when in abap I instantiate my http client (using CREATE_BY_DESTINATION method, >from CL_HTTP_CLIENT class): How does SAP knows which certificate to use? Because there will be >several users (hundreds) running this code to retrieve their specific data from a third party server.
>How does SAP knows whom certificate must use?
The certificate used will be the one defined in the HTTP destination.
You still seem to make the confusion between server client certificates and users client certificates.
a users client certificate is stored in the user's PC (or smartcard) and is used for HTTPS connections from the user's browser to the SSL server, not for an HTTPS connection from the ABAP server to another server.
Regards,
Olivier -
HTTP POST Request? How? Please Help!
Hi maybe this is a simple question. But I was able to do a GET Request from an applet to an ASP page just fine but I am having problems with the POST Request. How do you do a HTTP POST and put the parameter on the post data?
This is what I am doing:
url = new URL(queryParam);
connection = (HttpURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
// IS THIS CORRECT WAY TO ADD PARAMETER TO POST
connection.setRequestProperty("name","javaguy");
BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();The setRequestProperty() method is used to add HTTP headers to the request. The way you pass "post" parameters is to send them as the body of the message in "application/x-www-form-urlencoded" form. In other words, create a string of URLEncoded "name=value" pairs delimited by '&', just like you would see in the URL when making a GET request through the browser:
String paramStr = "name=javaguy&occupation=web+developer" ;
byte[] paramBuf = paramStr.getBytes("ISO-8859-1") ;
url = new URL(queryParam);
connection = (HttpURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
// THIS CORRECT WAY TO ADD PARAMETER TO POST
connection.setRequestProperty("Content-Length", Integer.toString(paramBuf.length)) ;
OutputStream out = connection.getOutputStream() ;
out.write(paramBuf) ;
out.flush() ;
out.close() ;
BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();Good luck! -
How to make a http request from a pl/sql procedure(URGENT)
I need to make a http request from a pl/sql procedure, can any one tell me which built-in package and which procedure/function we serve my need?
Thanks in advance.
Ram Prasad.You should use UTL_HTTP package, but before it install the JVM into DB
-
How to submit both HTTP post and a PDF
I would like to know how to submit HTTP post and a PDF to a HTTPS web server that will have a php code to parse. Any ideas would be great.
-DevIf you drop a regular button on the form and make it a submit button. In teh Submit panel you can control what is being submitted. One of the options is a PDF and another is an XDP (XML Data Package) where you can control what is in th epackage. One of the options for the package is the completed PDF (base64 encoded). If you use the XDP option you will get all of your data in XML and you will get the completed PDF in a separate node. I believe the node is Chunk. Then you can get the Chunk node an decode it and voila there is your data and completed PDF in a single transmission.
-
Can someone suggest how to make an interactive poster?
Hello everyone,
Could someone suggest how to make interactive images using photoshop. A professor of mine created a poster that had interactive graphics that made movements when rolled over as well as graphics. If someone could suggest a tutorial it would be appreciated. Any suggestions would be great! Thanks!
Sincerely,
Jimi Ryscovyan
[email protected]Images are not interactive on their own. There has to be more then an image file created with Photoshop. I'm sure the poster image you referring to was being displayed on some electronic device of some kind which was use by some image display application like a browser, that there was some programming involved for example interactive dynamic html, mouse overs , on click perhaps some javascript or even flash. And of course an input device like a mouse for a user to use. More then Photoshop is involved.
Maybe you are looking for
-
Hi I'm trying to setup SQL reporting services in a SharePoint 2013 farm consisting of: 4 WFE's 4 App Servers (NLB Central Admin x 4 servers) 4 App Severs for SSRS (Light limited SharePoint services running) I've installed SSRS 2012 SP1 by following t
-
Recruitment: Multiple Actions on the same day
Hi expert, Understand that in PA, we are able to perform multiple actions on the same day with the aid of Additional Actions infotype (0302). However, in Recruitment module (i.e. PB), we are unable to perform the above, the previous action record wil
-
Regarding customization of portal page
Hi any body suggest me how to change look and feel of a particular page in the portal. thanks sekhar.
-
Four fundamental questions on Sequences
DB version:11G Question *1* and *2*: To determine the current value of a Sequence i try SQL> SELECT SEQ_SHP_HDR.CURRVAL FROM DUAL; SELECT SEQ_SHP_HDR.CURRVAL FROM DUAL ERROR at line 1: ORA-08002: sequence SEQ_SHP_HDR.CURRVAL is not yet defined in t
-
Reader X: Read Out Loud function not working; no voice output
I was using this function in the Reader 9.4 but the voice got the text a bit garbled at times, so I thought I'd try the latest version of the Reader and see if the passage was less garbled. Reader X has no voice output at all, even after setting and