(Java) HTTP Post XML
Demonstrates how to POST XML to a website.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http = new CkHttp();
// Make sure to replace the URL with something real...
String url = "https://example.com/example.asp";
String xmlBody = "<test>This is the XML to be sent</test>";
CkHttpResponse resp = http.PostXml(url,xmlBody,"utf-8");
if (http.get_LastMethodSuccess() == false) {
System.out.println(http.lastErrorText());
}
else {
// Examine the body of the response.
System.out.println(resp.bodyStr());
}
}
}
|