GithubHelp home page GithubHelp logo

fxmlrpc's Introduction

fxmlrpc: really fast XML/RPC for PHP

Gitter Build Status Average time to resolve an issue Percentage of issues still open

  • A convenient, object oriented API (similar to the XML/RPC client in Zend Framework)
  • Very fast serializing and parsing of the XML payloads involved
  • Stick to the HTTP client you already use provided by HTTPlug
  • Licensed under the terms of the liberal MIT license
  • Supports modern standards: easy installation via composer, fully PSR-0, PSR-1 and PSR-2 compatible
  • Relentlessly unit- and integration tested
  • Implements all known XML/RPC extensions

Upgrading to 0.23.x

Instead of php-http/message-factory, we now use the PSR-7 compatible RequestFactoryInterface. You will have to change your custom HTTP client implementation and pass a Psr\Http\Message\RequestFactoryInterface implementation, a Psr\Http\Message\StreamFactoryInterface and a Http\Client\HttpClient to the HttpAdapterTransport. See below for details.

Installation

To install fxmlrpc run this command:

composer require lstrojny/fxmlrpc

Install dependencies

You must choose three packages for for the business of HTTP:

Example:

composer require php-http/message php-http/guzzle7-adapter

Instantiating HttpAdapterTransport

An example instantiation using Guzzle6:

$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(
        new \Http\Message\MessageFactory\DiactorosMessageFactory(),
        new \Http\Message\StreamFactory\DiactorosStreamFactory(),
        new \Http\Adapter\Guzzle7\Client($httpClient)
    )
);

Upgrading to 0.12.x

Instead of egeloen/http-adapter, we now use the PSR-7 compatible php-http/httplug. You will have to change your custom HTTP client implementation and pass a Http\Message\MessageFactory implementation and a Http\Client\HttpClient to the HttpAdapterTransport. See below for details.

Installation

To install fxmlrpc run this command:

composer require lstrojny/fxmlrpc

Install dependencies

You must choose three packages for for the business of HTTP:

Example:

composer require zendframework/zend-diactoros php-http/message php-http/guzzle6-adapter

Instantiating HttpAdapterTransport

An example instantiation using Guzzle6:

$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(
        new \Http\Message\MessageFactory\DiactorosMessageFactory(),
        new \Http\Adapter\Guzzle6\Client($httpClient)
    )
);

Upgrading to 0.11.x

We change ParserInterface::parse() method interface, now isn't required to pass second parameter ($isFault), parser should throw an exception FaultException when fault message is encountered in server response.

Upgrading to 0.10.x

0.10.x comes with a couple of breaking changes: We used to ship our own bridges for interoperability with various HTTP clients but moved that responsibility to a 3rd party library called Ivory HTTP Adapter. IMPORTANT NOTE: the library is not installed by default as you could choose to use fxmlrpc with just your own implementation of the fXmlRpc\Transport\TransportInterface. To install the library – and that’s what you most likely want – add this line to your composer.json

"egeloen/http-adapter": "~0.6"

… and run composer update

Instantiating an HTTP transport

In order to use the new adapters, you need to change how you instantiate fXmlRpc and its transport. This is how instantiating a custom transport looked before:

$httpClient = new GuzzleHttp\Client();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\Guzzle4Bridge($httpClient)
);

This is how you do it now:

$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new Ivory\HttpAdapter\GuzzleHttpHttpAdapter($httpClient))
);

Latest improvements

  • [BC] PSR-7 support
  • [IMPROVEMENT] PHP7 compatibility
  • [IMPROVEMENT] Refactor parsers throw fault exception instead of client (see #53, contribution by Piotr Olaszewski)
  • [FEATURE] Add XML validation on the client side. Configurable but enabled per default
  • [FEATURE] Transport decorator which contains XML of the last request, response and exception (see #47, contribution by Piotr Olaszewski)
  • [BC] PSR-4 for autoloading (see #29)
  • [BC] Rename fXmlRpc\Multicall to fXmlRpc\MulticallBuilder
  • [BC] Make the surface of the ClientInterface signifcantly smaller (see #24 for details)
  • [BC] Replaces built-in transports with Ivory HTTP Adapter. PECL HTTP is no longer supported. Contribution by Márk Sági-Kazár
  • [BUG] Fix serialization issue with XmlWriterSerializer (see #19 for details)
  • [FEATURE] New bridge for artax (with contributions by Markus Staab)
  • [FEATURE] New bridge for Guzzle 4 (contribution by Robin van der Vleuten)
  • [FEATURE] Allow HTTP transport headers to be controlled
  • [FEATURE] Allow transport content type and charset to be controlled (see #9)
  • [BC] Removing outdated PeclHttpBridge
  • [BC] Requiring PHP 5.4
  • [BUG] Fixing huge issue in XmlWriterSerializer (see #4 for details)
  • [FEATURE] Special API for multicall
  • [FEATURE] Supports all Java XML/RPC extensions
  • [BC] fXmlRpc\AbstractDecorator and fXmlRpc\ClientInterface now includes methods to prepend and append parameters
  • [BC] fXmlRpc\Client is marked as final. Properties marked as private. Extend via decorator.
  • [BC] Marked deprecated constructor of fXmlRpc\Value\Base64 as private. Additionally, the value object is final now
  • [TESTING] Integration test suite against Java XML/RPC and Python XML/RPC
  • [BUG] Fixing implicit string type handling (where string is no child of value)
  • [IMPROVEMENT] Improved exception handling
  • [BC] Changing naming scheme to studly caps
  • [BUG] Fixing various array/struct edge cases
  • [IMPROVEMENT] Small memory and performance improvements for serializers and parsers
  • [BC] Deprecated constructor of fXmlRpc\Value\Base64 and introduced ::serialize() an ::deserialize() instead.
  • [FEATURE] Adding fXmlRpc\Client::prependParams() and fXmlRpc\Client::appendParams() to set default params. This helps e.g. when you need to add authorization information for every call
  • [FEATURE] Timing Loggers now support threshold based logging to ease controlling your servers responds in a certain time
  • [TESTING] Travis now runs the test suite against various versions of supported HTTP clients and logging components.

How fast is it really?

IO performance is out of reach from a userspace perspective, but parsing and serialization speed is what matters. How fast can we generate the XML payload from PHP data structures and how fast can we parse the servers response? fXmlRpc uses stream based XML writers/readers to achieve it’s performance and heavily optimizes (read uglifies) for it. As as result the userland version is only around 2x slower than the native C implementation (ext/xmlrpc).

Parser

Zend\XmlRpc\Value (ZF2): 249.02972793579 sec
Zend_XmlRpc_Value (ZF1): 253.88145494461 sec
fXmlRpc\Parser\XmlReaderParser: 36.274516105652 sec
fXmlRpc\Parser\NativeParser: 18.652323007584 sec

Serializer

Zend\XmlRpc\Request (ZF2): 52.004573106766 sec
Zend_XmlRpc_Request (ZF1): 65.042532920837 sec
fXmlRpc\Serializer\XmlWriterSerializer: 23.652673006058 sec
fXmlRpc\Serializer\NativeSerializer: 9.0790779590607 sec

Usage

Basic Usage

<?php
$client = new fXmlRpc\Client('http://endpoint.com');
$client->call('remoteMethod', array('arg1', true));

Using native (ext/xmlrpc based) serializer/parser (for even better performance)

<?php
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    null,
    new fXmlRpc\Parser\NativeParser(),
    new fXmlRpc\Serializer\NativeSerializer()
);
$client->call('remoteMethod', array('arg1', true));

Prepending and appending arguments

<?php
$client = new fXmlRpc\Client('http://endpoint.com');
$client->prependParams(array('username', 'password'));
$client->appendParams(array('appended'));
...

Using a convenient Proxy object

<?php
$proxy = new fXmlRpc\Proxy(new fXmlRpc\Client('http://endpoint.com'));
// Call system.echo
$proxy->system->echo('Hello World!');

Tracking XML of the request and response

<?php
$transport = new fXmlRpc\Transport\HttpAdapterTransport(...);
$recorder = new Recorder($transport);
$client = new Client('http://foo.com', $recorder);
$client->call('TestMethod', ['param1', 2, ['param3' => true]]);

$lastRequest = $recorder->getLastRequest();
$lastResponse = $recorder->getLastResponse();

If exception occur in the transport layer you can get it using getLastException().

Helpful abstraction for multicall requests

<?php
$result = $client->multicall()
    ->addCall('system.add', array(1, 2))
    ->addCall(
        'system.add',
        array(2, 3),
        function ($result) {
            echo "Result was: " . $result;
        },
        function($result) {
            echo "An error occured: " . var_export($result, true);
        }
    )
    ->onSuccess(function ($result) {echo "Success";}) // Success handler for each call
    ->onError(function ($result) {echo "Error";}) // Error handler for each call
    ->execute();

Integration for various HTTP clients using Ivory

<?php
/** Buzz (https://github.com/kriswallsmith/Buzz) */
$browser = new Buzz\Browser();
$browser->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\BuzzHttpAdapter($browser))
);

/** Zend Framework 1 (http://framework.zend.com/) */
$httpClient = new Zend_Http_Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\Zend1HttpAdapter($httpClient))
);

/** Zend Framework 2 (http://framework.zend.com/zf2) */
$httpClient = new Zend\Http\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\Zend2HttpAdapter($httpClient))
);

/** Guzzle (http://guzzlephp.org/) */
$httpClient = new Guzzle\Http\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\GuzzleAdapter($httpClient))
);

/** Guzzle 4+ (http://guzzlephp.org/) */
$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\GuzzleHttpHttpAdapter($httpClient))
);

Timing XML/RPC requests to find problematic calls

fXmlRpc allows you to time your XML/RPC request, to find out which took how long. It provides a fXmlRpc\Timing\TimingDecorator which can be used with various timers implementing fXmlRpc\Timing\TimerInterface. Currently implemented are bridges for Monolog, Zend Framework 1 Zend_Log and Zend Framework 2 Zend\Log.

Usage:

<?php
$client = new fXmlRpc\Timing\TimingDecorator(
    new fXmlRpc\Client(...),
    new fXmlRpc\Timing\MonologTimerBridge(
        $monolog,
        Monolog\Logger::ALERT,
        'My custom log message template %F'
    )
);

fxmlrpc's People

Contributors

busterneece avatar cryptocompress avatar frederikbosch avatar gitter-badger avatar lstrojny avatar magnusnordlander avatar mfadul24 avatar nyholm avatar peter279k avatar piotrooo avatar robinvdvleuten avatar sagikazarmark avatar sharptsa avatar soullivaneuh avatar vincentlanglet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fxmlrpc's Issues

Uncaught RuntimeException: Puli Factory is not available

I've ran into Fatal error: Uncaught RuntimeException: Puli Factory is not available in /localhost/vendor/php-http/discovery/src/ClassDiscovery.php:32 after installing your library via composer require lstrojny/fxmlrpc and trying to run the basic example:

require_once dirname(__FILE__) . '/vendor/autoload.php';

$client = new \fXmlRpc\Client('http://endpoint.com');
$client->call('remoteMethod', array('arg1', true));

It seems that PULI_FACTORY_CLASS is not available. Any ideas on how to fix this issue?

Syntax error in PHP 5.5, unexpected '[' in fXmlRpc\Client

We leverage this library in the Acquia SDK for PHP, and our automated tests are failing on PHP 5.5 with the error mentioned in the title of this issue. Tests pass using PHP 5.3 and 5.4. There are multiple builds where this is happening, but a specific build is at https://travis-ci.org/acquia/acquia-sdk-php/jobs/17426083.

If looks like the 0.9.0 release adopted a more terse method of initializing some properties as empty arrays that doesn't jive with 5.5. See

. Earlier releases used private $prependParams = array(); syntax which seems to work across the board.

Let me know if you need more details or addition info.
Chris

New tag

Would you be so kind to create a new release with the updated dependencies that are already in master? The last release was on 2021.
Thank you in advance.

Logging requests

What do you think about implement method like __getLastRequest and __getLastResponse - like in SoapClient - to fast returning raw XML. Now you couldn't look for these info.

What case?

$client = new Client($url);
$result = $client->call('Execute', [1, 2, 3]);
print_t($client->getLastRequest());

Installation

Hello,

I have manually downloaded it and played and looks very good in terms of speed and now I want to install it into my project. (vendor Folder)

I did not quite get how can I install it ? there is no composer installation for the project ?

Cannot install guzzle6 adapter

Hi,

I cannot install guzzle6 adapter as it reqires httplug in version 2 or up, while the httpplug for fxmlrp is set to be below verion 2:
"php-http/httplug": "~1"
Can we use httplug in latest verion?

6MB XML file

The benchmark folder includes a 6 MB XML file, is it really necessary to include this in the composer package?

Implement PSR-17/18 adapter for direct connection to Guzzle 7

Hello! The recent release of version 7 of the Guzzle HTTP adapter has introduced direct support from the library for the PSR-18 (HTTP Client) standard. The folks at HTTPlug have said that they don't have immediate plans for adding support for Guzzle 7, since in the long term, the goal is to have PSR-18-compatible libraries just consumed directly, without need for a bridge layer.

Along with this, it would be mighty handy if we could implement an adapter that supports a PSR-17 (Request factory) and a PSR-18 HTTP client, allowing the removal of a fair number of intermediate bridge libraries. Ideally, just fXmlRpc, the PSR-17 request factory, and the PSR-18-implementing library itself would be required (the former and/or the latter requiring the PSR interfaces themselves).

If there's no opposition, I plan to begin working on a pull request for this shortly.

Package details

Some package improvements I would do:

  • Add a .editorconfig file for making compatible IDEs follow conventions.

Sample content:

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[composer.json]
indent_style = space
indent_size = 4

[*.php]
indent_style = space
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2
  • Add a .scrutinizer.yml file, to customize tests and ignore tests/ directory.

Sample content:

filter:
  paths: [src/*]
tools:
  php_analyzer: true
  php_mess_detector: true
  php_pdepend: true
  external_code_coverage:
    timeout: '600'
  • Add code coverage upload in travis using ocular.

Sample content:

language: php

php:
  - 5.4
  - 5.5
  - 5.6
  - hhvm

before_script:
  - travis_retry composer self-update
  - travis_retry composer install --prefer-source --no-interaction
  - npm install

script: phpunit

after_script:
  - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
  - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi

(Of course it needs a phpunit configuration generating coverage)

If you like any of these, I am happy to open a PR.

Force Content-Type

Some XMLRPC endpoints require request's Content-Type set to "text/xml" or will return a 400 response code.

As this lib is aimed at sending and receiving XML entities, it should set content type regardless of transport used

(having this issue with Gandi API : http://doc.rpc.gandi.net/overview.html#client)

How to implement HTTP Authorization?

Using the arguments I can implement XML-RPC server based authentication by passing username/password arguments to the call. How can I implement HTTP-based authentication?

Since the transport is a private property of the client I cannot access it, howerver I only want take care of an injected ClientInterface. So the actual question: If I have a Client object, how can I make it send HTTP Authorization header?

PHP 8 support

Hi,

I saw that the requirement in composer.json is ~7.1.
Any plan to support php 8 ? What are the blockers ?

Thanks.

[Bug] Implementation of PSR 17 Factories breaks requests

The switch from message-factory in favour of psr factory #86 breaks the requests in the HttpAdapterTransport since headers and body are no longer correctly set.

public function send($endpoint, $payload)
    {
        try {
            $request = $this->messageFactory->createRequest(
                'POST',
                $endpoint,
                ['Content-Type' => 'text/xml; charset=UTF-8'],
                $payload
            );

The PSR 17 request factory doesn't take headers or body as arguments and they need to be set manually with methods on the request object.

<?php

namespace Psr\Http\Message;

interface RequestFactoryInterface
{
    /**
     * Create a new request.
     *
     * @param string $method The HTTP method associated with the request.
     * @param UriInterface|string $uri The URI associated with the request. If
     *     the value is a string, the factory MUST create a UriInterface
     *     instance based on it.
     *
     * @return RequestInterface
     */
    public function createRequest(string $method, $uri): RequestInterface;
}

I'll work on a PR on Monday.

final keyword on Client class?

Just curious as the reasoning behind this? I'm using __call() as a workaround for this for the time being, but it'd be easier to just extend the class and avoid the extra overhead.

Issue in XmlReaderParser.php when an empty "struct" is parsed

Hello all,

Start with Symfony log error:
[2013-09-30 11:30:17] request.CRITICAL: Uncaught PHP Exception fXmlRpc\Exception\RuntimeException: "Invalid XML. Expected one of "member", got "struct" on depth 7 (context: "")" at ...\vendor\lstrojny\fxmlrpc\src\fXmlRpc\Parser\XmlReaderParser.php line 81 {"exception":"[object](fXmlRpc\Exception\RuntimeException: Invalid XML. Expected one of "member", got "struct" on depth 7 %28context: ""%29 at ...\vendor\lstrojny\fxmlrpc\src\fXmlRpc\Parser\XmlReaderParser.php:81)"} []

And the response parsed
<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>a name</name>
<value><struct></struct></value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>

Parsing of XML requests

First I would like to say thanks for the awesome XMLReader implementation you've written. Is it possible that you also add the code to parse incoming XML requests?

<?xml version="1.0"?>
<methodCall>
    <methodName>method.to.call</methodName>
    <params>
        <param>
            <value><i4>41</i4></value>
        </param>
    </params>
</methodCall>

Update HTTP Adapter usage

Currently the HttpAdapterInterface is used as a dependency in HttpAdapterTransport.

We could probably rely on PsrHttpAdapterInterface (introduced in 0.8 development branch) which is a parent of HttpAdapterInterface. However in this case we would have to construct Request objects instead of calling $adapter->post. It adds complexity, but allows users to use a wider set of implementations.

Wrong example for Guzzle 4+

The example for Guzzle 4+ is not working, because you need to use \Ivory\HttpAdapter\GuzzleHttpHttpAdapter instead of \Ivory\HttpAdapter\GuzzleHttpAdapter

Replace Transports with a http adapter

I know it is a big change/BC break, but I see no real need for maintaining a http adapter inside this package. Here is a quite good HTTP adapter package, under heavy development, but stable enough to use. Geocoder 3 will be released using this under the hood.

What do you think?

array with one integer key not zero converted to array and not to struct

Hello,

I found something very interesting and I even don't know and not sure if it is a bug or this is how it supposed to work.

When having an array with one key that is integer but not 0 - zero ,
it converted to xml array with data-values,
instead of been struct with member node.

example:
array (
0 => 'something',
1 => '15632',
2 => 1395,
3 => '25/05/2021',
4 => array (
4035 => array (
0 => 3600,
1 => 3700,
2 => 4200,
),
),
)

see the 4035 key that in this case represent an id of something, and holds list values.

the output xml of this part is:
<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>update_plan_prices</methodName><params><param><value><string>something</string></value></param><param><value><string>15632</string></value></param><param><value><int>1395</int></value></param><param><value><string>25/05/2021</string></value></param><param><value><array><data><value><array><data><value><int>3600</int></value><value><int>3700</int></value><value><int>4200</int></value></data></array></value></data></array></value></param></params></methodCall>

instead of been converted to:
<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>update_plan_prices</methodName><params><param><value><string>something</string></value></param><param><value><string>15632</string></value></param><param><value><int>1395</int></value></param><param><value><string>25/05/2021</string></value></param><param><value>**<struct><member>**<name>4035</name><value><array><data><value><int>3600</int></value><value><int>3700</int></value><value><int>4200</int></value></data></array></value>**</member></struct>**</value></param></params></methodCall>

I assume it is happening in this part if I'm using XmlWriterSerializer
https://github.com/lstrojny/fxmlrpc/blob/master/src/fXmlRpc/Serializer/XmlWriterSerializer.php#L138

and also if use the NativeSerializer
https://github.com/lstrojny/fxmlrpc/blob/master/src/fXmlRpc/Serializer/NativeSerializer.php
with the build in function xmlrpc_encode_request
https://www.php.net/manual/en/function.xmlrpc-encode-request.php

Non-XML response returns null, no way to access response

I've just run into a situation where under certain circumstances the response coming back from an (alleged) XMLRPC server is not XML, but simply a string containing an error message. \fXmlRpc\Client::call currently just returns null from this request, but ideally it would throw an exception and have some way to get access to the string that came through in the response.

I understand that you might want to assume the URL being called will always return XML, though having some way to handle the cases when a URL is wrong might be handy. If you can suggest some other way to handle this, I'm open to ideas.

(It's a Magento store, in case you're interested, and the error occurs in certain versions where the URL for the XMLRPC interface has to be slightly tweaked)

Slow speed tests

Under "How fast is it really?" it says this is only 2x slower then xmlrpc but with my data I am seeing it being 12x slower.

Here is an issue I logged on the official Infusionsoft PHP API repository about this problem:
infusionsoft/infusionsoft-php#229

I highly recommend trying the NativeParser out if you want to improve speed and have access to install xmlrpc.

Confusing $isFault in Client

Why Client class has logic responsible for throwing exception when server return fault? It's little confusing for me, this is not responsibility of this class.

For me this exception should be thrown by parsers. And passing by reference could be removed.

For class NativeParser line could be changed for:

throw ResponseException::fault($result);

For class XmlReaderParser line could be set as internal variable and after all parsed document checked is fault was encountered and then throw exception.

Add ivory-http-adapter as composer dependency

Because you are know using the ivory-http-adapter as the default you should include this in your composer.json. Or you should have updated to a major version know i updated to the latest version and my installation is broken.

Unnecessary methods in ClientInterface?

I am working with your package for a long time now, so I have some experience with it. I created a few clients implementing ClientInterface and I hardly ever used methods other than call and multicall. The rest of methods seems to me an implementation detail, which might be useful in the default client, but makes implementing the interface harder. So I am suggesting a BC breaking and a non BC breaking solution to make things cleaner:

  1. Remove all other methods from the interface, optionally create a child interface or an abstract class. (BC breaking)
  2. Create a CallableInterface which includes these two methods, extend it in ClientInterface. (non BC breaking)

What do you think? (It also follows the single responsibility principle by splitting into a callable and a configurable interface)

Hard coded XML encoding on serializers and parsers

As you can set the HTTP charset on the transport, shouldn't you also be able to set XML encoding on the serializers/parsers?

It is hard coded to UTF-8 here:
NativeSerializer
XmlWriterSerializer
NativeParser
XmlReaderParser

I don't know if any XmlRpc server or client would break down if you mix HTTP charset and XML encoding, but better safe than sorry?

I suggest adding a setEncoding to ParserInterface and SerializerInterface.

Encoding could also be set according to the HTTP charset and defaulted to UTF-8 if no HTTP charset is available?

What do you think?

HTTP Transport decorator

Would be nice to have a decorator for HTTP transports, so that writting decorators is easier. Current use case: Authentication decorator, which sets some header in the constructor, otherwise it behaves like the underlying transport.

Can't parse XML the $xmlParser->parse($xmlString) return null on valid XML

Hi, I'm facing with a probem when some of the XML's can't be parsed by XmlReaderParser.
For examlpe this XML string is valid, bat XmlReaderParser return null:

This is my code:

$xmlParser = new \fXmlRpc\Parser\XmlReaderParser();;
$res = $xmlParser->parse($xmlString);

and this is a XML:

<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><array><data>
<value><string>expected string or buffer
2015-07-30 16:19:22:INFO: [�[1m�[91mThreadID: 1�[0m �[1m�[92m - ChannelWorker�[92m�[0m] https://www.googleapis.com/youtube/v3/channels?managedByMe=true&amp;onBehalfOfContentOwner=12345&amp;maxResults=50&amp;pageToken=CPa8AxAA&amp;part=snippet%2CcontentDetails%2CtopicDetails%2Cstatistics%2CcontentOwnerDetails&amp;key=1234�[0m
2015-07-30 16:19:22:INFO: [�[1m�[96mAccess key: 12321123 [0m]
</string></value>
<value><int>68231371</int></value>
<value><boolean>1</boolean></value>
</data></array></value>
</param>
</params>
</methodResponse>

What is the problem, or maybe I doing something wrong?

Specific Parameter causes call to hang with max processor usage

The following code will cause fxmlrpc to hang with max processor usage (using composer):

<?php
require '../vendor/autoload.php';

$client = new \fXmlRpc\Client("http://localhost/");
$result = $client->call('Reserve', [["_FCGI_" => "some value"]]);

Looking at the code, it seems to be the array/struct detection code (line 146-157 in XmlWariterSerializer). When $a = '_FCGI_', the ++$a will never change, causing an infinite loop. I'm currently working around this by using ext/xmlrpc which doesn't exhibit the issue.

I found this when running PHP 5.6.2, non-thread safe, 64 bit under IIS 7.5 & 8.5 with fastcgi, and it's the fastcgi $_SERVER keys that look like this. The issue happens when running from the PHP built-in web server as well.

Empty elements throw RuntimeException::unexpectedTag

Currently working with an API that is returning some values like

<member>
    <name>msg</name>
    <value></value>
</member>

and the parser is throwing the unexpectedTag exception. Surely this just wants to parse that element as an empty value rather then throwing an unexpected tag?

Full exception message is "Invalid XML. Expected one of "array", "#text", "string", "struct", "int", "biginteger", "i8", "i4", "i2", "i1", "boolean", "double", "float", "bigdecimal", "dateTime.iso8601", "dateTime", "base64", "nil", "dom", got "value" on depth 9 (context: "")"

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.