Git Product home page Git Product logo

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

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.

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>

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());

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: "")"

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.

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)

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)

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)

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

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.

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>

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.

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.

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.

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

6MB XML file

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

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?

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.

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.

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?

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?

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.

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?

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?

[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.

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 ?

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

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?

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.

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.