Code Monkey home page Code Monkey logo

Comments (24)

gggeek avatar gggeek commented on June 14, 2024

Hello.

The first thing to do would be to enable the debug mode of the client, so that you can see exactly the xml payload received in the response.

However, I just noticed the funny casing of the word 'STRiNG' in your error message.
That leads me to think that the response that you are getting is generated not via a widely-used xmlrpc library but some ad-hoc code, which produces a slightly wrong xml, which is not compatible with the phpxmlrpc lib. If that is proven to be the case, I would suggest fixing the server-side, if at all possible...

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

but if i run same code on browser it works perfect. if i run on console generate this error.

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

When you say "on browser", I assume that you mean that you have a web page written in php that uses the phpxmlrpc library to make a call to an external server?

If so, the best I can say is as above: add a call $client->setDebug(2) in your code to get a complete dump of the HTTP communication, so that we can inspect in detail what is going on

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024
---SENDING---
<?xml version="1.0"?>
<methodCall>
<methodName>listAccounts</methodName>
<params>
<param>
<value><struct>
<member><name>limit</name>
<value><int>1</int></value>
</member>
</struct></value>
</param>
</params>
</methodCall>
---END---
*   Trying a.b.c.d...
* TCP_NODELAY set
* Connected to a.b.c.d (a.b.c.d) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.0 / DHE-RSA-AES256-SHA
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=example.com
*  start date: Sep 27 00:00:00 2016 GMT
*  expire date: Nov 26 23:59:59 2017 GMT
*  issuer: C=US; O=GeoTrust Inc.; CN=RapidSSL SHA256 CA
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Digest with user 'USERNAME'
> POST /xmlapi/xmlapi HTTP/1.1
Host: a.b.c.d
User-Agent: XML-RPC for PHP 4.3.0
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: text/xml
Accept-Charset: UTF-8,ISO-8859-1,US-ASCII
Content-Length: 0

< HTTP/1.1 401 Unauthorized
< Date: Mon, 13 Nov 2017 13:04:28 GMT
< Server: Apache/2.2.22 (FreeBSD) mod_wsgi/2.8 Python/2.7.2 mod_ssl/2.2.22 OpenSSL/0.9.8q DAV/2
< WWW-Authenticate: Digest nonce="<removed>", opaque="<removed>", realm="XML API", qop="auth"
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Transfer-Encoding: chunked
< Content-Type: text/plain; charset=utf-8
< 
* Ignoring the response-body
* Curl_http_done: called premature == 0
* Connection #0 to host a.b.c.d left intact
* Issue another request to this URL: 'https://a.b.c.d:443/xmlapi/xmlapi'
* Found bundle for host a.b.c.d: 0x5614d84cfa80 [can pipeline]
* Re-using existing connection! (#0) with host a.b.c.d
* Connected to a.b.c.d (a.b.c.d) port 443 (#0)
* Server auth using Digest with user 'USERNAME'
> POST /xmlapi/xmlapi HTTP/1.1
Host: a.b.c.d
Authorization: Digest username="USERNAME", realm="XML API", nonce="<removed>", uri="/xmlapi/xmlapi", cnonce="<removed>", nc=00000001, qop=auth, response="<removed>", opaque="<removed>"
User-Agent: XML-RPC for PHP 4.3.0
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: text/xml
Accept-Charset: UTF-8,ISO-8859-1,US-ASCII
Content-Length: 221

* upload completely sent off: 221 out of 221 bytes
< HTTP/1.1 200 OK
< Date: Mon, 13 Nov 2017 13:04:28 GMT
< Server: Apache/2.2.22 (FreeBSD) mod_wsgi/2.8 Python/2.7.2 mod_ssl/2.2.22 OpenSSL/0.9.8q DAV/2
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Transfer-Encoding: chunked
< Content-Type: text/xml
< 
* Curl_http_done: called premature == 0
* Connection #0 to host a.b.c.d left intact

---CURL INFO---
url: https://a.b.c.d:443/xmlapi/xmlapi
content_type: text/xml
http_code: 200
header_size: 666
request_size: 952
filetime: -1
ssl_verify_result: 20
redirect_count: 1
total_time: 0.533197
namelookup_time: 5.4E-5
connect_time: 5.6E-5
pretransfer_time: 0.000277
size_upload: 221
size_download: 365
speed_download: 684
speed_upload: 414
download_content_length: -1
upload_content_length: 221
starttransfer_time: 0.143867
redirect_time: 0.389067
redirect_url: 
primary_ip: a.b.c.d
certinfo: 
primary_port: 443
local_ip: 192.168.1.11
local_port: 57784
---END---

---GOT---
HTTP/1.1 401 Unauthorized
Date: Mon, 13 Nov 2017 13:04:28 GMT
Server: Apache/2.2.22 (FreeBSD) mod_wsgi/2.8 Python/2.7.2 mod_ssl/2.2.22 OpenSSL/0.9.8q DAV/2
WWW-Authenticate: Digest nonce="<removed>", opaque="<removed>", realm="XML API", qop="auth"
Vary: Accept-Encoding
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/plain; charset=utf-8

HTTP/1.1 200 OK
Date: Mon, 13 Nov 2017 13:04:28 GMT
Server: Apache/2.2.22 (FreeBSD) mod_wsgi/2.8 Python/2.7.2 mod_ssl/2.2.22 OpenSSL/0.9.8q DAV/2
Vary: Accept-Encoding
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/xml

<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><struct>
<member>
<name>accounts</name>
<value><array><data>
<value><struct>
<member>
<name>username</name>
<value><string>1234567890</string></value>
</member>
<member>
<name>credit_limit</name>
<value><double>9.0</double></value>
</member>
<member>
<name>description</name>
<value><string>Acme Co.</string></value>
</member>
<member>
<name>i_account</name>
<value><int>9645615649</int></value>
</member>
<member>
<name>base_currency</name>
<value><string>BTC</string></value>
</member>
<member>
<name>balance</name>
<value><double>-1.02571465</double></value>
</member>
<member>
<name>expired</name>
<value><boolean>0</boolean></value>
</member>
<member>
<name>registration_status</name>
<value><nil/></value></member>
<member>
<name>blocked</name>
<value><boolean>0</boolean></value>
</member>
</struct></value>
</data></array></value>
</member>
<member>
<name>result</name>
<value><string>OK</string></value>
</member>
</struct></value>
</param>
</params>
</methodResponse>


---END---

HEADER: date: Mon, 13 Nov 2017 13:04:28 GMT
HEADER: server: Apache/2.2.22 (FreeBSD) mod_wsgi/2.8 Python/2.7.2 mod_ssl/2.2.22 OpenSSL/0.9.8q DAV/2
HEADER: vary: Accept-Encoding
HEADER: content-encoding: gzip
HEADER: transfer-encoding: chunked
HEADER: content-type: text/xml

Fault. Code: 2, Reason: Invalid return payload: enable debugging to examine incoming payload xmlrpc element STRiNG cannot be child of VALUE

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

error produced at line 320 on Request.php

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

error produces only while running on console:
php script.php
when i run with elinks there is no error:
elinks https://localhost/script.php

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

interesting! when i run my codes in debian there is this error. but same codes run perfectly in my mac. (mac php71 apache24 with brew)

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

any news?

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

Sorry, busy times. I will try to take a look at this before end of week.

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

I have tested the following code on both Win 8.1 and Debian 8:

<?php
include('./lib/xmlrpc.inc');
$string = file_get_contents('./test.response');
\PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true;
$req = new \PhpXmlRpc\Request('hi');
$resp = $req->parseResponse($string, true);
var_dump($resp);

where test.response I have copied and pasted from your comments above.

In both cases it worked.

I suspect that in fact you might be executing more than 1 single xmlrpc call here (or at least parsing more than 1 response), and the error seen might not be related to the debug output that you pasted.

I am afraid that the only way for me to investigate more would be for you to send me the whole php script that is executing the call (and, if it needs a bigger framework to run, even better the whole app).

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

Firstly, thanks for your interest.
I run only 1 single xmlrpc call. In console there is this error. In browser there is no error and worked perfectly. I run with links but i did not like this method. If i found anything i will inform you.

thanks again...

from phpxmlrpc.

bunalng avatar bunalng commented on June 14, 2024

error came from request.php ine 319 and 320:

            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
                PhpXmlRpc::$xmlrpcstr['invalid_return'] . $xmlRpcParser->_xh['isf_reason']);

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

Lines 319-3209 are correct. The error message that you get in $xmlRpcParser->_xh['isf_reason'] is being generated by the xml parser, which is run before.
This is the bit of code that creates it:

                $parent = end($this->_xh['stack']);
                if (!array_key_exists($name, $this->xmlrpc_valid_parents) || !in_array($parent, $this->xmlrpc_valid_parents[$name])) {
                    $this->_xh['isf'] = 2;
                    $this->_xh['isf_reason'] = "xmlrpc element $name cannot be child of $parent";

                    return;
                }

And the really funny thing is that name is passed to the code of the lib by the xml engine itself (php)...

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

Closing as "can not reproduce" because there as been no feedback in more than one year. Feel free to reopen

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024

facing same issue, recieving data well , but getting this error

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

@pgururahul would you be able to provide me with the raw xml response that you get? If the server you are interacting with was publiclly accessible, so that I could query it directly, it would be even better.

PS: which version of phpxmlrpc/php/OS are you on?

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024
PhpXmlRpc\Response Object
(
    [val] => 0
    [valtyp] => 
    [errno] => 2
    [errstr] => Invalid response payload (you can use the setDebug method to allow analysis of the response) found not-xmlrpc xml element NIL
    [payload] => 
    [content_type] => text/xml
    [httpResponse:protected] => Array
        (
            [headers] => Array
                (
                    [date] => Sat, 10 Dec 2022 11:02:51 GMT
                    [server] => Apache/2.4.48 (FreeBSD) OpenSSL/1.1.1k mod_wsgi/4.7.0 Python/3.6
                    [content-length] => 8958
                    [content-type] => text/xml
                )

            [cookies] => Array
                (
                )

            [raw_data] => HTTP/1.1 401 Unauthorized
Date: Sat, 10 Dec 2022 11:02:51 GMT
Server: Apache/2.4.48 (FreeBSD) OpenSSL/1.1.1k mod_wsgi/4.7.0 Python/3.6
WWW-Authenticate: Digest realm="XML API", qop="auth", nonce="2323233", opaque="3232344"
Transfer-Encoding: chunked
Content-Type: text/plain; charset=utf-8

HTTP/1.1 200 OK
Date: Sat, 10 Dec 2022 11:02:51 GMT
Server: Apache/2.4.48 (FreeBSD) OpenSSL/1.1.1k mod_wsgi/4.7.0 Python/3.6
Content-Length: 8958
Content-Type: text/xml

<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><struct>
<member>
<name>i_contact</name>
<value><int>303419</int></value>
</member>
<member>
<name>username</name>
<value><int>303419</int></value>
</member>
</struct></value>
</param>
</params>
</methodResponse>


            [status_code] => 200
            [protocol_version] => 1.1
        )

)

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024

@gggeek Sorry, Thats private server . I managed to give you raw response coming from the server..

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

@pgururahul the error message in your sample is slightly different from the one in the original ticket: ... found not-xmlrpc xml element NIL.

What is really strange is that there is no trace of NIL in the xml which is part of the response.

Also, the server responded with Content-Length: 8958, but the xml chunk which followed is clearly much smaller than that - even taking into account newline characters, it should be around 500 bytes.

Just in case, if the server that you are contacting does make usage of the XMLRPC NIL extension, you should add to your code, before making any call, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true; Would you be able to test if doing that fixes your issue?

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024

which version of phpxmlrpc/php/OS are you on?.

Latest one.

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024

Also, the server responded with Content-Length: 8958, but the xml chunk which followed is clearly much smaller than that - even taking into account newline characters, it should be around 500 bytes...

Please Ignore this.. I cut down The content .. It is having confidential information. THe conetent was much lengthy. If u want, i can get u the count of the content length.

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024

Just in case, if the server that you are contacting does make usage of the XMLRPC NIL extension, you should add to your code, before making any call, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true; Would you be able to test if doing that fixes your issue?

Allright. Let me try with this

from phpxmlrpc.

pgururahul avatar pgururahul commented on June 14, 2024

\PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true; Thank You. It worked.

from phpxmlrpc.

gggeek avatar gggeek commented on June 14, 2024

lovely!

from phpxmlrpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.