* Create XMLHttp Object lxmlObj = CreateObject("Microsoft.XMLHTTP") * Set Header *lxmlObj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") * Base64 Encoding cEncoded = STRCONV(cBuffer,13) * cDecoded = STRCONV(cEncoded,14) * Define Authentication String cAuthenticate = "Basic " + cEncoded * Open POST lxmlObj.Open("POST", lcWSDL, .F., cAuthenticate) * Set Header lxmlObj.SetRequestHeader("Authentication", cAuthenticate) * Send lxmlObj.Send() * Response lcResponse = lxmlObj.ResponseTextBelow is Java code that was given to me that supposedly does HTTP basic authentication. I'm trying to do the same thing using Foxpro and the Microsoft.XMLHTTP object. Mine doesn't work. The guy I got the Java code from says his does. Anyone know what I need to do to mine to make the Foxpro code above work?
//import jdk classes import java.io.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.security.Security; import com.mckesson.common.security.Base64; public class HttpBasicAuth { static String protocalHandler = "com.sun.net.ssl.internal.www.protocol"; static String securityProvider = "com.sun.net.ssl.internal.ssl.Provider"; static String id = "userid"; static String password = "password"; static String request = "test message"; public static void main(String args[]) { String strUrl = "https://www.ftc.gov"; System.setProperty("java.protocol.handler.pkgs", protocalHandler); System.out.println("\nStarting test..."); //setup the JSSE handler for the connection Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); try { String authString = id + ":" + password; String encoding = Base64.encode(authString.getBytes()); System.out.println("authorization unencoded= " + authString + " encoded = " + encoding +"\n\n"); //setup the HTTP connection java.net.URL oURL = new java.net.URL(strUrl); HttpURLConnection oUC (HttpURLConnection)oURL.openConnection(); //setup the auth header oUC.setRequestProperty("authorization", "Basic: " + encoding); oUC.setDoInput(true); oUC.setDoOutput(true); oUC.connect(); PrintWriter pw = new PrintWriter(oUC.getOutputStream()); pw.print(request); pw.close(); //grab the response BufferedReader oBR = new BufferedReader(new InputStreamReader(oUC.getInputStream())); String oStr = null; //display the response to STDOUT while((oStr = oBR.readLine()) != null) { System.out.println(oStr); } } catch(Exception oExc) { System.out.println(oExc); } System.out.println("\n\n"); } }