Mantis Bugtracker          
testlink.org

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007701TestLinkAPI - XMLRPCpublic2016-10-16 14:292017-01-22 07:57
Reporterbugdoneoff 
Assigned Tofman 
PrioritynormalSeverityblockReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.9.15 (2015 Q4) 
Fixed in Version1.9.16 (2016 Q4) 
Summary0007701: XMLRPC API returns "XML-RPC server accepts POST requests only" for any request
DescriptionXMLRPC API returns "XML-RPC server accepts POST requests only" for any request
Steps To ReproduceCreate for a user API Key

And send POST request with body

<?xml version="1.0" encoding="UTF-8"?>
<methodCall xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions"> [^]
<methodName>tl.checkDevKey</methodName>
<params><param><value><struct><member><name>devKey</name><value>..your api key is here...</value></member></struct></value></param></params>
</methodCall>

Response is "XML-RPC server accepts POST requests only"
Additional InformationThere is a workaround I found here - https://foliovision.com/2007/05/xml-rpc-server-wordpress-error [^] :

Adding the following lines to lib/api/xmlrpc/v1/xmlrpc.php solved the problem

// Some browser-embedded clients send cookies. We don't want them.
$_COOKIE = array();

$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input" [^]);
TagsNo tags attached.
Database (MySQL,Postgres,etc)MySQL
BrowserChrome
PHP VersionPHP 7.0.8-0ubuntu0.16.04.3
TestCaseID
QA Team - Task Workflow StatusREADY FOR TESTING
Attached Files

- Relationships
child of 0007666closedfman Availables hot-fixes for 1.9.15 & How To get full fixed package from GitHub 

-  Notes
(0025509)
fman (administrator)
2016-10-17 19:15

Please provide php example that allows to reproduce issue, similar to examples we provide with testlink distribution
(0025512)
bugdoneoff (reporter)
2016-10-18 11:40
edited on: 2016-10-18 11:41

Sorry, I'm not familiar with PHP too much. An could not get quickly reproducing script using samples. But I generated PHP code in postman for you.

<?php

$request = new HttpRequest();
$request->setUrl('http://localhost/lib/api/xmlrpc/v1/xmlrpc.php' [^]);
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'cache-control' => 'no-cache'
));

$request->setBody('<?xml version="1.0" encoding="UTF-8"?>
<methodCall xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions"> [^]
<methodName>tl.checkDevKey</methodName>
<params><param><value><struct><member><name>devKey</name><value>5401d944d9e8araed0501b7383421771</value></member></struct></value></param></params>
</methodCall>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

(0025555)
DierickxD71 (reporter)
2016-11-07 15:14
edited on: 2016-11-07 15:14

First off, don't do that, use the examples.
Second, below an explanation how i got the examples to work for me.

1a) Copy "class-IXR.php" to "class-IXR2.php"
1b) On line 555 insert this command: "$contents = substr($contents, 4);"
(for one reason or another the response received has 4 bytes too many at the front, so this was my workaround)

2) Make a file "whatever.php" containing this code: (without horiz.lines)
------------------------------------------------
<?php
define("DEV_KEY", "notadevkey");
require_once 'class-IXR2.php';
$server_url = "http://localhost:80/testlink/lib/api/xmlrpc/v1/xmlrpc.php"; [^]
$client = new IXR_Client($server_url);
$client->debug=false;

$method = 'checkDevKey';
$args = array();
$args['devKey'] = '5401d944d9e8araed0501b7383421771';

if(!$client->query("tl.{$method}", $args)) {
   echo "something went wrong - " . $client->getErrorCode() . " - " . $client->getErrorMessage() . " - " . $client->getResponse();
} else {
   echo $client->getResponse();
}

?>
------------------------------------------------

WARNING: make sure that $server_url is correct !!!

This should help you get on your way. A lot easier than having to construct your own xml structure.

(hope you agree with this fman)

(0025825)
anton7811 (reporter)
2017-01-06 14:19

As I see this is a server side issue. It could be reproduced with both 1.9.14 and 1.9.15 after upgrade PHP5 -> PHP7 (and maybe apache2, but not sure). I'd like to resolve this on server instead of "patching" all clients. Moreover I use python based clients installed from PyPI which works great with testlink on the older LAMP software.

Unfortunately modifying of class-IXR.php doesn't solve the problem for me.
(0025826)
anton7811 (reporter)
2017-01-06 14:57

Steps to reproduce:
curl -i -H "Content-Type: text/xml" "http://serveraddress/testlink/lib/api/xmlrpc/v1/xmlrpc.php" [^] -X POST -d "<?xml version="1.0"?><methodCall><methodName>tl.ping</methodName><params></params></methodCall>"
(0025828)
anton7811 (reporter)
2017-01-06 17:12

Seems the problem is in class-IXR.php. Create methods are php4 like.
This is 3d party file. What's the origin? Wordpress? I'll try to update it.
(0025829)
fman (administrator)
2017-01-07 12:26
edited on: 2017-01-07 12:31

https://github.com/TestLinkOpenSourceTRMS/testlink-code/commit/c7fae789cff75736598fdf8e66512e3e714c0eba [^]

All tests with server and client on same host => localhost
using XAMPP with PHP 7.03
==========================================
Franciscos-Air:~ fman$ curl -i -H "Content-Type: text/xml" "http://localhost/development/github/testlink-code/lib/api/xmlrpc/v1/xmlrpc.php" [^] [^] -X POST -d "<?xml version="1.0"?><methodCall><methodName>tl.ping</methodName><params></params></methodCall>"
HTTP/1.1 200 OK
Date: Sat, 07 Jan 2017 12:24:27 GMT
Server: Apache/2.4.18 (Unix) OpenSSL/1.0.2f PHP/7.0.3 mod_perl/2.0.8-dev Perl/v5.16.3
X-Powered-By: PHP/7.0.3
Connection: close
Content-Length: 166
Content-Type: text/xml;charset=UTF-8

<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value>
        <string>Hello!</string>
      </value>
    </param>
  </params>
</methodResponse>
curl: (3) [globbing] bad range specification in column 2
===========================================

(0025830)
fman (administrator)
2017-01-07 12:31

Please do changes and provide feedback.
(0025845)
anton7811 (reporter)
2017-01-17 14:37

This is the fix in my case:
$ git diff lib/api/xmlrpc/v1/xmlrpc.php
diff --git a/lib/api/xmlrpc/v1/xmlrpc.php b/lib/api/xmlrpc/v1/xmlrpc.php
index 7edb30e..7a3e501 100644
--- a/lib/api/xmlrpc/v1/xmlrpc.php
+++ b/lib/api/xmlrpc/v1/xmlrpc.php
@@ -20,6 +20,10 @@
  *
  */
 
+if (!isset($HTTP_RAW_POST_DATA)) {
+ $HTTP_RAW_POST_DATA = file_get_contents('php://input' [^]);
+}
+
 require_once("xmlrpc.class.php");
 
 $XMLRPCServer = new TestlinkXMLRPCServer();


I tried to fix all PHP4 constructors but those errors were not critical, the only problem they caused - garbage in apache logs.
(0025848)
fman (administrator)
2017-01-18 06:25

@anton7811
question is: why youa proposing your fix without testing the fix I've posted?
(0025849)
DierickxD71 (reporter)
2017-01-18 07:00

For me the fix of fman works. (v1.9.15)
(0025850)
anton7811 (reporter)
2017-01-18 08:07
edited on: 2017-01-18 08:23

Sorry, I missed a link to the fix in your message.

I did pull from main repository, the fix works well.
Thank you!

(0025860)
fman (administrator)
2017-01-22 07:57

1.9.16 released

- Issue History
Date Modified Username Field Change
2016-10-16 14:29 bugdoneoff New Issue
2016-10-17 19:15 fman Note Added: 0025509
2016-10-17 19:15 fman Status new => feedback
2016-10-18 11:40 bugdoneoff Note Added: 0025512
2016-10-18 11:40 bugdoneoff Status feedback => new
2016-10-18 11:41 bugdoneoff Note Edited: 0025512 View Revisions
2016-11-07 15:14 DierickxD71 Note Added: 0025555
2016-11-07 15:14 DierickxD71 Note Edited: 0025555 View Revisions
2017-01-06 14:19 anton7811 Note Added: 0025825
2017-01-06 14:57 anton7811 Note Added: 0025826
2017-01-06 17:12 anton7811 Note Added: 0025828
2017-01-07 12:26 fman Note Added: 0025829
2017-01-07 12:30 fman Note View State: 0025829: public
2017-01-07 12:31 fman Note Edited: 0025829 View Revisions
2017-01-07 12:31 fman QA Team - Task Workflow Status => TBD
2017-01-07 12:31 fman Note Added: 0025830
2017-01-07 12:31 fman Assigned To => fman
2017-01-07 12:31 fman Status new => feedback
2017-01-07 12:32 fman Relationship added child of 0007666
2017-01-17 14:37 anton7811 Note Added: 0025845
2017-01-18 06:25 fman Note Added: 0025848
2017-01-18 07:00 DierickxD71 Note Added: 0025849
2017-01-18 08:07 anton7811 Note Added: 0025850
2017-01-18 08:23 anton7811 Note Edited: 0025850 View Revisions
2017-01-19 20:17 fman QA Team - Task Workflow Status TBD => READY FOR TESTING
2017-01-19 20:17 fman Status feedback => resolved
2017-01-19 20:17 fman Fixed in Version => 1.9.16 (2016 Q4)
2017-01-19 20:17 fman Resolution open => fixed
2017-01-22 07:57 fman Note Added: 0025860
2017-01-22 07:57 fman Status resolved => closed



Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker