meng-tian / async-soap-guzzle Goto Github PK
View Code? Open in Web Editor NEWAn asynchronous SOAP client build on top of Guzzle.
License: MIT License
An asynchronous SOAP client build on top of Guzzle.
License: MIT License
Some methods in services, witch used soap, have methods that do not need arguments. So i must put empty array to call method but it is unreadable code. Can you make it optional?
Can I use async-soap-guzzle with ws-security?
Hi,
I am using promise with guzzle implementation and as a promise callback i have been using ResponseInterface. Implementation of your asynchronous SOAP request (method callAsync) does not return request that implements ResponseInterface.
Is there some possible way to get response that implements ResponseInterface ? It would be great if the response from async soap guzzle will be the same as response after calling sendAsync in guzzle implementation.
Thank you very much
Replace "composer install ..." to "composer require"
It looks like many people are confused how v0.4+ of this library should be used, e.g., #40.
I plan to update the README to specifically explain how this library should be used after v0.4+.
It would be great to do accesible the XML REQUEST of a client to see the lastrequest, I see debuging that the XML request is in the client object. But is impossible to recover. Why is not possible to recover it?
some like _lastRequest is not working.
soap 1.2 will lead to test fails in travis ci but not locally.
Hi. Thanks for the library, it's working great here.
One minor annoyance is that SoapClient provides a wsdl_cache
option that this library ignores, thus no WSDL is ever cached.
The cache_wsdl option is one of WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY or WSDL_CACHE_BOTH.
The cache would improve performance.
Hi @meng-tian , first thank you so much for your work, i really apreciate!
I wrote this issue requesting more use cases, example errors responses,SoapFault...
Hope you can update please.
Thanks again!
Hi Meng-Tian,
Have you managed to do multiple async calls at the same time? Currently, in most examples - you call wait on the promise which makes it synchronous.
I have tried few things but to no avail.
The above(atleast the first option) makes the requests in a non-blocking way, but it's the order and timing of the responses not making sense.
Suppose I have 3 similar requests all initiated at the same time calling the SoapClient async function below.
echo Request: #
$response = (yield $this->client->sendAsync($request, $requestOptions));
echo Response: #
The order goes like this for a http call of 5 seconds
Request 1, Request 2, Request 3 at T
First response received at T + 5
Second response received at T + 5 + 5
Third response received at T + 5 + 5 + 5
Note: I use all 4 of your libraries to send soap requests.
Hello ,
I have a soap call where the namespace url is different from the wsdl url.
$client = new \SoapClient('http://example.com/?wsdl', []);
$client->__setSoapHeaders(
new \SoapHeader('http://other.domain.tld', 'AuthHeader', [
'Username' => $this->user,
'Password' => $this->password,
'ResellerCode' => $this->code,
]));
$client->someFunction();
works
$factory = new \Meng\AsyncSoap\Guzzle\Factory();
$client = $factory->create(new \GuzzleHttp\Client(), 'http://example.com/?wsdl');
$client->call(
'someFunction',
[],
[
new SoapHeader('http://other.domain.tld',[
'Username' => $this->user,
'Password' => $this->password,
'ResellerCode' => $this->code,
])
]
);
returns
SOAP-ERROR: Parsing Schema: can't import schema from 'data://text/xml/_types/CommonTypes.xsd'
I'm guessing it's related to the namespace since i'm already using your package for other calls with no issues.
Is there anyway to set the namespace ?
PHP Notice: Undefined variable: response in .../vendor/meng-tian/async-soap-guzzle/src/SoapClient.php on line 48
This is going to be a breaking change as the some new dependencies (PSR17 factory interfaces) need to be injected.
Hi @meng-tian,
This is a question, not an issue.
Is there any way to get the SOAP-ENV:Header (sample below) from the response after doing a soap call?
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<SOAP-ENV:Header>
....
</SOAP-ENV:Header>
<SOAP-ENV:Body>
.....
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Edit: After a bit of investigation, I found the answer I was looking for. Basically, we can pass an argument by reference to the client caller function - the client then sets the output headers to this variable.
See $outputHeaders below.
$factory = new Factory();
$client = $factory->create(new Client($client_options), $wsdl);
$response = $client->call($name, array $arguments, array $options = null, $inputHeaders = null, array &$outputHeaders = null)
Regards,
Bilal
When I'm using local WSDL file, it fails with an error from CURL.
I tried with path like "/some/path/file.wsdl" and "file:///some/path/file.wsdl" but it didn't work.
The error comes from here : https://github.com/meng-tian/async-soap-guzzle/blob/master/src/Factory.php#L33
The SoapClient class support local files and I thought it would be great if it was supported here too.
Maybe add a condition to check if the URI scheme is "file" and load WSDL data without using curl ?
No issue here, just wanted to thank you for this awesome package. It actually makes working with Soap somewhat bearable! ๐
Right now this SoapClient uses only the Guzzle Response Body to work with. For a full usage it would be useful to have information like Header, Status Code etc.
Is there a plan to implement it?
How could the headers, options & context options, and arguments be set to the client?
Can you provide a complete example that includes credentials, namespace, etc.?
Trying to utilize this package but I get the error:
Class 'Laminas\Diactoros\StreamFactory' not found
I looked at the composer.json file and you have laminas/laminas-diactoros
under require-dev
. Shouldn't it be included under the require
key if it's a package dependency?
When developing an adapter for one service, I encountered the problem of mocking soap responses. How would it be best to form a response through this package?
C:\www\ICE\localization_manager>composer require meng-tian/async-soap-guzzle
?[30;43mThe "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed?[39;49m
Hi,
Suddenly My app started to not work and here is the issue:
Symfony\Component\Debug\Exception\FatalErrorException in SMSChannel.php line 21: Class 'Meng\AsyncSoap\Guzzle\Factory' not found
use GuzzleHttp\Client;
use Meng\AsyncSoap\Guzzle\Factory;
$message = $notification->toSms($notifiable);
$factory = new Factory();
$client = $factory->create(new Client(), 'http://xxxxx/WebService.asmx?wsdl');
$promise = $client->callAsync('SendMessage', [['Username' => env('SMS_USERNAME'),
'Password' => env('SMS_PASSWORD'),
'Number' => env('SMS_NUMBER'),
'Mobile' => array('string' => substr($notifiable->mobile,1)) ,
'Message' =>$message->text,
'Type' => '1']]);
$result = $promise->wait();
I have a rather simple no-wsdl query:
with regular SoapClient I do:
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$soapClient = new SoapClientDebug(NULL, [
'login' => self::$user,
'password' => self::$pass,
'location' => self::$endpointUrl,
'uri' => 'urn:sap-com:document:sap:rfc:functions',
'trace' => 1,
'use' => SOAP_LITERAL,
'style' => SOAP_SINGLE_ELEMENT_ARRAYS,
'soap_version' => SOAP_1_1,
'stream_context' => $context,
]);
$soapVar = new \SoapVar('<FIRST>1234</FIRST><SECOND>ABC</SECOND>', XSD_ANYXML);
return $soapClient->GET_VALUES($soapVar);
With this one I do:
$arguments = [
'login' => self::$user,
'password' => self::$pass,
'location' => self::$endpointUrl,
'uri' => 'urn:sap-com:document:sap:rfc:functions',
'trace' => 1,
'use' => SOAP_LITERAL,
'style' => SOAP_SINGLE_ELEMENT_ARRAYS,
'soap_version' => SOAP_1_1,
];
$request_options = array(
'auth' => [self::$user, self::$pass],
'verify' => FALSE,
);
$soapVar = new \SoapVar('<FIRST>1234</FIRST><SECOND>ABC</SECOND>', XSD_ANYXML);
$factory = new Factory();
$client = $factory->create(new Client($request_options), NULL, $arguments);
$promise = $client->callAsync(self::$getAllValuesService, [$soapVar]);
return $promise->wait();
where $getAllValuesService = "GET_VALUES"
For both instances I wrote out with debugger the request (xml), endpoint (url) and action for the actual soap request, and they are identical.. just with the guzzle soap I am returned the following error:
SoapFault: looks like we got no XML document in SoapClient->__soapCall() (line 60 of vendor/meng-tian/php-soap-interpreter/src/Soap.php).
Hoe someone more knowledgeable in this, than I, can help.
Best regards,
Alari
Hi Meng,
I am trying to achieve below header
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> <wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken"> <wsse:Username>USERNAME</wsse:Username> <wsse:Password Type="#PasswordText">PASS</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">nEmCjKCvNwnnY5CfyOq3fQ==</wsse:Nonce> <wsu:Created>2018-01-11T13:09:16.157Z</wsu:Created> </wsse:UsernameToken> </wsse:Security> <wsa:Action>URL/Account_Get</wsa:Action> <wsa:To>URL/JavaAxis</wsa:To> </soap:Header>
Below are my codes
$client = $this->factory->create(
new \GuzzleHttp\Client(),
'URL?WSDL',
[
'soap_version' => 'SOAP_1_2',
'login' => 'USERNAME',
'password' => 'PASSWORD',
'location' => 'URL/JavaAxis',
]
);
$response = $client->call('FUNCTION_NAME', [['VAR_NAME' => 'VALUE']]);
So far it will only response NULL, anything that I've missed?
Appreciate your help.
Prior to using this package I used __setSoapHeaders to set my authentication. Doesn't seem to be any way to do that now..?
I need to make several soap calls using a pool.
is there any way to do this
<?php
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use Meng\AsyncSoap\Guzzle\Factory;
require_once '../vendor/autoload.php';
$factory = new Factory();
$client = $factory->create(new Client(), 'http://www.dneonline.com/calculator.asmx?WSDL');
// async call
$data = [1, 2, 4, 5, 6];
$requests = function ($data) use ($client) {
foreach ($data as $key => $value) {
yield $key => $client->callAsync('Subtract', [['intA' => $value, 'intB' => 1]]);
}
};
$pool = new Pool(new Client(), $requests($data), [
'concurrency' => 500,
'fulfilled' => function (Response $response, $index) use (&$data) {
echo $data[$index] . ' - SUCESS' . PHP_EOL;
},
'rejected' => function ($reason, $index) use (&$data) {
echo $reason->getResponse()->getBody()->getContents();
echo $data[$index] . ' - ERROR' . PHP_EOL;
}
]);
$promise = $pool->promise();
$promise->wait();
I need to attach an xml file to send via soap. Is it possible to attach a file with this project ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.