GithubHelp home page GithubHelp logo

codedredd / laravel-soap Goto Github PK

View Code? Open in Web Editor NEW
201.0 5.0 40.0 1.96 MB

Laravel Soap Client

Home Page: https://codedredd.github.io/laravel-soap/

License: MIT License

PHP 100.00%
laravel soap soap-client php php7 php8

laravel-soap's People

Contributors

bastien-phi avatar bernhardk91 avatar bretto36 avatar chiiya avatar codedredd avatar dependabot-preview[bot] avatar dependabot[bot] avatar elrochito avatar github-actions[bot] avatar jaspur avatar laravel-shift avatar ohnotnow avatar peter279k avatar vardanmovsisyan 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

laravel-soap's Issues

Can't configure basic auth via config

When building a client via config (Soap::buildClient('frontend')) with the with_basic_auth option configured, the SoapClient::withBasicAuth() method throws the following error:

Argument 1 passed to CodeDredd\\Soap\\SoapClient::withBasicAuth() must be of the type string, array given

Example config:

'clients' => [
    'frontend' => [
        'base_wsdl' => 'https://example.org//soap?wsdl',
        'with_basic_auth' => [
            'username' => 'xyz',
            'password' => 'xyz',
        ],
    ],
],

This is due to the way array config options are handled by the SoapClient::byConfig() method:

} elseif (is_array($setupItemConfig)) {
    $this->{Str::camel($setupItem)}($this->arrayKeysToCamel($setupItemConfig));
}

That will call SoapClient::withBasicAuth() with an array as the only parameter (['username' => 'xyz', 'password' => 'xyz']), whereas the method signature expects two string parameters (string $username, string $password).

The SoapClient::withBasicAuth() method should probably be adapted to accept an array configuration as well, similar to how Laravel itself handles some of its methods (by checking if the first parameter is an array or a string). I can create a pull request if you're happy with that solution.

Transfer-Encoding : Chunked Issue

Hi CodeDredd;

I can get data from most of them. Only one function is returning a pdf file as byte format. When i try to read the response, i only got a blank data. When i use The SoapUI, it returns me back the pdf file. But in PHP it's not working somehow.

For example, this code returns data without problem.

public function getSupplyCarryTypes(Request $request)
{
    $response = Soap::baseWsdl('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl')
        ->withBasicAuth('999999', '999999testtest')
        ->withOptions([
            'trace' => false,
            'encoding' => 'UTF-8',
            'cache_wsdl' => WSDL_CACHE_NONE,
        ])
        ->call('paramTehlikeliMaddeTasimaSekli',array(
            'wsuser' => array('kullaniciAdi' => '999999', 'sifre' => '999999testtest')));

    dd($response['return']['tehlikeliMaddeTasimaSekliListesi']);
}

But when i try this one, it returns null. It normally returns a PDF file as bytes. At least it's working well in SoapUI.After cheking the raw codes in SoapUI, i saw that the only difference is "Transfer Encoding : chunked".

public function getVoyageReport() // Not Working
{
    $response = Soap::baseWsdl('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl')
        ->withBasicAuth('999999', '999999testtest')
        ->withOptions([
            'trace' => false,
            'encoding' => 'UTF-8',
            'cache_wsdl' => WSDL_CACHE_NONE,
        ])
        ->call('seferRaporuV3', array(
            'wsuser' => array('kullaniciAdi' => '999999', 'sifre' => '999999testtest'),
            'seferId' => '21042300246027'));

    return $response->body();
}

Am i missing something? I would be really happy, if you take a look...
Thanks...

PKC12 digital signature base64 SHA1withRSA

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Are you able to assist bring the feature to reality?
no | yes, I can...

Additional context
Add any other context or screenshots about the feature request here.

ConnectionFailed::__construct(): Argument #1 ($request) must be of type CodeDredd\Soap\Client\Request,

Good evening
Can you please help me with an error that I get when using the library, I don't know if I'm making a mistake in the configuration of this

i am getting this error

imagen

This is my base configuration

 $soap = Soap::baseWsdl('https://miportafoliouat.transunion.co/ws/UbicaPlusWebService/services/UbicaPlus')
            ->withOptions(['cache_wsdl' => WSDL_CACHE_NONE,
                'trace' => 1,
                'stream_context' => stream_context_create([
                    'ssl' => [
                        'verify_peer' => false,
                        'verify_peer_name' => false,
                        'allow_self_signed' => false
                    ],
                    'http' => [
                        'header' => 'Authorization: Basic ' . base64_encode('xxx' . ':' . 'xxx')
                    ]])
            ])->withWsse([
                'userTokenName' => '331487',
                'userTokenPassword' => '2op.bPgtinma',
                'privateKeyFile' => Storage::disk('local')->path('cifin-private.key'),
                'publicKeyFile' => Storage::disk('local')->path('cifin-public.key'),
                'serverCertificateFile' => Storage::disk('local')->path('cifin-public.key'),
                'serverCertificateHasSubjectKeyIdentifier' => true,
                'userTokenDigest' => true,
                'digitalSignMethod' => XMLSecurityKey::RSA_SHA256,
                'timestamp' => 10000,
                'signAllHeaders' => true,


            ]);

I would really appreciate if you help me to solve this problem

Body being wrapped in an array when using a generated class

Hi there,

I'm using a class generated from WSDL as demonstrated in the documentation. When using this class, the provided $body seems to be wrapped in another array by line 355 of SoapClient.php

This is leading to the request not being formed properly.

However, if I don't use this class and instead use the BaseWsdl method and call, the same body isn't wrapped in this array.

I can't understand why the behaviour is different and I'd like to know if I'm doing something wrong.

Below is the two different ways I'm calling the methods. The latter doesn't work and produce the wrapped array, the former works correctly and returns a correct response.

$response = Soap::baseWsdl('x')->call('ConfirmCredentials', $security->toArray());

$client->ConfirmCredentials($security->toArray());

Upgrade of phpro/soap-client available

Just wanted to inform you about recent changes in phpro/soap-client:v2.0.0:

https://github.com/phpro/soap-client/blob/master/UPGRADING.md

It contains some better SOAP related defaults and less opt-in suggested packages in composer.
This is partially done by moving things like WSE to a separate package.

We moved all low-level SOAP things to a separate organization:
https://github.com/php-soap

I noticed this package contains some copied classes.
Not sure what the reason behind that is, but it might make sense to improve the packages inside the new php-soap organisation.

Let me know if I can be of any assistance ;)

Authentication Problem

Good greetings I am new and using your library I have a problem when using authentication, I would like to know what middleware uses for authentication on the routes since I use the default auth does not authenticate.

So I use the authentication.
$response = Soap::baseWsdl("$this->serverUrl/$this->serverScript?wsdl") ->withBasicAuth('test','123') ->LoguearUsuario($data);

middleware on the route.
Route::get('user', function () { return "hello user"; })->middleware('auth');

SoapClient::$request must not be accessed before initialization

Hi I have a problem call a method, but I don't have idea how to do it that:

The error is:

Typed property CodeDredd\\Soap\\SoapClient::$request must not be accessed before initialization

I try to create this petition WITHOUT SSL Certification: https://xxxxxxxx/xxx/xxx/xxx?wsdl

<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:ser="http://service.cows.gnconsult.com/">
	<soapenv:Header/>
	<soapenv:Body>
		<ser:cons_saldo_cliente>
			<cliente>1234</cliente>
			<entidad>12345</entidad>
		</ser:cons_saldo_cliente>
	</soapenv:Body>
</soapenv:Envelope>

I create based in the other comments this code:

$urlWSDL = 'https://xxxxxxxx/xxx/xxx/xxx?wsdl';

$client = Soap::withGuzzleClientOptions([
            'allow_redirects' => RedirectMiddleware::$defaultSettings,
            'http_errors' => true,
            'decode_content' => true,
            'verify' => false,
            'cookies' => false,
            'idn_conversion' => false,
        ])
            ->baseWsdl($urlWSDL)
            ->withOptions([
                'ser' => 'http://service.cows.gnconsult.com/',
            ])
            ;

        $response = $client->call('ser:cons_saldo_cliente', [
                'cliente' => '1234',
                'entidad' => '12345',
            ])
            ->throw()
            ->json();

        return $response;

But in diferente case is the same answere:

Typed property CodeDredd\\Soap\\SoapClient::$request must not be accessed before initialization

Please help me!

400 Bad Request, XML not as expected

Hi @CodeDredd,

I've been trying to implement this package today but have encountered a few issues along the way, such as exceptions about request body being empty when using withWsa(), now that I have removed that call I am getting a 400 Bad Request with everything I try even though the docs make it look very straightforward.

Here is a screenshot of my IDE, showing my class on the left creating the Soap client via your package and calling a method defined in the WSDL, and passing three parameters through with keys which I would expect to see in the XML request. However when I perform a dd() in the ExtSoapEncoder it gets passed through, the arguments are there but are not truly reflected in the generated XML.

soap_package_issue_anon

For example it hasn't added the first parameter languageID at all, and it has added the startDate and endDate as param1, param2 etc not honouring the keys that I am passing through - why is this?

Also just to note I have defined the __call method on my class and applied trait when I took a look at one of the generated classes:

    /**
     * Execute soap call
     *
     * @param string $method
     * @param mixed $parameters
     * @return \CodeDredd\Soap\Client\Response|mixed
     */
    public function __call($method, $parameters)
    {
        if (static::hasMacro($method)) {
            return $this->macroCall($method, $parameters);
        }

        $validationClass = 'App\\Validations'
            . ucfirst(Str::camel($method))
            . 'Validation';
        if (class_exists($validationClass)) {
            $parameters = app()->call([$validationClass, 'validator'], ['parameters' => $parameters]);
        }

        return $this->soap->call($method, $parameters);
    }

I can generate a successful response from the API using the SoapUI application which generates the following XML for the request:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
   <soap:Header/>
   <soap:Body>
      <tem:GetVisitSummariesByDate>
         <tem:languageID>1</tem:languageID>
         <tem:startDate>2021-04-10T00:00:00.000Z</tem:startDate>
         <tem:endDate>2021-04-14T00:00:00.000Z</tem:endDate>
      </tem:GetVisitSummariesByDate>
   </soap:Body>
</soap:Envelope>

The SoapUI configuration in terms of authentication is simply a Username and Password, WSS-Password Type set to PasswordText and the 'Add default wsa:To` option checked.

Am I missing something here or is this package not going to work the way I need it to? ๐Ÿค”

Laravel 6, package version 1.5.1

Cheers,
Matt

Install Issue on Laravel 8.X

Laravel 8 use guzzle ^7.0, but php-http/guzzle6-adapter require guzzlehttp/guzzle ^6.0.

Laravel 8 install error:

Problem 1
- Installation request for guzzlehttp/guzzle (locked at 7.2.0, required as ^7.0.1) -> satisfiable by guzzlehttp/guzzle[7.2.0].
- php-http/guzzle6-adapter 2.x-dev requires guzzlehttp/guzzle ^6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- php-http/guzzle6-adapter v2.0.0 requires guzzlehttp/guzzle ^6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- php-http/guzzle6-adapter v2.0.1 requires guzzlehttp/guzzle ^6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- Conclusion: don't install codedredd/laravel-soap v1.3.1|install guzzlehttp/guzzle 6.5.x-dev
- Conclusion: don't install guzzlehttp/guzzle 6.5.x-dev
- codedredd/laravel-soap v1.3.0 requires php-http/guzzle6-adapter ^2.0 -> satisfiable by php-http/guzzle6-adapter[2.x-dev, v2.0.0, v2.0.1].

Error passing a date parameter

Hello,
parameters of type date do not work correctly, they are passed empty.
I've tried changing the 'wrap_arguments_in_array' parameter but it doesn't work anyway.

For example:

     <xsd:element maxOccurs="1" minOccurs="1" name="fecha_denuncia" type="xsd:date">
        <xsd:annotation>
           <xsd:documentation>Fecha en la cual se desea conocer la
					validez del cinemometro. Ej: 2013-10-31</xsd:documentation>
        </xsd:annotation>
     </xsd:element>

Any other parameters work correctly, but those defined as 'xsd:date' do not.

This is my code:

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->wsdl = config('soap.DGT.base_uri');
    $this->privKey = config('soap.DGT.private_key');
    $this->publicKey = config('soap.DGT.public_key');
    $this->clientSOAP = Soap::baseWsdl($this->wsdl)
                            ->withOptions([
                                'cache_wsdl' => WSDL_CACHE_NONE,
                                'trace' => true,
                            ])
                            ->withWsse([
                                'privateKeyFile' => $this->privKey,
                                'publicKeyFile' => $this->publicKey,
                            ]);
}


/**
 * Retorna si existe el cinemometro
 * @return Illuminate\Http\Response
 */
public function esValidoCertificadoCinemometro($cin_id, $fecha_denuncia)
{
    $response = $this->clientSOAP->call('esValidoCertificadoCinemometro', ['cin_id' => $cin_id,
                                                                            'fecha_denuncia' => $fecha_denuncia,]);
    if ($response->successful()) {
        return $this->successResponse($response->json());
    }

    return $this->clientSOAP->debugLastSoapRequest();
}

And this is the output of debugLastSoapRequest():

{
"request": {
"headers": "",
"body": "\n<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1="http://servappl.trafico.es/ServicioWebDGT/services/ServicioWeb\">SOAP-ENV:Bodyns1:esValidoCertificadoCinemometro<cin_id>100067</cin_id><fecha_denuncia/></ns1:esValidoCertificadoCinemometro></SOAP-ENV:Body></SOAP-ENV:Envelope>\n"
},
"response": {
"headers": "",
"body": "\n<soapenv:Envelope xmlns:dpconfig="http://www.datapower.com/param/config\" xmlns:dgt="http://www.datapower.com/extensions/functions\" xmlns:date="http://exslt.org/dates-and-times\" xmlns:str="http://exslt.org/strings\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd="http://www.w3.org/2001/XMLSchema\" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/\">soapenv:Header/soapenv:Bodysoapenv:Faultsoapenv:Schema.ErrorError de validacion de esquema : cvc-simple-type 1: element fecha_denuncia of type {http://www.w3.org/2001/XMLSchema}date may not be empty</soapenv:Fault></soapenv:Body></soapenv:Envelope>"
}
}

Add PHP 8.2 support

What problem is this solving

Currently the PHP version is locked to ^8.0 and ^8.1 in composer. But PHP 8.2 is about to release.

Proposed solution

Add ^8.2.

Problem installing in Laravel 8

When trying to install via Composer with the given code, the following error is obtained:

Problem 1
- codedredd / laravel-soap [v1.5.0, ..., v1.5.1] require illuminate / support ^ 5.6 || ^ 6.0 || ^ 7.0 -> found illuminate / support [v5.6.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev ] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires codedredd / laravel-soap ^ 1.5 -> satisfiable by codedredd / laravel-soap [v1.5.0, v1.5.1].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require codedredd / laravel-soap: *" to figure out if any version is installable, or "composer require codedredd / laravel-soap: ^ 2.1" if you know which you need.

If I install it indicating the latest compatible version, it tells me the following:

Problem 1
- phpro / soap-client [v1.4.0, ..., v1.7.x-dev] require psr / log ^ 1.0 -> found psr / log [1.0.0, ..., 1.1.4] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- codedredd / laravel-soap v2.0.0-rc.1 requires phpro / soap-client ^ 1.4 -> satisfiable by phpro / soap-client [v1.4.0, ..., v1.7.x-dev].
- Root composer.json requires codedredd / laravel-soap 2.0.0-rc.1 -> satisfiable by codedredd / laravel-soap [v2.0.0-rc.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

I am using Laravel 8 with Jetstream

Cant install with php version 8.0

Steps to reproduce the behavior

Document say it support php 8.0, but when i run composer require codedredd/laravel-soap
it show

  Problem 1
    - codedredd/laravel-soap v3.0.0.beta.0 requires php-soap/psr18-wsse-middleware ^1.1 -> satisfiable by php-soap/psr18-wsse-middleware[v1.1.0].
    - codedredd/laravel-soap[v3.0.0.beta.1, ..., v3.0.1] require veewee/xml ^1.3 -> satisfiable by veewee/xml[v1.3.0, v1.4.0, 1.5.0, 1.6.0].
    - php-soap/psr18-wsse-middleware v1.1.0 requires veewee/xml ^1.0 -> satisfiable by veewee/xml[v1.0.0, ..., 1.6.0].
    - veewee/xml[v1.0.0, ..., v1.0.1] require azjezz/psl ^1.6 -> satisfiable by azjezz/psl[1.6.0, ..., 1.9.x-dev].
    - veewee/xml[v1.1.0, ..., 1.6.0] require azjezz/psl ^1.9 || ^2.0 -> satisfiable by azjezz/psl[1.9.0, ..., 1.9.x-dev, 2.0.0-rc1, ..., 2.1.x-dev].
    - azjezz/psl[1.6.0, ..., 1.9.x-dev] require ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
    - azjezz/psl[2.0.0-rc1, ..., 2.1.x-dev] require php ~8.1.0 -> your php version (8.0.13) does not satisfy that requirement.
    - Root composer.json requires codedredd/laravel-soap ^3.0 -> satisfiable by codedredd/laravel-soap[v3.0.0.beta.0, ..., v3.0.1].

Expected behavior

Install successfully.

Actual behavior

Install error.

Additional information

php 8.0.13
windows 11
wamp

Please tell if you need any other detail information.
Thank you!

Proxy settings do not reach Guzzle

Reproduction

Setting the proxy settings using

$soap = Soap::baseWsdl($wsdl)->withOptions([
                    'proxy_host' =>'...',
                    'proxy_port' => '..',
                    'proxy_login' => "",
                    'proxy_password' => "",
                ]);

and then making a call with

$soap->Call('Ping', []);

does not use the proxy.

If I manually edit the GuzzleHttp\Handler\CurlHandler class to burn in the proxy, then the proxy server is used. (Obv., this workaround is not suitable outside dev env)

    public function __invoke(RequestInterface $request, array $options): PromiseInterface
    {
        if (isset($options['delay'])) {
            \usleep($options['delay'] * 1000);
        }

        // Dirty dirty hack!!!!
        $options['proxy'] = config('soap.proxy');

        $easy = $this->factory->create($request, $options);
        \curl_exec($easy->handle);
        $easy->errno = \curl_errno($easy->handle);

        return CurlFactory::finish($this, $easy, $this->factory);
    }

Expected behavior

The library directly tries to call the SOAP host, though the proxy server.

Actual behavior

The library directly tries to call the SOAP host, without using the proxy server.

Additional information

image

Thank you for your assistance

How to add headers in the envelope?

I'm not sure if I'm misunderstanding the documentation, the feature doesn't exist, or if there's a way to do this with the existing features. I'm working with a SOAP API that specifies the following message format:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="insert API namespace here">
	<env:Header>
		<ns1:Authenticate> 
			<AuthenticateRequest>
				<id>my_id_here</id>
				<key>my_key_here</key> 
			</AuthenticateRequest>
		</ns1:Authenticate> 
	</env:Header> 
	<env:Body>
		... 
	</env:Body>
</env:Envelope>

Based on the example used in withHeaders(), it appears that those add Http headers, not soap headers which is what I'm trying to do here. I did try putting it in withHeaders() but that didn't work with the api responding that the id and key are invalid.

$auth_header = [
    'id' => $my_id,
    'key' => $my_key
]
$response = Soap::withHeaders($auth_header)->baseWsdl($api_wsdl)->$api_method($params);

Calling their standalone authenticate endpoint does verify my credentials are valid which rules out the wrong credentials being provided.

$response = Soap::baseWsdl($api_wsdl)->Authenticate([
    'id' => $my_id,
    'key' => $my_key
]);

Attempting the following doesn't work either with the api complaining that my credentials were not valid and I suspect it's because it's being put into the body.

$auth_header = [
    'AuthenticateRequest' => [
        'id' => $my_id,
        'key' => $my_key
    ]
];
$response = Soap::baseWsdl($api_wsdl)->$methodName([
    'Authenticate' => $auth_header,
    'other_params' => $values
]);

Delay between requests

Some SOAP services have requirements about max requests count, like not more 1 request in 0.25 sec.

What about to make new method that set delay between requests? Like:

$client = Http::baseWsdl('wsdl')->delay(0.25);

$client->call('first');
$client->call('second'); // this method will be called in 0.25sec after getting previous response

I think most advantage of that functional in tests, where delay can be disabled (by default?):

Soap::fake()->enableDelay();

As alternative - maybe callbacks that will be called before every request, like:

$client = Http::baseWsdl('wsdl')
    ->before(function(string $method_name, Request $request, bool $is_fake) {
        if($method_name === 'GetBigData' && $is_fake) {
            usleep(250000);
        }
    });

How do I install version 2?

composer require codedredd/laravel-soap tries to install v1.5

I use laravel-zero based on laravel 8. So I need v2. But when I try the below command, it fails:

composer require codedredd/[email protected]

I get the below error:
Could not find a matching version of package

Wrong Version - Version Mismatch laravel Soap vs PHP SoapClient

Bellow code with laravel-soap:

$client = Soap::baseWsdl($url)
->withOptions([
    'location' => $url,
    'soap_version' => SOAP_1_1,
    'local_cert' => storage_path('app/local_cert.pem'),
    'trace' => true,
    'keep_alive' => true,
    'exceptions' => true,
    'cache_wsdl'=> WSDL_CACHE_NONE,
]);    

$response = $client->call('retrieveInfo', [
  'username' => 'admin',
  'password' => 'awesome',
]);

Returns: Wrong Version

Bellow code with php soapClient

$client = new \SoapClient($url, array(
  'location' => $url,
  'soap_version' => SOAP_1_1,
  'local_cert' => storage_path('app/local_cert.pem'),
  'trace' => true,
  'keep_alive' => true,
  'exceptions' => true,
  'cache_wsdl'=> WSDL_CACHE_NONE,
));

$response = $client->__soapCall("retrieveInfo", array([
  'username' => 'admin',
  'password' => 'awesome',
]));

Returns: Success and works

Please tell what tests to do so i can give more details, sadly i cannot attach the Wsdl.
Thank you!

Laravel 10 support

What problem is this solving

Cannot install in Laravel 10

Proposed solution

Change composer.json to allow laravel 10 to install

Describe alternatives you've considered

I notice there is non conflicting PR for this, could that be implemented?

400 Bad Request

PHP: 8.1
Laravel: 9.47
codedredd/laravel-soap: 3.0.2

Hi @CodeDredd

Thanks for the awesome Package.

I'm facing issue while using this Package to make API calls. I get 400 Bad request response.

Looks like it doesn't reach to the point where it generates the request body.
I followed the function calls from Package classes:
In our ApiClient class, we're calling the call method of package's SoapClient class. In the call method, it calls its class member method refreshEngine, which calls setTransport method. Eventually it reaches the AbusedClient class's constructor, from where when it calls:

parent::__construct($wsdl, $options);

it returns the error response:

image

Here is my code:

`$client = Soap::baseWsdl(config('services.api.endpoint'))

                ->withWsse([
                    'storeId' => config('services.api.store_id'),
                    'userName' => config('services.api.username'),
                    'password' => config('services.api.password'),
                ])

                ->call('SubmitTransaction', $data);

I've also tried:


$client = Soap::baseWsdl(config('services.leads_online.endpoint'))

                ->withOptions([
                    'cache_wsdl' => WSDL_CACHE_NONE,
                    'trace' => true,
                ])

                ->withWsse([
                    'storeId' => config('services.api.store_id'),
                    'userName' => config('services.api.username'),
                    'password' => config('services.api.password'),
                ])

                ->withWsa()

                ->call('SubmitTransaction', $data);

The storeId is expected for authentication purpose, I've also tried by removing it.
May be I'm missing something or doing something wrong somewhere.
Can you please take a look an guide me here.
Thanks in advance :-)

Add PHP 8.1 Support

If I want to install I get:

Your lock file does not contain a compatible set of packages. Please run composer update.

Problem 1

  • phpro/soap-client is locked to version v1.7.2 and an update of this package was not requested.
  • phpro/soap-client v1.7.2 requires php ^7.4 || <8.1 -> your php version (8.1.1) does not satisfy that requirement.

Problem 2

  • phpro/soap-client v1.7.2 requires php ^7.4 || <8.1 -> your php version (8.1.1) does not satisfy that requirement.
  • codedredd/laravel-soap v2.0.0-rc.1 requires phpro/soap-client ^1.4 -> satisfiable by phpro/soap-client[v1.7.2].
  • codedredd/laravel-soap is locked to version v2.0.0-rc.1 and an update of this package was not requested.

At least the phpro/soap-client package should be upgraded to Version 2.1.0

Problem decoding response

Hi!
First of all: many thanks!

I have a little problem with a soap webservice. The response is incomplete (null) and i don't know why.
Here an example :
image
image

I think the request & response are good. The problem is probably with the decoding process.

Thanks to you again.
Thomas.

Error sending arguments

HI,

Since I've upgrade to 3.0.1, I've got problem while sending arguments.

Indeed, for example :

Soap::baseWsdl($request->host)
       ->withOptions([
            'soap_version' => SOAP_1_2,
        ])
        ->call('GetTeeSheetByDate', [
                'courseId' => 1,
                'fromDateOA' => '444444',
                'toDateOA' => '444444'
            ]);

It generate a request like this (on version 3.0.1)

<?xml version="1.0" encoding="UTF-8"?>\n
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/Psk.WTS8.WebServices/OnlineReservationService"><env:Body><ns1:GetTeeSheetByDate/><param1>44444</param1><param2>44444</param2></env:Body></env:Envelope>\n

We should have : (on version 3.0.0.beta.3 it was this good format)

<?xml version="1.0" encoding="UTF-8"?>\n
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/Psk.WTS8.WebServices/OnlineReservationService"><env:Body><ns1:GetTeeSheetByDate/><ns1:courseId>1</ns1:courseId><ns1:fromDateOA>44444</ns1:fromDateOA><ns1:toDateOA>44444</ns1:toDateOA></env:Body></env:Envelope>

Data are not correctly formatted and it missing one of them (eg: courseId)

My problem seems to be linked to your fix (fix(#233): Array of arguments is not working correctly @CodeDredd (04113b4))

My WSDL looks like :
image

Error with composer install

Error with composer install

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires codedredd/laravel-soap ^1.5 -> satisfiable by codedredd/laravel-soap[v1.5.0, v1.5.1].
    - codedredd/laravel-soap[v1.5.0, ..., v1.5.1] require illuminate/support ^5.6 || ^6.0 || ^7.0 -> found illuminate/support[v5.6.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.

You can also try re-running composer require with an explicit version constraint, e.g. "composer require codedredd/laravel-soap:*" to figure out if any version is installable, or "composer require codedredd/laravel-soap:^2.1" if you know which you need.

Using Wsa 2005

We have a SOAP implementation that uses WSA 2005. Is it possible to add a method to add WSA2005 support from php-soap

->withWsa2005()

AbusedClient::__doRequest Argument #5 ($oneWay) type error

I did install your package (v2.0.0-beta.3) and wanted to give it a quick run.
But I immediately running into this error.

Error Message:

Phpro\SoapClient\Soap\HttpBinding\SoapRequest::__construct(): Argument #5 ($oneWay) must be of type int, bool given, called in /home/vagrant/code/vendor/codedredd/laravel-soap/src/Driver/ExtSoap/AbusedClient.php on line 23

Routes:

// routes/web.php

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    $response = CodeDredd\Soap\Facades\Soap::baseWsdl('http://www.dneonline.com/calculator.asmx?wsdl')
        ->call('Add', [
            'intA', 4,
            'intB', 5
        ]);

    return $response;
});

Packages:

// composer.json
{
    "name": "laravel/laravel",
    "require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.12",
        "laravel/tinker": "^2.5",
        "codedredd/laravel-soap": "^2",
        "ext-soap": "*"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.5",
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/homestead": "^12.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    }
}

Caused by this file

// CodeDredd/Soap/Driver/ExtSoap/AbusedClient.php

declare(strict_types=1);

namespace CodeDredd\Soap\Driver\ExtSoap;

use Phpro\SoapClient\Soap\Driver\ExtSoap\AbusedClient as PhproAbusedClient;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapOptions;
use Phpro\SoapClient\Soap\HttpBinding\SoapRequest;
use Phpro\SoapClient\Xml\SoapXml;

class AbusedClient extends PhproAbusedClient
{
    public static function createFromOptions(ExtSoapOptions $options): PhproAbusedClient
    {
        return new self($options->getWsdl(), $options->getOptions());
    }

    public function __doRequest($request, $location, $action, $version, $oneWay = 0)
    {
        $xml = SoapXml::fromString($request);
        $action = $action ?? $xml->getBody()->firstChild->localName;
        $this->storedRequest = new SoapRequest($request, $location, $action, $version, $oneWay);  // <-- line 23

        return $this->storedResponse ? $this->storedResponse->getResponse() : '';
    }
}

I'm still new to SOAP.
Does it require to feed Soap::baseWsdl()->call() with more options to make it pass?

Error when faking http error response

Hi,

I try to fake an 500 error on my test like this :

Soap::fake(function ($request) {
    return Soap::response('Hello World', 500);
});

$this->expectException(SpecificException::class);

$action->execute(....)

On my $action class, I have this code :

Soap::baseWsdl($host)
    ->withOptions([
        'soap_version' => SOAP_1_2,
    ])
    ->call('method', $args)
    ->throw()
    ->validate(['field' => 'required'])

When I run my test, neither exception has been thrown. When I debug, this on CodeDredd\Soap\Client\Response, I have a response with a status code 200

It should be a 500 as status code.

unable to install

Hi,
when I try to install laravel-soap, I run into this:

 composer require codedredd/laravel-soap
Using version ^1.3 for codedredd/laravel-soap
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for guzzlehttp/guzzle ^7.2 -> satisfiable by guzzlehttp/guzzle[7.2.0].
    - php-http/guzzle6-adapter 2.x-dev requires guzzlehttp/guzzle ^6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - php-http/guzzle6-adapter v2.0.0 requires guzzlehttp/guzzle ^6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - php-http/guzzle6-adapter v2.0.1 requires guzzlehttp/guzzle ^6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - Conclusion: don't install codedredd/laravel-soap v1.3.1|install guzzlehttp/guzzle 6.5.x-dev
    - Conclusion: don't install guzzlehttp/guzzle 6.5.x-dev
    - codedredd/laravel-soap v1.3.0 requires php-http/guzzle6-adapter ^2.0 -> satisfiable by php-http/guzzle6-adapter[2.x-dev, v2.0.0, v2.0.1].
    - Installation request for codedredd/laravel-soap ^1.3 -> satisfiable by codedredd/laravel-soap[v1.3.0, v1.3.1].


Installation failed, reverting ./composer.json to its original content.

I tried to install php-http/guzzle6-adapter

 composer require php-http/guzzle6-adapter
Using version ^2.0 for php-http/guzzle6-adapter
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for php-http/guzzle6-adapter ^2.0 -> satisfiable by php-http/guzzle6-adapter[2.x-dev, v2.0.0, v2.0.1].
    - Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.2.0].
    - Can only install one of: guzzlehttp/guzzle[7.2.0, 6.5.x-dev].
    - Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.2.0].
    - Conclusion: install guzzlehttp/guzzle 6.5.x-dev
    - Installation request for guzzlehttp/guzzle ^7.2 -> satisfiable by guzzlehttp/guzzle[7.2.0].


Installation failed, reverting ./composer.json to its original content.

Is there a way to work with a recent version of guzzle?
Thanks

soap url instead of baseWsdl

Hi, is there any way I can call an endpoint without getting the baseWsdl? The reason I asked is, the url that my soap client does not return the wsdl. I have the wsdl file though. Can I set the wsdl file locally and access the soap client with an url? The method baseWsdl expect a wsdl file to be returned. Please advise.

SSL certificate problem

Hi, and thank you for this great library.
I have this issue:

CodeDredd\Soap\Exceptions\SoapException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://webservicestest.vwgroup.it/proxy/WSDatiVeicoli.asmx

/var/www/html/vendor/codedredd/laravel-soap/src/Exceptions/SoapException.php:17
/var/www/html/vendor/codedredd/laravel-soap/src/SoapClient.php:368
...

Caused by
GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for [...]

In a standard approach, using php SoapClient I'm able to connect to this SOAP service adding this options:

$options = [
    'stream_context' => stream_context_create(
        [
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true,
            ],
        ]
    ),
];

But it seems that this is not working with your implementation that uses Guzzle under the hood.
If I tweak Guzzle client default options putting false on verify, then it works:

$defaults = [
    'allow_redirects' => RedirectMiddleware::$defaultSettings,
    'http_errors' => true,
    'decode_content' => true,
    'verify' => false,
    'cookies' => false,
    'idn_conversion' => false,
];

Is there a way to pass some option to Guzzle from CodeDredd Soap facade?

I don't have any control on the server side.

Thank you

not support to php 8.2

What problem is this solving

A clear and concise description of what the problem is. Ex. when using the function X we cannot do Y.

Proposed solution

A clear and concise description of what you want to happen with an API proposal when applicable

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Content-Type being overwritten

First of all thanks for this library - its very useful for a project I'm working through.

I have an service that requires a specific content-type value (application/soap+xml; charset=utf-8), however when I use this class and pass content-type using withHeaders() the content-type is always being set as text/xml; charset="utf-8". Is it possible to override this somehow - I've tried a few different approaches and have come up with nothing...

Error with parameters - parameter name:s

I'm using v2.x.

Returns : String reference not set to an instance of a String.\nParameter name: s"}

The soap method has parameters, but it just ignore my parameters.

$response = Soap::baseWsdl($this->baseWsdl)
                            ->withOptions($options)
                            ->call('mSocioDadosPessoais', $parameters);
 return $response->body();

Server was unable to read request. ---> There is an error in XML document (2, 252). ---> The string '' is not a valid AllXsd value

when trying to pass in any date fields, you receive the following error:

Server was unable to read request. ---> There is an error in XML document (2, 252). ---> The string '' is not a valid AllXsd value

Ive tried almost every date format to fix this. The field type from what the soap api docs state is datetime, however there seems to be a lot of people stating that you should use

->format('c') if using Carbon

Do you know how i can get around this?

Hi everyone! i have a following question: how to set a timeout to soap call???

Discussed in #209

Originally posted by sramirezse March 24, 2022
I tried to use withOptions(['connection_timeout' and 'default_socket_timeout' but the response takes much longer and does not throw an error, this is my code:

`try{

        $responseGetOrder = Soap::baseWsdl($this->url)->withOptions([
            'connection_timeout' => 30,
            'default_socket_timeout' => 30,
        ])->getOrder([
            'user' => $this->user,
            'operator' => $this->operator,
            'idProduct' => 'RMP100',
            'numberAccount' => 5511111160,
            // 'numberAccount' => 3334441122,
            // 'numberAccount' => 5511111130,
            'clientFolio' => $serviceAttempt->id,
        ]);
        $responseGetOrderBody = $responseGetOrder->json();
        return $responseGetOrderBody;
    }catch(\Exception $e){
       dd($e);
    }`

this is the time it takes to respond, sorry my bad english
imagen

Add Laravel 9 support

Is your feature request related to a problem? Please describe.
Currently it does not support Laravel 9. This prevents me from updating.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Change "illuminate/support": "^8.0", to "illuminate/support": "^8.0 || ^9.0",

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Are you able to assist bring the feature to reality?
yes, I can...

Additional context
Add any other context or screenshots about the feature request here.

handler must be a callable

I've got an exception

"[object] (CodeDredd\\Soap\\Exceptions\\SoapException(code: 0): handler must be a callable at ...\\vendor\\codedredd\\laravel-soap\\src\\Exceptions\\SoapException.php:17)
[stacktrace]
#0 ...\\vendor\\codedredd\\laravel-soap\\src\\SoapClient.php(348): CodeDredd\\Soap\\Exceptions\\SoapException::fromThrowable()
#1 ...: CodeDredd\\Soap\\SoapClient->call()
...
[previous exception] [object] (InvalidArgumentException(code: 0): handler must be a callable at ...\\vendor\\guzzlehttp\\guzzle\\src\\Client.php:68)
[stacktrace]
#0 ...\\vendor\\php-http\\guzzle6-adapter\\src\\Client.php(79): GuzzleHttp\\Client->__construct()
#1 ...\\vendor\\php-http\\guzzle6-adapter\\src\\Client.php(47): Http\\Adapter\\Guzzle6\\Client::buildClient()
#2 ...\\vendor\\codedredd\\laravel-soap\\src\\SoapClient.php(135): Http\\Adapter\\Guzzle6\\Client::createWithConfig()
#3 ...\\vendor\\codedredd\\laravel-soap\\src\\SoapClient.php(174): CodeDredd\\Soap\\SoapClient->setHandler()
#4 ...\\vendor\\codedredd\\laravel-soap\\src\\SoapClient.php(370): CodeDredd\\Soap\\SoapClient->withHandlerOptions()
#5 ...\\vendor\\codedredd\\laravel-soap\\src\\SoapClient.php(323): CodeDredd\\Soap\\SoapClient->buildClient()
#6 ...: CodeDredd\\Soap\\SoapClient->call()
...

The problem is in the constructor for the file guzzle6-adapter\Client.php. In $config variable for parameter 'handler' is passed an array, not a callable object.

An example usage is:

$context = stream_context_create([
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    ]
]);
$response = Soap::baseWsdl('http://test.com'/v1?wsdl)->withWsse([
    'userTokenName' => 'username',
    'userTokenPassword' => 'password',
])->withOptions([
    'trace' => true,
    'connection_timeout' => '60',
    'stream_context' => $context,
    'cache_wsdl' => WSDL_CACHE_NONE
])->call(...);

Laravel: 7.26.1

Can you fix this?
Thanks.

Make Readme Better

The readme has still some typos and the codes examples should be more readable.

Laravel 8 in not install

Your requirements could not be resolved to an installable set of packages.

Problem 1
- codedredd/laravel-soap[v1.5.0, ..., v1.5.1] require illuminate/support ^5.6 || ^6.0 || ^7.0 -> found illuminate/support[v5.6.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but it conflicts with your root composer.json require (^8.56).
- Root composer.json requires codedredd/laravel-soap ^1.5 -> satisfiable by codedredd/laravel-soap[v1.5.0, v1.5.1].

Problem installation with Laravel 8.8 - failed

Problem 1
- codedredd/laravel-soap[v1.5.0, ..., v1.5.1] require illuminate/support ^5.6 || ^6.0 || ^7.0 -> found illuminate/support[v5.6.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires codedredd/laravel-soap ^1.5 -> satisfiable by codedredd/laravel-soap[v1.5.0, v1.5.1].

missing WS-Addressing envelope headers

Hi,
I need to send a request like this:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <a:Action mustUnderstand="1">https://www.example.com/API/GetPersonInfoByUserID_Post</a:Action>
    <a:MessageID>urn:uuid:73e142a1-df57-4bfe-9caa-aaaaaaaaaaaa</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To mustUnderstand="1">https://yoursite.example.com/services/API.svc/ws</a:To>
  </s:Header>
  <s:Body>
    <GetPersonInfoByUserID_Post xmlns="https://www.example.com/">
      <username>username</username>
      <password>password</password>
      <user_id>a_user</user_id>
    </GetPersonInfoByUserID_Post>
  </s:Body>
</s:Envelope>

and my code is:

        $client = Soap::baseWsdl('https://yoursite.example.com/services/API.svc?Wsdl')
            ->withWsa()
            ->withOptions([
                'soap_version' => SOAP_1_2,
                'trace' => true,
            ]);
        $response = $client->call('GetPersonInfoByUserID_Post', [
                'username' => 'username',
                'password' => 'password',
                'user_id' => 'a_user',
            ]);
        $debug = $client->debugLastSoapRequest();

        return $debug;

Actual behavior

I'm using debugLastSoapRequest() to know the request sent by Laravel:

"request": {
    "headers": "",
    "body": "
<?xml version=\"1.0\" encoding=\"UTF-8\"?> <env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns1=\"https://www.example.com/\">
  <env:Body>
    <ns1:GetPersonInfoByUserID_Post>
       <ns1:username>username</ns1:username>
       <ns1:password>password'</ns1:password>
       <ns1:user_ide>a_user</ns1:user_id>
    </ns1:GetPersonInfoByUserID_Post>
  </env:Body>
</env:Envelope>\n"
  },

and, as you can see, the WSA envelope headers are missing. I've tried to add header:

->withHeaders(['Content-Type' => 'application/soap+xml; charset="utf-8"; action="https://www.example.com/API/GetPersonInfoByUserID_Post"'])

or:

->withHeaders(['SoapAction' => 'https://www.example.com/API/GetPersonInfoByUserID_Post'])

but I'm not able to get any WSA headers in my request.

The response from the SOAP server is:

The SOAP action specified on the message, '', does not match the HTTP SOAP Action

Am I missing something (I'm a newbie in php/soap world) or is there a problem in withWsa() function ?

Thanks

Additional information

Laravel v9.42.2
laravel-soap v3.0.2

Problem to retrieve action

Since I updated the package to v2.0.0-beta.9, I've got a problem to retrieve SOAP request action.

This method parse header to get SOAPAction but with version v2.0.0-beta.9, SOAPAction doesn't exists on header, we can see it in the Content-type header ...

public function action(): string
{
   return $this->request->getHeaderLine('SOAPAction');
}

Request dump :

...
"Content-Type" => array:1 [
    0 => "application/soap+xml; charset="utf-8"; action="addReservation""
]
...

In the v2.0.0-beta.7 I don't have this problem

Thanks for your answers

Problem with binary data

I'm expexting to receive around 700KB of text data in response(binary representation of file). When I try to get body() from response I have empty string, json() gives null. What may be reason for this? some memory limits? I'm running it on artisan dev server.

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.