Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Writing a XML-RPC client

Ash Qin
A fox!
Join date: 16 Feb 2005
Posts: 103
01-23-2006 00:59
For the past few days, I've been trying to write a XML-RPC client which communicates with Secondlife objects from scratch.

I suspect I'm not doing something right in the HTTP protocol. Unfortunately, I cannot figure out what the heck I'm doing wrong with my communications, and I'm wondering if someone would be kind enough to point out what is wrong with what I'm doing.

Notes:
number: - status message
number> - outgoing data
number< - incomming data

CODE
Creating new connection, naming it: SL.1138006250165126008
SL.1138006250165126008: Connecting to xmlrpc.secondlife.com:80...
SL.1138006250165126008: Connection established.
SL.1138006250165126008: Generating XML file...
SL.1138006250165126008: Generation complete.
SL.1138006250165126008: Sending headers...
SL.1138006250165126008> POST /cgi-bin/xmlrpc.cgi HTTP/1.1
SL.1138006250165126008> Host: xmlrpc.secondlife.com
SL.1138006250165126008> Content-type: application/x-www-form-urlencoded
SL.1138006250165126008> Content-length: 413
SL.1138006250165126008> Connection: close
SL.1138006250165126008>
SL.1138006250165126008>
SL.1138006250165126008: Headers sent, sending data...
SL.1138006250165126008> <?xml version="1.0"?>
<methodCall>
<methodName>llRemoteData</methodName><params>
<param><value><struct>
<member><name>Channel</name><value><string>0ae1ebdb-55a4-df6f-bc94-fe07bc2c45bb</string></value></member>
<member><name>IntValue</name><value><int>0</int></value></member>
<member><name>StringValue</name><value><string>testing</string></value></member>
</struct></value></param></params></methodCall>

SL.1138006250165126008: Data sent, closing headers...
SL.1138006250165126008>
SL.1138006250165126008>
SL.1138006250165126008: Headers closed.
SL.1138006250165126008< HTTP/1.1 200 OK
SL.1138006250165126008< Date: Mon, 23 Jan 2006 08:50:58 GMT
SL.1138006250165126008< Server: Apache
SL.1138006250165126008< Vary: Accept-Encoding,U
SL.1138006250165126008< Set-Cookie: Apache=83.21.17.89.133271138006258838; path=/; expires=Thu, 21-Jan-16 08:50:58 GMT
SL.1138006250165126008< Content-Length: 324
SL.1138006250165126008< Connection: close
SL.1138006250165126008< Content-Type: text/xml
SL.1138006250165126008< Content-Language: en
SL.1138006250165126008<
SL.1138006250165126008< <?xml version="1.0"?><methodResponse><fault><value><struct><member><name>faultString</name><value><string>parse error. not well formed.
SL.1138006250165126008<
SL.1138006250165126008< error occurred at line 2, column 0, byte index 1</string></value></member><member><name>faultCode</name><value><int>-32700</int></value></member></struct></value></fault></methodResponse>
_____________________
Do not meddle in the affairs of kitsune, for you are crunchy and good with ketchup.
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
01-23-2006 06:01
Works for me.

CODE
"POST /cgi-bin/xmlrpc.cgi HTTP/1.1\r\nHost: xmlrpc.secondlife.com\r\nContent-type: application/x-www-form-urlencoded\r\nContent-length: 413\r\nConnection: close\r\n\r\n"
"<?xml version=\"1.0\"?>\n\r<methodCall>\n\r<methodName>llRemoteData</methodName><params>\n\r<param><value><struct>\n\r<member><name>Channel</name><value><string>0ae1ebdb-55a4-df6f-bc94-fe07bc2c45bb</string></value></member>\n\r<member><name>IntValue</name><value><int>0</int></value></member>\n\r<member><name>StringValue</name><value><string>testing</string></value></member>\n\r</struct></value></param></params></methodCall>\n\r"
HTTP/1.1 200 OK
Date: Mon, 23 Jan 2006 13:54:16 GMT
Server: Apache
Vary: Accept-Encoding,U
Set-Cookie: Apache=x.x.x.x.179881138024456905; path=/; expires=Thu, 21-Jan-16 13:54:16 GMT
Content-Length: 353
Connection: close
Content-Type: text/xml
Content-Language: en

<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Channel</name><value><string>0ae1ebdb-55a4-df6f-bc94-fe07bc2c45bb</string></value></member><member><name>StringValue</name><value><string/></value></member><member><name>IntValue</name><value><int>0</int></value></member></struct></value></param></params></methodResponse>


I tried swapping the \r\n in the request body to see if that was it, but it doesn't make a difference. I tried urlencoding the request body but the error is different. There could be other errors in your code that won't show up in logs though.

Linden's XMLRPC server doesn't currently seem to care, but if you want it to be correct, a User-Agent must be provided, and it should be (note case):

Content-Length: 413
Content-Type: text/xml