NYCPHP Meetup

NYPHP.org

[nycphp-talk] PEAR XML-RPC server does not like carriage returns (details enclosed)

Jayesh Sheth jayeshsh at ceruleansky.com
Sun Nov 21 00:56:22 EST 2004


Hello everyone,

Some of you may remember my presentation at NYPHP from June of this year
(2004) [ http://www.moztips.com/index.php?id=335 ]. I released the code to
an earlier version of fortune cookies code at moztips.com [
http://www.moztips.com/index.php?id=266 ].

Some people who were using versions of PHP greater than 4.3.5 experienced
errors on the JavaScript side (e.g. "someThing is not a function"). In
reality, these were caused by errors / XML-RPC faults triggerd by the PEAR
XML-RPC server.

I have done a lot of debugging since, and here is what I have found:

The JavaScript XML-RPC client, jsolait  [
http://xmlrpc.kollhof.net/index.xhtml ] sends the following bit of XML as
the initial HTTP request, asking the XML-RPC server which methods it
supports (If this message gets mangled, full details (including PHP code)
are posted online at: http://www.moztips.com/debug2/ ):

POST /xul_lessons/debug2/debugserver.php HTTP/1.1
Host: localhost
User-Agent: PEAR HTTP_Request class ( http://pear.php.net/ )
Connection: close
Content-Type: text/xml
Content-Length: 95

<?xml version="1.0"?>
<methodCall>
<methodName>system.listMethods</methodName>
</methodCall>

Then the server replies:

HTTP/1.1 200 OK
Date: Sun, 21 Nov 2004 04:32:09 GMT
Server: Apache/2.0.52 (Win32) mod_ssl/2.0.52 OpenSSL/0.9.7c PHP/4.3.9
X-Powered-By: PHP/4.3.9
Content-Length: 360
Connection: close
Content-Type: text/xml

<?xml version="1.0"?>
<!-- DEBUG INFO:



-->
<methodResponse>
<params>
<param>
<value><array>
<data>
<value><string>echoEcho</string></value>
<value><string>system.listMethods</string></value>
<value><string>system.methodHelp</string></value>
<value><string>system.methodSignature</string></value>
</data>
</array></value>
</param>
</params>
</methodResponse>

------ ------- --------

But, if the same initial HTTP request is sent with line breaks / carriage
returns after each XML tag, an error is produced.

Here is the request:

POST /xul_lessons/debug2/debugserver.php HTTP/1.1
Host: localhost
User-Agent: PEAR HTTP_Request class ( http://pear.php.net/ )
Connection: close
Content-Type: text/xml
Content-Length: 89

<?xml
version="1.0"?><methodCall><methodName>system.listMethods</methodName></methodCall>

And here is the response:

HTTP/1.1 200 OK
Date: Sun, 21 Nov 2004 04:33:18 GMT
Server: Apache/2.0.52 (Win32) mod_ssl/2.0.52 OpenSSL/0.9.7c PHP/4.3.9
X-Powered-By: PHP/4.3.9
Content-Length: 362
Connection: close
Content-Type: text/xml

<?xml version="1.0"?>
<!-- DEBUG INFO:



-->
<methodResponse>
<fault>
  <value>
    <struct>
      <member>
        <name>faultCode</name>
        <value><int>1</int></value>
      </member>
      <member>
        <name>faultString</name>
        <value><string>Unknown method</string></value>
      </member>
    </struct>
  </value>
</fault>
</methodResponse>

------- ------ ------

Does anyone know why this is happening? Incidentally, I tried this at
moztips.com and I was able to reproduce the error. But the thing is, the
NYPHP presentation hosted at moztips.com currently works. So, after all
this debugging, I don't know if I found the right error after all.

Another interesting thing is that the PEAR XML-RPC library, when acting as
a client sends an extra pair of empty "<params></params>" tags along with
intitial request.

Full code, including a test-case debug client and server that logs the
HTTP requests and response is available at:
http://www.moztips.com/debug2/

If anyone can help me with this, I will buy you a drink of your choice at
the next NYPHP talk-dinner!

Thanks in advance,

- Jay



More information about the talk mailing list