Giter VIP home page Giter VIP logo

soap-client's People

Contributors

ademarco avatar cjprinse avatar clxmstaab avatar dhedberg avatar driehle avatar edudobay avatar freezy-sk avatar garyjones avatar geoffreytran avatar hkandulla avatar icanhazstring avatar igorsantos07 avatar janvernieuwe avatar joshhornby avatar jurbar avatar kostajh avatar livda avatar lukastaferner avatar marek-pietrzak-tg avatar midnightdesign avatar ro0nl avatar samvdb avatar schlessera avatar simivar avatar simoheinonen avatar sippsolutions avatar staabm avatar tombevers avatar veewee avatar xthiago 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soap-client's Issues

Drop ext-soap

As it currently stands, the ext-soap extension is a huge source of bugs, so it should be isolated/squashed.

  • Parse WSDLs manually
  • Add custom type mapping based on parsed WSDL
  • Add custom method mapping based on parsed WSDL
  • Add custom object from/to xml conversion
  • Support the important soap options.
  • ... ?

Best practice for multiple WSDL files?

First, thanks for this amazing package and your hard work in putting it together!

Sorry if this is an obvious question, but I'm fairly new to the SOAP world. I am integrating with a service that has about 8 different WSDL files. What would be the best way to structure my client class?

From the usage doc it seems like you'd want to have multiple clients, one per WSDL file, and have a wrapper client class that can make use of any of them.

Order of generating Classes / Dependencies

Hi there
For realizing Type-Extension I need to extend a SOAP class from another (the generator doesn't seem to do it by itself). At the moment I'm working on expanding the Constructor- and the JsonSerializable Assemblers to handle extended classes. That seems to work quite well. I will commit it soon.
The problem that I have is that the ExtendAssembler can't extend from classes that are not built yet. This is understandable. So is it possible to determine the order of the classes to be generated? I can run the code generator twice but that is quite ugly. It would be great if someone could implement something like a priority list or dependency. Any ideas?

Regards
Thomas

Add return to generate:classmaps

Currently the generate:classmap command produces:

<?php

use Phpro\SoapClient\Soap\ClassMap\ClassMapCollection;
use Phpro\SoapClient\Soap\ClassMap\ClassMap;

new ClassMapCollection([
...
]);

If this is intended to be dropped into a standalone file (evidenced by the opening delimiter and use statements, and then used with the ClientBuilder withClassmaps(), then it would be handier to include the return in it too:

<?php

use Phpro\SoapClient\Soap\ClassMap\ClassMapCollection;
use Phpro\SoapClient\Soap\ClassMap\ClassMap;

return new ClassMapCollection([
...
]);

Create generate:types destination if it doesn't exist

If one runs soap-client generate-types --config=..., but the setDestination key in the config doesn't exist, it will generate misleading information:

PHP Warning:  file_put_contents(src/SoapTypes/GetContracts.php): failed to open stream: No such file or directory in /path/to/vendor/phpro/soap-client/src/Phpro/SoapClient/Util/Filesystem.php on line 55

Warning: file_put_contents(src/SoapTypes/GetContracts.php): failed to open stream: No such file or directory in /path/to/phpro/soap-client/src/Phpro/SoapClient/Util/Filesystem.php on line 55
Generated class GAA\CorpManagerApi\SoapTypes\GetContracts to src/SoapTypes/GetContracts.php

{repeat for each class}

That's two warnings, and then an incorrect success message, per class, since the file is never saved.

Once the destination folder (empty) is manually created, then the files are generated as intended.

Could the generate:type command at least try and create the destination directory if it doesn't exist, or give a more helpful warning and die immediately, if it can't?

Dependencies are too restrictives

Hi,

Dependencies of the library are too restrictive.

For instance you restrict symfony/filesystem to version ~2.3. If someone already uses <2.3 or >2.3 (special mention for >=3.0) in it's project, it's not possible to use the soap client (it's my case).

Symfony versioning is smart enough and I recommend you to provide a wider version range for deps.

Better error messages for converters

When for example a DateTimeConverter gets a null value, you get a very vague soap exception:

SoapFault: SOAP-ERROR: Encoding: Error calling to_xml callback

It's probably a good idea to check if the type can be converted, and throw a clearer exception then the default soap error.

This is probably the case for all converters.

Implement ImmutableSetterAssembler

If your SOAP requests has a lot of optional parameters, it might be handy to skip the constructor and use immutable setters instead. The idea is to create an immutable setter assembler which generates PSR-7 like immutable with*() methods. (More info: http://www.php-fig.org/psr/psr-7/)

Example of generated code:

class MyRequest implements RequestInterface
{
    /**
     * @var string
     */
    private $someFilter;

    /**
     * @param string $someFilter
     * @return MyRequest
     */
    public function withSomeFilter(string $someFilter): MyRequest
    {
        $new = clone $this;
        $new->someFilter = $someFilter;

        return $new;
    }
}

Usage:

$request = (new MyRequest)->withSomeFilter('myfilter');

Support return types

A generated method like:

    /**
     * @return string
     */
    public function getNewUsername()
    {
        return $this->NewUsername;
    }

could have a return type, if a config flag was set, so that it generated it as:

   /**
     * @return string
     */
    public function getNewUsername(): string
    {
        return $this->NewUsername;
    }

Response type

How can I solve this problem "Argument 3 passed to Phpro\SoapClient\Event\ResponseEvent::__construct() must implement interface Phpro\SoapClient\Type\ResultInterface, instance of stdClass given" ?

Filter logged params?

I pass an instance of Monolog to $clientBuilder->withLogging(), and the Logging plugin all works fine.

However, the API I'm using requires username and password as two of the standard params, and without them, the API doesn't respond. This results in log entries like (formatted for readability):

[2017-12-12 15:47:16] [SiteReference] General.INFO: [phpro/soap-client] request: call "DemoSetup" with params My\PackageName\SoapTypes\DemoSetup Object (
    [adminUsername:protected] => myUsername
    [adminPassword:protected] => myPassword
    [firstName:protected] => Gary
    [lastName:protected] => Jones
    [email:protected] => [email protected]
    [clientIp:protected] => 123.123.123.321
)  [] []

The issue here is that the API's password (and username) are now recorded in the log files.

Is there a way to filter the params when the request logging is done so that we can remove, or change the password value to (redacted)?

CodeGenerator - date changed to dateTime within a class name

In generated classes I can see:

    /**
     * @var ArrayOfConsoli\DateTimedAgreement
     */
    private $ConsolidatedFrom = null;

instead of:

    /**
     * @var ArrayOfConsolidatedAgreement
     */
    private $ConsolidatedFrom = null;

It looks like all doc block where date word is found are wrong with \DateTime replacing date in the original text.

Use documentation from .wsdl in generated code?

The code generated by soap-client tends to just add a DocBlock with the @var or @return type. I'd love to be able to get Summary and Description added in for methods and properties.

  • How might this information be added in to the WSDL?
  • How might soap-client be able to read that and make use of it?

Patching does not add new elements

When adding a new element to a WSDL node and then run the generate:types command again it does not get added as a class attribute via an <xsd:import schemaLocation ..../> file.
WSDL was:

....
<xs:complexType name="Field">
    <xs:sequence>
        <xs:element minOccurs="0" name="Description" nillable="true" type="xs:string"/>
        <xs:element minOccurs="0" name="FieldType" nillable="true" type="xs:string"/>
    </xs:sequence>
</xs:complexType>
....

....
<xs:complexType name="Field">
    <xs:sequence>
        <xs:element minOccurs="0" name="Description" nillable="true" type="xs:string"/>
        <xs:element minOccurs="0" name="FieldType" nillable="true" type="xs:string"/>
        <xs:element minOccurs="0" name="SortOrder" type="xs:int"/>
    </xs:sequence>
</xs:complexType>
....

It does create a backup file and state that it is patching like so:

Type Field exists. Trying to patch ...Patched!

The file and the backup are identical without the new element in the class.

class Field
{

   /**
    * @var string
    */
   protected $Description;

   /**
    * @var string
    */
   protected $FieldType;

}

Add a WSDL handler mechanism

This ticket is a split-up of #21: Add an extension mechanism
It should be possible to have more control over the WSDL downloads:

  • Download a WSDL and Alter it locally . This is needed for following reasons:
  • Add a caching mechanism for the altered WSDLs so that they don't have to download / alter on every time the soapclient is being used. This should be a configurable setting.

This should be implemented in a non-required way: The user can choose to use this feature or just use the built-in SoapClient functionalities.

Make it possible to configure the visibility in the PropertyAssembler

Currently the PropertyAssembler generates protected properties by default.
Since we mostly don't extend these types, it is a better idea to change the default to private.

    /**
     * @var string
     */
    protected $someFilter;

This could be done by adding the visibility as a constructor parameter to the PropertyAssembler and changing the defaults in the Configuration file. This way you can still choose to use protected or even public if you're a real daredevil.

Enummerations, SimpleTypes and Arrays in Entity generation

hi, i played a bit around with the library and noticed that some elements of the wsdl i tested werent recognized in the entity generation:

  1. simpleTypes are ignored
    <xs:simpleType name="ExampleState">

  2. enumerations are ignored

<xs:enumeration value="Cancelled">
  <xs:annotation>
    <xs:appinfo>
      <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">4</EnumerationValue>
    </xs:appinfo>
  </xs:annotation>
</xs:enumeration>
  1. array elements are not converted to arrays
    minOccurs & maxOccurs could maybe detect arrays.
<xs:complexType name="PriceArray">
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="Price" nillable="true" type="tns:Price"/>
  </xs:sequence>
</xs:complexType>

Maybe i did some misconfiguration or you have some idea to circumvent this?

Add SwA / MTOM attachements middleware

Make it possible to send / receive attachements in the soap-client.

  • SwA: SOAP Messages with Attachments Spec
  • MTOM: SOAP Message Transmission Optimization Mechanism Spec

A sample Jave implementation:

Sample PHP implementations:

Type hints for setter assemblers

At the moment the setters have no type hints:

    /**
     * @param CardOrder $OrderInformation
     */
    public function setOrderInformation($OrderInformation)
    {
        $this->OrderInformation = $OrderInformation;
    }

It would be nice to enforce the types in the setters like so.

    /**
     * @param CardOrder $OrderInformation
     */
    public function setOrderInformation(CardOrder $OrderInformation)
    {
        $this->OrderInformation = $OrderInformation;
    }

GuzzleWsdlProvider fills up tmp with cache files and keeps downloading WSDL file

Unless I'm missing something major, there seem to be a few issues in the guzzle provider

A random file is ALWAYS generated if getLocation() does not return anything, it causes the system tmp directory to be filled up with files such as /tmp/phpro-soap-client-wsdluP5u2I but also with WSDL cache files, (if cache_wsdl is on) because the cache is based on that file.

I'm not sure what the point of setting a location is, you'd have to create an empty file in advance or it will throw a WsdlException, after that it will keep rewriting that file every time a SoapClient is built.

A GET request is always done to retrieve the WSDL, there is nothing that prevents this. Ideally it should return a path to the cached WSDL file, but this would keep it cached forever due to lack of cache invalidation.

I currently don't see a fix other than building in a cache manager to handle cache correctly, ideally one implementing PSR-6 or PSR-16. A unique cache key could be generated from $source. This would make the cache_wsdl option rather useless though, you'd have 2 caching layers.

Assembler overload problemm

By default, when you create a configuration, you install two of the assembler.

public function __construct($wsdl = '', $destination = '')
    {
        $this->setWsdl($wsdl);
        $this->setDestination($destination);
        $this->ruleSet = new RuleSet([
            new Rules\AssembleRule(new Assembler\PropertyAssembler()),
            new Rules\AssembleRule(new Assembler\ClassMapAssembler()),
        ]);
    }

The problem is with PropertyAssembler:

  1. the documentation indicated that he as a constructor can make the type field visibility, but there is no constructor :)

  2. I wrote my own assembler and tried to install it

->addRule(new Rules\AssembleRule(new wnPropertyAssembler(PropertyGenerator::VISIBILITY_PUBLIC)))

but since you already have a default assembler uses it. I studied the source code of configuration class and solved the problem as follows

->setRuleSet(
        new Rules\RuleSet([
            new Rules\AssembleRule(new OwnPropertyAssembler(PropertyGenerator::VISIBILITY_PUBLIC)),
            new Rules\AssembleRule(new ClassMapAssembler())
        ])
    )

Please Add this information in documentation :)

OBJECT REQUEST

Hi, I have this wsdl:
https://vendor-ctrip.fws.ctripqa.com/Hotel/OTAReceive/OTAReceiveService.asmx?wsdl based in OTA standard.

I make my generate classes:

Array
(
    [0] => Igm\Synergy\Models\OTA\OTAHotelRatePlanRQ Object
        (
            [timeStamp:Igm\Synergy\Models\OTA\OTAHotelRatePlanRQ:private] => 
            [version:Igm\Synergy\Models\OTA\OTAHotelRatePlanRQ:private] => 0
            [primaryLangID:Igm\Synergy\Models\OTA\OTAHotelRatePlanRQ:private] => 
            [pOS:Igm\Synergy\Models\OTA\OTAHotelRatePlanRQ:private] => Igm\Synergy\Models\OTA\POSType Object
                (
                    [source:Igm\Synergy\Models\OTA\POSType:private] => Igm\Synergy\Models\OTA\SourceType Object
                        (
                            [requestorID:Igm\Synergy\Models\OTA\SourceType:private] => Igm\Synergy\Models\OTA\SourceType\RequestorIDAType Object
                                (
                                    [messagePassword:Igm\Synergy\Models\OTA\SourceType\RequestorIDAType:private] => IGM123
                                    [companyName:Igm\Synergy\Models\OTA\SourceType\RequestorIDAType:private] => Igm\Synergy\Models\OTA\CompanyNameType Object
                                        (
                                            [code:Igm\Synergy\Models\OTA\CompanyNameType:private] => C
                                            [codeContext:Igm\Synergy\Models\OTA\CompanyNameType:private] => 556
                                        )

                                    [iD:Igm\Synergy\Models\OTA\UniqueIDType:private] => IGM
                                    [type:Igm\Synergy\Models\OTA\UniqueIDType:private] => 1
                                )
                        )
                )
)

But when I create arguments and request. Generate this xml with errors:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
   <SOAP-ENV:Body>
      <ns1:OTA_HotelRatePlanRQ />
      <param1>0</param1>
      <param2 />
      <param3>
         <source>
            <requestorID>
               <messagePassword>IGM123</messagePassword>
               <companyName>
                  <code>C</code>
                  <codeContext>556</codeContext>
               </companyName>
               <iD>IGM</iD>
               <type>1</type>
            </requestorID>
         </source>
      </param3>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Any suggestions for that?

Request object different than the xml (soap)

Hi guys.
I've an object (this is an excerpt)

[items:\RQtype:private] => Array
    (
        [0] => \Items Object
            (
                [itemtype:\Items:private] => TEST
                [itemcode:\Items:private] => TS
                [type:\Items:private] => Type Object
                    (
                        [typecode:\type:private] => A
                        [number:\type:private] => 2
                    )
                [foo:\Items:private] => Foo Object
                    (
                        [index:\Foo:private] => 1
                    )
            )
    )

and after the clientBuilder receives it, the xml produced is

<ns1:items xsi:type="ns1:items">
    <ns1:itemtype>TEST</ns1:itemtype>
    <ns1:itemcode>TS</ns1:itemcode>
    <ns1:type>
        <ns1:typecode>A</ns1:typecode>
        <ns1:number>2</ns1:number>
    </ns1:type>
</ns1:items>

As you can see Foo is missing.
I double checked the entities and they seem OK and I'm running out of ideas.
Does it ring any bells?
Thanks!
A.

[Code Generator] weird behaviour for property named `PaymentTransactionID`

I ran code generator on Friday and can see one weird use case. This is the code generated:

   /**
     * @var string
     */
    private $PaymentTransactionID = null;

    /**
     * @return string
     */
    public function getPaymentTransactionIentifier()
    {
        return $this->PaymentTransactionIentifier;
    }

    /**
     * @param string $PaymentTransactionIentifier
     * @return $this
     */
    public function setPaymentTransactionIentifier($PaymentTransactionIentifier)
    {
        $this->PaymentTransactionIentifier = $PaymentTransactionIentifier;
        return $this;
    }

Property PaymentTransactionID has been replaced with PaymentTransactionIentifier

Convert decimal type to float?

The XML schemas supports a numeric data type of decimal. Right now, the WDSL I'm parsing has:

<s:element minOccurs="1" maxOccurs="1" name="Fee" nillable="true" type="s:decimal" />

Which results in a generated class property of:

   /**
     * @var decimal
     */
    protected $Fee = null;

and a corresponding getter:

    /**
     * @return decimal
     */
    public function getFee()
    {
        return $this->Fee;
    }

Could this be automatically converted to a float by this package, or otherwise handled in a nicer manner?

`SoapXml::fromStream()` returns wrong object

The named constructor SoapXml::fromStream() does not return a Phpro\SoapClient\Xml\SoapXml object, but rather a Phpro\SoapClient\Xml\Xml object.

This makes it impossible to call any of the extended methods that the SoapXml class provides.

As an example, on the object you receive, you can't call a method like getHeaders().

The problem is caused here:

return new self($xml);

This line should use late static binding to actually create an instance of the subclass that was requesting it, not the base Xml class:

return new static($xml);

Support strict types declare in generate:types

Like the Config::create() can fluently setNamespace(...), it would be nice to be able to optionally state that each of the generated classes also had declare(strict_types=1); at the top of the files too.

Remove duplicated "overwrite or patch" logic in console commands

Currently the logic for overwriting or patching a file is duplicated in the console commands.
Suggested solution:

  • Add CLI option 'filemode' with options ['patch', 'override']. Make sure to mark 'patch' as default.
  • Remove old option --overwrite or make it force pathmode=override
  • Remove all interactive questions.
  • Drop backup logic. We all use version control, so there is no need to create .backup files
  • Make sure the code generation invocation is placed inside one private method inside the command
  • Optionally: make it possible to configure the filemode inside the CodeGeneration config file.
  • Make sure the generators work in a consistent way (code should be generated by assemblers so that all code generation is customizable)
  • Add documentation
  • Profit!

Issues with PHP-VCR

I'm working on integrating php-vcr with my project, but running into difficulties. This is the message I get:

You can only add handlers if the SoapClientFactory is returning an instance of Phpro\SoapClient\Soap\SoapClient. Got: VCR\Util\SoapClient
 /Users/kostajh/src/example/drupal/sites/all/vendor/phpro/soap-client/src/Phpro/SoapClient/ClientBuilder.php:199
 /Users/kostajh/src/example/drupal/sites/all/modules/custom/example_integration/src/Api/Client/IntegrationClient.php:180
 /Users/kostajh/src/example/drupal/sites/all/modules/custom/example_integration/src/Api/Client/IntegrationClient.php:87
 /Users/kostajh/src/example/drupal/sites/all/modules/custom/example_integration/tests/src/IntegrationTestBase.php:51
 /Users/kostajh/src/example/drupal/sites/all/modules/custom/example_integration/tests/src/Integration/CodeUnitGuestInfoTest.php:22

I'm using PHPUnit 6 with the latest 3.0.0 release of php-vcr-listeners project. Line 180 of IntegrationClient.php is calling $clientBuilder->build() on a client object I've built up.

Any ideas?

New subscriber (e.g. logger) added for each client built by ClientBuilder

The problem: Same log message is logged multiple times.

Situation: We are using several services with different WSDLs. For each service we created a seperate client.

As far as I understand the example on the "Basic Usage" page, for the instantiation of a specific client a ClientFactory is needed, which in turn is fed into the ClientBuilder. So for each our clients we have

$clientFactory = new ClientFactory(YourClient::class);
$clientBuilder = new ClientBuilder($clientFactory, $wsdl, $soapOptions);
$clientBuilder->withLogger($container->get('logger') /* always the same logger-instance */);
// ...
$client = $clientBuilder->build();

Unfortunately, the log messages from each client is logged multiple times (number of clients).

When I look into https://github.com/phpro/soap-client/blob/v0.5.3/src/Phpro/SoapClient/ClientBuilder.php#L221 , a new instance of a LogPlugin (Subscriber) is added.

Am I using the library the wrong way or might this be a bug? As a workaround for now I specify withLogger() only for the first client.

Client Generator

I used this (very quick and dirty code) to initially generate client functions, perhaps this could be an inspiration to create a client-generator.

$dom = new DOMDocument();
$dom->load('/tmp/giftcard_4_6.asmx.xml');
$types = $dom->getElementsByTagName('portType');
$types = $types->item(0);
/** @var DOMElement $type */
foreach ($types->childNodes as $type) {
    if (!$type instanceof DOMElement) {
        continue;
    }
    $name = $type->getAttribute('name');
    $docs = $type->getElementsByTagName('documentation')->item(0)->textContent;
    printf(
        '    /**
     * %s
     *
     * @param Type\%s $%s
     * @return ResultInterface|Type\%sResponse
     */
    public function %s(Type\%s $%s)
    {
        return $this->call(\'%s\', $%s);
    }'.PHP_EOL.PHP_EOL,
        $docs,
        $name,
        lcfirst($name),
        $name,
        lcfirst($name),
        $name,
        lcfirst($name),
        $name,
        lcfirst($name)
    );
}

Generated getResult() method is incompatible with ResultProviderInterface parent method due to missing return type declaration

The ResultProviderAssembler generates classes with a getResult() method.

Here's a part of my WSDL:

<s:element name="CalcRatesResponse">
    <s:complexType>
        <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="CalcRatesResult" type="tns:CalcRatesResult" />
        </s:sequence>
    </s:complexType>
</s:element>

Here's the relevant rule in my config file:

    ->addRule(new Rules\TypenameMatchesRule(
        new Rules\AssembleRule(new ResultProviderAssembler()),
        '/Response$/'
     ))

Here's one of my generated classes:

<?php

namespace GAA\CorpManagerApi\SoapTypes;

use Phpro\SoapClient\Type\ResultProviderInterface;
use Phpro\SoapClient\Type\ResultInterface;

class CalcRatesResponse implements ResultProviderInterface
{

    /**
     * @var CalcRatesResult
     */
    private $CalcRatesResult;

    /**
     * @return CalcRatesResult|ResultInterface
     */
    public function getResult()
    {
        return $this->CalcRatesResult;
    }
}

However, the getResult() method in the ResultProviderInterface has a return type declaration (added via #80), which means the generated method is an incompatible signature, causing a fatal error.

    /**
     * @return ResultInterface
     */
    public function getResult(): ResultInterface;

The method generation code doesn't appear to have anything suggesting that a return type declaration should be included.

Zend-code does have the support of adding a returntype when generating the method from an array.

Array complex type

Hi!
First, congrats for the package, really well written!

I have the following complex type on my wsdl file:

<xsd:complexType name="userIdsArray">
  <xsd:complexContent>
   <xsd:restriction base="SOAP-ENC:Array">
    <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:integer[]"/>
   </xsd:restriction>
  </xsd:complexContent>
 </xsd:complexType>

How I can load it without getting this error:

PHP Catchable fatal error:  Argument 3 passed to Phpro\SoapClient\Event\ResponseEvent::__construct() must be an instance of Phpro\SoapClient\Type\ResultInterface, array given, called in /vendor/phpro/soap-client/src/Phpro/SoapClient/Client.php on line 100 and defined in /vendor/phpro/soap-client/src/Phpro/SoapClient/Event/ResponseEvent.php on line 35

Drop property default value if it is null

A property created with generate:types can be like:

    /**
     * @var string
     */
    protected $NewUsername = null;

The = null bit is completely redundant and could be removed if the default value is === null.

CodeGenerator can't generate types if parent directory contains underscores

Introduced in #71

I have just tried to create types for the configuration stored in /config/code_generator folder.
It failed with:

  [Phpro\SoapClient\Exception\RuntimeException]
  /mnt/c/Apache24/htdocs/xxx/config/code/generator/../../src/Types/Payment does not exist and could not be created.


Exception trace:
 () at /mnt/c/Apache24/htdocs/xxx/vendor/phpro/soap-client/src/Phpro/SoapClient/Util/Filesystem.php:29
 Phpro\SoapClient\Util\Filesystem->ensureDirectoryExists() at /mnt/c/Apache24/htdocs/xxx/vendor/phpro/soap-client/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php:120
 Phpro\SoapClient\Console\Command\GenerateTypesCommand->handleType() at /mnt/c/Apache24/htdocs/xxx/vendor/phpro/soap-client/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php:96
 Phpro\SoapClient\Console\Command\GenerateTypesCommand->execute() at /mnt/c/Apache24/htdocs/xxx/vendor/symfony/console/Command/Command.php:264
 Symfony\Component\Console\Command\Command->run() at /mnt/c/Apache24/htdocs/xxx/vendor/symfony/console/Application.php:888
 Symfony\Component\Console\Application->doRunCommand() at /mnt/c/Apache24/htdocs/xxx/vendor/symfony/console/Application.php:224
 Symfony\Component\Console\Application->doRun() at /mnt/c/Apache24/htdocs/xxx/vendor/symfony/console/Application.php:125
 Symfony\Component\Console\Application->run() at /mnt/c/Apache24/htdocs/xxx/vendor/phpro/soap-client/bin/soap-client:26

generate:types [--config CONFIG] [-o|--overwrite]

The config file I used for configuration started with

return Config::create()
    ->setWsdl(__DIR__ . '/../wsdl/PaymentService.wsdl')
    ->setDestination(__DIR__ . '/../../src/Types/Payment')

As you can see all underscores from my __DIR__ have been replaced with /. In this case code_generator was replaced by /code/generator.

Use the http-interop layer instead of Guzzle.

This is a follow-up ticket for #23:

Currently we are using Guzzle as a hardcoded handler in this project.
This is because the http-interop doesn't have a standard on:

  • What interfaces a http-client should have. (http-client)
  • How a request / response should be created (http-factory)
  • What client middlewares should look like (http-middleware)
  • How async callbacks should work (async-interop/promise)

When all the groups above come to a deciscion, it is possible to make this package independent of the http-client you want to use. For now we'll only support the Guzzle implementations.

Actions:

Empty namespace inside xml request

I need to add this code inside 'Phpro\SoapClient\Soap\SoapClient.php' to remove empty namesapaces like xmlns:ns1=""

public function __doRequest($request, $location, $action, $version, $oneWay = 0)
    {
        //my code - begin
        if (preg_match('/xmlns:ns1=""/', $request)) {
            $request = preg_replace('/xmlns:ns1=""/', '', $request, 1);
            $request = preg_replace('/ns1:/', '', $request);
        }
        //my code - end
      $request = new SoapRequest($request, $location, $action, $version, $oneWay);
      $response = $this->handler->request($request);
      ...

Is it possible to make this in a proper way? Via configuration for example. I don't want to change the original code.

Thanks!

Add a middleware mechanism

Since there are many custom Soap implementations to implement e.g. authentication, we need a way of extending the current SoapClient. This way, we can easily configure additional extensions to the current SoapClient. For example:

$clientBuilder = new ClientBuilder($clientFactory, $wsdl, $soapOptions);
$clientBuilder->addMiddleware(new NtlmMiddleware());
$clientBuilder->addMiddleware(new WsseMiddleware());
$clientBuilder->addMiddleware(new WsaMiddleware));
// ....

(This could also be added to the SoapClientFactory instead)

In the SoapClient class, we'll need to add a handler system around the __doRequest() method.
This way, it is possible to add multiple extensions which can manipulate the raw XML and return a raw XML response. All extensions need to be fully tested.

A list of possible extensions:

Note that the extensions should also be able to:

  • #22: Add a WSDL handler mechanism
  • Hook in to the "options" part of the SoapClient (for example for the basic auth and WSP certificates)

The features described above may be implemented in multiple PRs. This ticket is just an overview of how the extension part should work.

Can't override default type converters

Hi,
My problem is that I can not override the default type converters (datetime, date etc.) with a custom one because ClientBuilder::addTypeConverter() checking first that a converter already exists, and the default converters already added during ClientBuilder __constuct().

Solution: I think adding the default type converters on the build() method would solve this issue.

PHP 5.6

It's posible run de generate classes with PHP 5.6?

Strict types

Currently the codebase is a mix of strictly typed and mixed typed functions.
This is because we started working on this package for PHP 5.6.
Since we've bumped the version to >7, we can now use strict types everywhere.
The code in this package should be actively pushed to strict types.

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.