import java.net.*;
import java.io.*;
import java.util.*;
import java.net.URLEncoder;
public class WeblogsPing {
public static final int SOCKET_TIMEOUT_VALUE = 60 * 1000;
public static int PORT = 0;
public static String IP = null;
public Socket s = null;
public PrintWriter out = null;
public InputStream is = null;
public static boolean soap = false;
// Pass in rpc.weblogs.com 80 1
// Pass in rpc.weblogs.com 80 1
public static void main(String rgs[]) {
IP="rpc.weblogs.com";
PORT=80;
boolean showPage = true;
String url = null;
url = " /RPC2";
HTTPWrapper httpWrapper = new HTTPWrapper();
int bcount = 0;
StringBuffer sb = new StringBuffer();
try {
String data = null;
data = "<?xml version=\"1.0\"?>\r\n" + "<methodCall>\r\n"
+ "<methodName>weblogUpdates.ping</methodName>\r\n"
+ "<params>\r\n" + "<param>\r\n"
+ "<value>Joels Blog</value>\r\n" + "</param>\r\n"
+ "<param>\r\n"
+ "<value>
http://feeds.feedburner.com/JoelsBlog/</value>\r\n"
+ "</param>\r\n" + "</params>\r\n"
+ "</methodCall>\r\n";
Socket s = null;
s = new Socket(IP, PORT);
s.setSoTimeout(SOCKET_TIMEOUT_VALUE);
PrintWriter out = new PrintWriter(s.getOutputStream());
String output = ("POST " + url + " HTTP/1.0\r\n"
+ "User-Agent: Java RPC Client (WinNT)\r\n"
+ "Content-Length: " + data.length() +
"\r\n"+"Content-Type: text/xml\r\n\r\n");
String finalOutput = output + data;
System.out.println("outgoing request:\n" + finalOutput);
out.print(finalOutput);
out.flush();
DataInputStream is = new DataInputStream(new BufferedInputStream(s
.getInputStream()));
int thechar;
while ((thechar = is.read()) != -1) {
bcount = bcount + 1;
sb.append((char) thechar);
}
is.close();
out.close();
s.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Page of Length " + sb.length() + " returned");
System.out.println(sb);
}
}