I am tring to get the response to a certain web page. I have tracked the request and response from the following page using http analyser. Its sending some kind of XML data with the post request. I have built a code that sends the same request, but getting error.perhaps the problem is with the format in which the xml data is send. Please , please do suggest.
I have attached correct request and response found out through http analyser along with the code down it.
Request
==========================================================
POST /securevault/reservations/canadcorp/srs/step2.php HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Host:
www.novgroup.com User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 609
Content-Type: text/xml
<wddxPacket version="1.0"><header /><data><struct><var name="parameters"><struct><var name="discount"><array length="5"><null /><null /><null /><null /><null /></array></var><var name="enddate"><string>Jul 13, 2006</string></var><var name="startdate"><string>Jul 12, 2006</string></var><var name="hotelid"><string>10</string></var><var name="roomid"><string>40</string></var><var name="adults"><number>1</number></var><var name="fields"><array length="2"><string>id</string><string>name</string></array></var></struct></var><var name="funcName"><string>getRoomPrice</string></var></struct></data></wddxPacket>
==========================================================
Response which is comming. ==========================================================
<wddxPacket version='1.0'><header/><data><struct><var name='cNames'><array length='2'><string>adate</string><string>rate</string></array></var><var name='rates'><array length='1'><array length='2'><string>2006-07-12</string><string>109.00</string></array></array></var></struct></data></wddxPacket>
============================================================================================================================
My code to get the response page ===========================
import java.net.*;
import java.io.*;
import java.net.HttpURLConnection.*;
public class testpost{
public static void main(String[] args) throws Exception {
URL downeyjrURL = new URL("https://www.novgroup.com/securevault/reservations/canadcorp/srs/step2.php");
HttpURLConnection c = (HttpURLConnection)(downeyjrURL.openConnection());
c.setDoOutput(true);
c.setRequestMethod("POST");
PrintWriter out = new PrintWriter(c.getOutputStream());
String xmlString;
String htmlString = "<wddxPacket version=1.0><header /><data><struct><var name=parameters><struct><var name=discount><array length=5><null /><null /><null /><null /><null /></array></var><var name=enddate><string>Jun 23, 2006</string></var><var name=startdate><string>Jun 22, 2006</string></var><var name=hotelid><string>10</string></var><var name=roomid><string>38</string></var><var name=adults><number>1</number></var><var name=fields><array length=2><string>id</string><string>name</string></array></var></struct></var><var name=funcName><string>getRoomPrice</string></var></struct></data></wddxPacket>";
// Here's whether the parameter is set.
out.println("xmldoc=" + URLEncoder.encode(htmlString));
//out.println("xmldoc=" + htmlString);
out.close();
BufferedReader in2 = new BufferedReader(new
InputStreamReader(c.getInputStream()));
String inputLine;
while((inputLine = in2.readLine()) != null)
System.out.println(inputLine);
in2.close();
}
}
//====================================================================================================================
but is giving error --no function called (). I think I am not able tosend the Xml in Right format.
Exact error-----------------------------------------------------------------------------------------------------------------------------------------------
br />
<b>Notice</b>: Undefined index: HTTP_RAW_POST_DATA in <b>/var/www/htdocs/novgr
oup.com/securevault/reservations/canadcorp/srs/step2.php</b> on line <b>27</b><b
r />
<br />
<b>Notice</b>: Undefined variable: HTTP_RAW_POST_DATA in <b>/var/www/htdocs/no
vgroup.com/securevault/reservations/canadcorp/srs/step2.php</b> on line <b>30</b
><br />
<br />
<b>Fatal error</b>: Call to undefined function: () in <b>/var/www/htdocs/novgr
oup.com/securevault/reservations/canadcorp/srs/step2.php</b> on line <b>42</b><b
r />
//==================================================================================================================
Please help me. any code or suggestion will be helpful.