Hi,
I try to use xmlrpc in order to create an infolog from our application.
Here is a sample of how I try to do that.
You could see that the login seems to be OK (the server send back the sessionid/kp3), then, I try to send a read (infolog) request.
I’ve got an error (wrong XML?), and it seems that I’ve been disconnected (see response HEADER: connection: close)…
Could you help me to solve this problem ?
More infos :
- cookies are enabled on my Navigator
- egw version 1.8.004
Thanks.
The source Code :
//*****************Xmlrpc Login*************************/
$xml='<?xml version="1.0"?>
<methodCall><methodName>system.login</methodName>
<params><param><value><struct>
<member><name>domain</name><value><string>default</string></value></member>
<member><name>username</name><value><string>test</string></value></member>
<member><name>password</name><value><string>test1</string></value></member>
</struct></value></param></params></methodCall>';
$f=new xmlrpcmsg($xml);
$c=new xmlrpc_client("/EGW/xmlrpc.php", "my.domain.com", 80);
$c->setDebug(1);
$v=$c->send($xml);
//*****************infolog Read*************************/
$xmlReadInfolog='<?xml version="1.0"?>
<methodCall><methodName>infolog.boinfolog.read</methodName>
<params><param><value><struct>
<member><name>id</name><value><int>3</int></value></member>
</struct></value></param></params></methodCall>';
$cookies=$v->cookies();
var_dump($cookies);
// set Cookies on request
foreach($cookies as $cookie => $keys) $c->setcookie('$cookie', $keys['value']);
$fInfolog=new xmlrpcmsg($xmlReadInfolog);
$info=$c->send($fInfolog);
And the debug result :
—GOT—
HTTP/1.1 200 OK
Date: Fri, 08 Mar 2013 13:55:15 GMT
Server: Apache
X-Powered-By: PHP/5.4.12
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: sessionid=a0106a1d1da30fb685e723dd535838aa; path=/; domain=my.domain.com
Set-Cookie: kp3=TB3mTql3rVgPlMLDAGHs9sQ8; path=/; domain=my.domain.com
Set-Cookie: domain=default; path=/; domain=my.domain.com
Set-Cookie: last_loginid=test; expires=Fri, 22-Mar-2013 13:55:16 GMT; path=/; domain=my.domain.com
Set-Cookie: last_domain=default; expires=Fri, 22-Mar-2013 13:55:16 GMT; path=/; domain=my.domain.com
Content-length: 402
Connection: close
Content-Type: text/xml
<?xml version="1.0"?>
domain
default
sessionid
a0106a1d1da30fb685e723dd535838aa
kp3
TB3mTql3rVgPlMLDAGHs9sQ8
---END---
HEADER: date: Fri, 08 Mar 2013 13:55:15 GMT
HEADER: server: Apache
HEADER: x-powered-by: PHP/5.4.12
HEADER: expires: Thu, 19 Nov 1981 08:52:00 GMT
HEADER: cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
HEADER: pragma: no-cache
HEADER: set-cookie: sessionid=a0106a1d1da30fb685e723dd535838aa; path=/; domain=my.domain.com, kp3=TB3mTql3rVgPlMLDAGHs9sQ8; path=/; domain=my.domain.com, domain=default; path=/; domain=my.domain.com, last_loginid=test; expires=Fri, 22-Mar-2013 13:55:16 GMT; path=/; domain=my.domain.com, last_domain=default; expires=Fri, 22-Mar-2013 13:55:16 GMT; path=/; domain=my.domain.com
HEADER: content-length: 402
HEADER: connection: close
HEADER: content-type: text/xml
COOKIE: sessionid=a0106a1d1da30fb685e723dd535838aa
COOKIE: kp3=TB3mTql3rVgPlMLDAGHs9sQ8
COOKIE: domain=default
COOKIE: last_loginid=test
COOKIE: last_domain=default
—PARSED—
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘struct’ =>
array (
‘domain’ =>
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘string’ => ‘default’,
),
‘mytype’ => 1,
’_php_class’ => NULL,
)),
‘sessionid’ =>
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘string’ => ‘a0106a1d1da30fb685e723dd535838aa’,
),
‘mytype’ => 1,
’_php_class’ => NULL,
)),
‘kp3’ =>
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘string’ => ‘TB3mTql3rVgPlMLDAGHs9sQ8’,
),
‘mytype’ => 1,
’_php_class’ => NULL,
)),
),
),
‘mytype’ => 3,
’_php_class’ => NULL,
))
—END—
TRYING TO READ AN INFOLOG :
—GOT—
HTTP/1.1 200 OK
Date: Fri, 08 Mar 2013 13:55:16 GMT
Server: Apache
X-Powered-By: PHP/5.4.12
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Content-length: 296
Connection: close
Content-Type: text/xml
<?xml version="1.0"?>
faultCode
164
faultString
XML error: Reserved XML Name at line 3
---END---
HEADER: date: Fri, 08 Mar 2013 13:55:16 GMT
HEADER: server: Apache
HEADER: x-powered-by: PHP/5.4.12
HEADER: cache-control: no-cache, must-revalidate
HEADER: pragma: no-cache
HEADER: content-length: 296
HEADER: connection: close
HEADER: content-type: text/xml
—PARSED—
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘struct’ =>
array (
‘faultCode’ =>
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘int’ => 164,
),
‘mytype’ => 1,
’_php_class’ => NULL,
)),
‘faultString’ =>
xmlrpcval::__set_state(array(
‘me’ =>
array (
‘string’ => ‘XML error: Reserved XML Name at line 3’,
),
‘mytype’ => 1,
’_php_class’ => NULL,
)),
),
),
‘mytype’ => 3,
’_php_class’ => NULL,
))
—END—