|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
Has anyone built a JS client making XML RPC calls to PHP PRC enabled server? I can invoke server methods with the client using the xmlrpc-epi-php library OK But not with js. More specifically if I use js Microsoft.XMLHTTP activeX object and send the server replies: faultString server error. method not found. faultCode -32601 If this looks familiar please respond : ) xmlhttp.send("<?xml version='1.0' encoding='iso-8859-1' ?> <methodCall>echo1<methodName> </methodName><params> <param> <value> <string>HELLO</string> </value> </param></params></methodCall>"); Thanx |
|
#2
|
|||
|
|||
|
Well I managed to work it out by my self so there! : )
Here is a sample code of how I do it 4 anyone that needs to know: JS client making a RPC call to a PHP server: The server method "echo" simply returns the parameter massed to it. <script language="JavaScript"> // Creating an MS XMLHTTP request object - get the latest SDK for v4.0 var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0"); //Open the connection xmlhttp.Open("POST","/server_xmlrpc.php", false); // Define the XML Header xmlhttp.setRequestHeader("User-Agent", "xmlrpc-epi-php/0.2 (PHP)"); xmlhttp.setRequestHeader("Content-Type", "text/xml"); // Define ther xml request into a string var xml_request = "<?xml version='1.0' ?>"+ "<methodCall>"+ "<methodName>echo</methodName>"+ "<params>"+ "<param>"+ "<value>"+ "<string>I've done it at last!</string>"+ "</value>"+ "</param>"+ "</params>"+ "</methodCall>"; // set the xml content length var length = xml_request.length; xmlhttp.setRequestHeader("Content-length", length); // send the request xmlhttp.send(xml_request); // retreive output from the server var out = xmlhttp.responseText; document.write(out); </script> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Xml - Rpc Js && Php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|