ricorocks-digital-agency / soap Goto Github PK
View Code? Open in Web Editor NEWA Laravel SOAP client that provides a clean interface for handling requests and responses.
License: MIT License
A Laravel SOAP client that provides a clean interface for handling requests and responses.
License: MIT License
Hi!
I am trying to consume a soap service sending a .pem certificate, but I receive a connection error with the endpoint indicating that the certificate is not sent. This is the correct way to attach it?
$response = Soap::to(env('SOAP_URL', ''))
->withBasicAuth('xxxx', 'C/.21k')
->withOptions([
'local_cert' => storage_path() . '\certificate.pem',
'soap_version' => SOAP_1_2
])
->trace(true)
->call('consultaPlano', $params);
Hello,
I need to pass following structure to the SOAP Client:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<get_voip_account_subscriber xmlns="/SOAP/Provisioning">
<authentication>
<type xsi:type="xsd:string">admin</type>
<username xsi:type="xsd:string">administrator</username>
<password xsi:type="xsd:string">administrator</password>
</authentication>
<parameters>
<id xsi:type="xsd:int">6</id>
<username xsi:type="xsd:string">nobody</username>
<domain xsi:type="xsd:string">example.com</domain>
</parameters>
</get_voip_account_subscriber>
</soap:Body>
</soap:Envelope>
I've tried with the following array as parameters. But it doesn't works.
$params = [
'authentication' => [
'type' => 'admin',
'username' => 'administrator',
'password' => 'administrator',
],
'parameters' => [
'id' => 6,
'username' => 'nobody',
'domain' => 'example.com'
]
]
Anybody can give me an hand with this?
Regards
This is my wsdl
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:alt="http://aaa.com/"
xmlns:req="http://bbb.com"
xmlns:req1="http://ccc.com/"
>
<soapenv:Header/>
<soapenv:Body>
<alt:altaDeDeudas>
<!--Optional:-->
<requerimientoAltaDeDeudas>
<req:cabecera>
<idRequerimiento>?</idRequerimiento>
<ipCliente>?</ipCliente>
<timeStamp>?</timeStamp>
<idEntidad>?</idEntidad>
<canal>?</canal>
</req:cabecera>
<req1:ente>?</req1:ente>
<req1:usuario>?</req1:usuario>
</requerimientoAltaDeDeudas>
</alt:altaDeDeudas>
</soapenv:Body>
</soapenv:Envelope>
And this is my code so far
$client = Soap::to($wsdl)
->withHeaders($wsseHeader)
->withOptions([
'trace' => true,
'proxy_host' => $proxyHost,
'proxy_port' => $proxyPort,
])
->trace();
$body = Soap::node([])
->body([
'requerimientoAltaDeDeudas' => Soap::node([])
->body([
'cabecera' => Soap::node([])->body([
"idRequerimiento" => "aa",
"ipCliente" => $params['ip'],
"timeStamp" => "",
"idEntidad" => "",
"canal" => "",
]),
'ente' => '',
'usuario' => '',
])
]);
$response = $client->altaDeDeudas($body);
But i get an error saying that element are expected as <{http://aaa.ar/}cabecera>, <{..}ente> ....
. How can i define those namespaces/schemas on every node?
I need to build php classes from a SOAP that is behind basic auth.
$options = array(
'login' => $username,
'password' => $password,
);
$client = new SoapClient($wsdl, $options);
Hello There,
Would you consider merging a PR which includes https://github.com/php-soap/ext-soap-engine as a replacement for using PHP's SoapClient
directly?
Some context:
I am the author of phpro/soap-client.
We recently created the php-soap organisation, which contains an extraction of the low-level structure of our own soap-client package.
The packages inside the php-soap organisation can be used completely stand-alone and provide well-proven structures around PHP's SoapClient
in order to make it as flexible as possible.
What's in it for this package:
__getFunctions()
and __getTypes()
, so that you can actually do something with that information.ext-soap
implementation in the future. Benifits for that could be that the wsdl does not need to be loaded every time you want to do something with soap. (-> faster reponse times)I'm not a laravel expert, but looking at the code - it should not be to hard to include the basics.
At first sight, including the package would especially affect these lines:
Soap/src/Request/SoapClientRequest.php
Lines 80 to 88 in b0e5ef2
If you are willing to accept a PR, I am willing to try introducing the basics into this package.
Hello everybody, can you add support for php < 7.4? i have now 7.3 and i can't use "fn() =>" format but it can be solved quickly.
Thank you
I'm getting a soap fault when making a soap request. The error message is "looks like we got no XML document". I'm making the request to a third party API so I can't debug that side, however calling other methods on the same API works fine. I am a Laravel developer with minimal experience in SOAP APIs. Please could you tell me if you have any known bugs that could account for this error? There is no additional information given in the exception being thrown and soap errors are notoriously generic. I don't know where to start in debugging this error. Any help would be greatly appreciated.
Is it possible to user NTLM authentication with this library?
First, let me say that I've been working on this on and off for over a week. I'm baffled by why I can't get it working. My token works correctly when used through Postman, but I can't get the package to utilize the header/token correctly.
I am instantiating the class and trying to set it as a global header like so:
Soap::to($url)->trace()->headers(Soap::header()->name('Authorization')->data('Bearer ' . $token))->withOptions($options)->call($method, $payload);
I get the following error:
SOAP-ERROR: Parsing WSDL: Couldn't load from '<MY_SOAP_URL> : failed to load external entity "<MY_SOAP_URL>"
What am I doing wrong here? I'm just trying to set a simple Authorization
Bearer <token>
header.
Related to issue #24
I've suspected this and already did the checking and I can confirm that the soap extension is loaded in phpinfo. Maybe this is related? I even rebooted the whole development server to be sure.
soap
Soap Client => enabled
Soap Server => enabled
Directive => Local Value => Master Value
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Is there a way to dump the xml body before making the request so we can see the structure...
Hi there and thanks for the package.
I appreciate the fluent options, the fake helpers and the ray extension.
But actually I have a little problem with the package when I want to use the old magento1 soap v1 api.
https://devdocs-openmage.org/guides/m1x/api/soap/introduction.html
TLDR:
By using "call" as the method name and the structure of building the request in SoapClientRequest makeRequests() method (using getMethod() as __call()) it conflicts with the needed call() method in the magento1 soap api.
Using __soapCall() directly could prevent this:
$this->client()->__soapCall($this->getMethod(),$this->getBody());
Here are 2 examples which aren't working for me with the package at the moment:
1. Multiple parameters
Its similar to #42 but the provided solution in #45 does only work for objects, not for simple values.
To use the magento api I have to obtain a session token via the login soap method as described in the docs:
$session = $client->login('apiUser', 'apiKey');
The thing is, we can't use the magic __call() method from SoapClientRequest.php because its only using the first parameter.
$parameters[0] ?? []
A workaround for me is to use the call() method directly, but the problem is that it does not work, because then it wants to use the magic call method provided from magento1 instead of 'login' as the method name.
$params = array(
'username' => 'myusername',
'apiKey'=> 'myapiKey',
);
$session = $client->call('login', $params);
But even when I try the native SoapClient instead of the one from this package, it wont work because of some strange wsdl mapping.
Wrong Request (Array is bound to username and I can't figure out why):
<SOAP-ENV:Body>
<ns1:login>
<username xsi:type="xsd:string">Array</username>
<apiKey xsi:nil="true"/>
</ns1:login>
</SOAP-ENV:Body>
(And we can't use multiple params like suggested in the magento docs like described avobe)
The interesting thing is that using the __soapCall() method directly results in the wanted request:
$sessionToken = $client->__soapCall('login', $params);
RequestXML:
<SOAP-ENV:Body>
<ns1:login>
<username xsi:type="xsd:string">myusername</username>
<apiKey xsi:type="xsd:string">myapikey</apiKey>
</ns1:login>
</SOAP-ENV:Body>
Maybe I have to use better Soap Nodes to get the same result as with soapCall, but I couldn't figure it out.
2. magic __call vs __soapCall
Nonetheless here is another example why I can't using the soap method name like suggested with this soap package:
Magento1 Soap api uses the "call" method as a rpc method.
call(sessionId, resourcePath,array arguments) | Call the API resource that is allowed in the current session. See Note below.
In my case something like:
$data = array(
$sessionToken->response,
'sales_order.info',
'my-order-id',
);
$response = $client->call('call', $data);
But with this package it uses the "call" directly as the getMethod().
So I can't use something like:
$response = $client->call('call', $params);
because of the structure the request is done in SoapClientRequest.php
protected function makeRequest()
{
return $this->client()->{$this->getMethod()}($this->getBody());
}
what works for me is, when I change this to something like:
protected function makeRequest()
{
return $this->client()->__soapCall($this->getMethod(),$this->getBody());
}
I have also tested this change with the package and all tests went through. Even the skipped ones.
I think we just have to provide the options and headers again for the soapCall params:
https://www.php.net/manual/en/soapclient.soapcall.php
(I don't know they are still taken from the soapclient)
Edit: I can also confirm that Soap::fake() tests does still work when the change is applied
If wanted I can provide a pull request for this.
What are your thoughts about that?
Trying to do this call using this package:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<data:GetVersion xmlns:data="http://www.skidata.com/interfaces/common/v1/data"/>
</soapenv:Body>
</soapenv:Envelope>
How do I do xmlns:data="http://www.skidata.com/interfaces/common/v1/data"
?
I have this so far:
use RicorocksDigitalAgency\Soap\Facades\Soap;
Soap::to('https://hb.usa.skidata.com/bei/ParkingCounterServiceInterface')
->withBasicAuth('xxxx', 'yyy')
->withOptions([
'SOAPAction' => 'http://www.skidata.com/interfaces/parking/counter/v2/GetVersion'
])->GetVersion();
But it throws an error:
PHP Warning: SoapClient::__construct(https://hb.usa.skidata.com/bei/ParkingCounterServiceInterface): Failed to open stream: HTTP request failed! HTTP/1.1 405 Method Not Allowed
in /Users/erin/Sites/sacair/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 915
PHP Warning: SoapClient::__construct(): I/O warning : failed to load external entity "https://hb.usa.skidata.com/bei/ParkingCounterServiceInterface" in /Users/erin/Sites/sacair/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 915
SoapFault with message 'SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://hb.usa.skidata.com/bei/ParkingCounterServiceInterface' : failed to load external entity "https://hb.usa.skidata.com/bei/ParkingCounterServiceInterface"
$soap = Soap::to('https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL');
$response = $soap->call('NumberToWords', ['ubiNum' => 10]);
$this->info($response->NumberToWordsResult);
$response = $soap->call('NumberToWords', ['ubiNum' => 20]);
$this->info($response->NumberToWordsResult);
This code writes out:
ten
ten
I expected:
ten
twenty
Native SoapClient does not cache response ( it writes ten twenty ):
$soap = new \SoapClient('https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL');
$response = $soap->__soapCall('NumberToWords', [['ubiNum' => 10]]);
$this->info($response->NumberToWordsResult); // ten
$response = $soap->__soapCall('NumberToWords', [['ubiNum' => 20]]);
$this->info($response->NumberToWordsResult); //twenty
What are reasons to cache the response?
I get expected, when I override the getResponse method, like this:
protected function getResponse()
{
// return $this->response ??= $this->getRealResponse();
return $this->getRealResponse();
}
Is it safe to do that?
Thanks, Ognjen
I want to add client ip. My request body, schema and response is below.
Request:
$response = Soap::to('url')
->call('CommitPurchase', [
'CommitPurchaseRequest' => [
'transaction_header' => [
'client_id' => 123,
'request_datetime' => '2021-04-27T11:16:53',
'request_reference_no' => 123,
'send_sms' => 'N',
'send_sms_language' => 'xx',
],
'transaction_body' => [
'amount' => 1000,
'macro_merchant_id' => x,
'order_no' => xx,
'payment_type' => 'xx',
'token' => xx,
],
]
]);
Schema:
<CommitPurchaseRequest
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://phaymobile.cardtekgroup/Tmm/RemotePurchaseP2M">
<transaction_header>
<client_id
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes">................
</client_id>
<request_datetime
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes">2015-10-15T09:09:53
</request_datetime>
<request_reference_no
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes">444900193670
</request_reference_no>
<send_sms
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes">N
</send_sms>
<send_sms_language
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes">tur
</send_sms_language>
<client_token xsi:nil="true"
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />
<device_fingerprint xsi:nil="true"
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />
<version xsi:nil="true"
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />
<ip_address xsi:nil="true"
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />
<client_type xsi:nil="true"
xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />
</transaction_header>
<transaction_body>
<amount>300</amount>
<macro_merchant_id>.........</macro_merchant_id>
<order_no>44490.......</order_no>
<payment_type>DIRECT_PAYMENT</payment_type>
<token>37AD60A2F1D0DE40D050D442C3BC7E3FC1C65B7443E.......</token>
<custom_fields xsi:nil="true" />
</transaction_body>
</CommitPurchaseRequest>
Response:
Client Ip not found!
I try in call function:
'transaction_header' => [
'client_id' => 34701630,
'request_datetime' => '2021-04-27T11:16:53',
'request_reference_no' => $request->input('referenceNo'),
'send_sms' => 'N',
'send_sms_language' => 'tur',
'<client_token xsi:nil="true" xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />',
'<device_fingerprint xsi:nil="true" xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />',
'<version xsi:nil="true" xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />',
'<ip_address xsi:nil="true" xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />',
'<client_type xsi:nil="true" xmlns="http://phaymobile.cardtekgroup/Tmm/CommonTypes" />'
],
Hi there,
I'm trying to create a node with attributes and just a value as body.
Like this
<Test a="b"> 123 </Test>
I'm getting pretty far with the following code:
$testNode = soap_node(["a" => "b"])->body([$value]);
However when I'm sending my request to my endpoint the value is omitted.
<Test a="b"/>
First off, it might be nice to have a XML debug function before we send the message that just outputs the raw XML. It's hard to determine if my endpoint omits the value or the package.
Second off, is it even possible to just use a value as body?
If so, how should the code be formatted?
Laravel 8.46.0
PHP 7.4.18
Package 1.3.0
Error 1: Unresolvable dependency resolving [Parameter #3 [ <optional> $mustunderstand ]] in class SoapHeader {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #3 [ <optional> $mustunderstand ]] in class SoapHeader at /var/www/magnum/vendor/laravel/framework/src/Illuminate/Container/Container.php:1067)
Error 1 Quick Fix: \ricorocks-digital-agency\soap\src\Request\SoapClientRequest.php:100 replace mustUnderstand to mustunderstand...
Error 2: Soap header throw error when actor
is null...
Error 2 Quick Fix: Add actor to header
The is any plan to support laravel 10?
Hi there,
please help me, when i use this package to call soap API to return a response as XML data.
example as follow:
$response = Soap::to('myapiservicepoint.asmx?WSDL')
->call('method_name');
How when I tried to convert this response to string like this simplexml_load_string((string)$customers) so that I could use it as json it give me an error
please help
Hello, after install I got this error:
In SoapServiceProvider.php line 17:
syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')'
Then I changed
$this->app->singleton('soap', fn () => app(Soap::class));
to
$this->app->singleton('soap', function () {
app(Soap::class);
});
This resolves issue but I. think only until I update composer
php -v
PHP 7.3.27 (cli) (built: Feb 4 2021 12:13:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
php artisan --version
Laravel Framework 8.47.0
I just got started using this and I'm not exactly sure what I did wrong. I installed it as per instructions but calling the facade gets me this error:
In Container.php line 838:
Target class [soap] does not exist.
In Container.php line 836:
Class soap does not exist
I tried running composer dump-autoload
to rule out autoloading issues and it's still getting that error. At this point, I'm not sure what exactly I'm missing.
I'm using Lumen 8.0 with php 7.4 if it matters.
What is the format of the response from a basic soap request?
$response = Soap::to('url')->call('method', [...$params]); // Is the response object an array, xml, json...?
Hello
with the laravel 11 i get this error message could you please fix it?
Problem 1
- Root composer.json requires laravel/framework ^11.0.6 -> satisfiable by laravel/framework[v11.0.6].
- ricorocks-digital-agency/soap v1.7.0 requires illuminate/support ^8.16|^9.0|^10.0 -> satisfiable by illuminate/support[v8.16.0, ..., v8.83.27, v9.0.0, ..., v9.52.16, v10.0.0, ..., v10.48.3].
- Only one of these can be installed: illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16, v10.0.0, ..., v10.48.3, v11.0.0, ..., v11.0.6], laravel/framework[v11.0.6]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
- Root composer.json requires ricorocks-digital-agency/soap ^1.7 -> satisfiable by ricorocks-digital-agency/soap[v1.7.0].
Hi, and thank you for this great library.
Unfortunately, I would need suppport to SoapHeader
, to set an authentication header, but, I'm not able to manage it with this facade.
Is there any way to get it?
The final result on XML should be:
<soap:Header>
<AuthHeader xmlns=".../">
<Username>user</Username>
<Password>password</Password>
</AuthHeader>
</soap:Header>
Thank you in advance
Hi,
If your service SOAP WSLD show this error:
SOAP-ERROR: Parsing WSDL: Couldn't load from '<MY_SOAP_URL> : failed to load external entity "<MY_SOAP_URL>"
Don't worry is normal IF You don't configure or renew the SSL (https) for the domain or ip.
In base of the answer:
There is a difference between soap headers and HTTP headers.
In this case you are trying to set SOAP headers.You could try to add the header by using a
stream_context
through theSoapClient
's$options
.
See https://www.php.net/manual/en/context.http.php
But I think that context is not being used by the SoapClient for fetching the WSDL.Leaving you with the option to either download the file(s) locally or fetch it dynamically (with curl or a stream wrapper).
Originally posted by @veewee in #38 (comment)
To fix this problem you only need to do it this:
// Libraries
use GuzzleHttp\RedirectMiddleware;
use RicorocksDigitalAgency\Soap\Facades\Soap;
// Vars
$urlWSDL = '';
$method = '';
$params = [];
// SSL Configuration (SSL: Off)
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$client = Soap::to($urlWSDL)
->withOptions([
// Complement (Optional)
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
'verify' => false,
'cookies' => false,
'idn_conversion' => false,
// SSL Configuration
'stream_context' => $context,
])
->call($method, $params);
And now only need try again :D ๐
Note: In Curl the same process is with the flag -k
for more information.
I'm not sure if this is the right place to post this, but I'm having an issue translating an XML soap request into the format required by this package.
I was hoping if I posted the XML below, someone might be willing to reply with the correct code to send the Soap request using this package?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.id3global.com/ID3gWS/2013/04">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns:AuthenticateSP>
<ns:ProfileIDVersion>
<ns:ID>12345</ns:ID>
<ns:Version>0</ns:Version>
</ns:ProfileIDVersion>
<ns:CustomerReference>test</ns:CustomerReference>
<ns:InputData>
<ns:Personal>
<ns:PersonalDetails>
<ns:Forename>test</ns:Forename>
<ns:Surname>test</ns:Surname>
<ns:DOBDay>01</ns:DOBDay>
<ns:DOBMonth>01</ns:DOBMonth>
<ns:DOBYear>1991</ns:DOBYear>
</ns:PersonalDetails>
</ns:Personal>
<ns:Addresses>
<ns:CurrentAddress>
<ns:Country>test</ns:Country>
<ns:Street>test</ns:Street>
<ns:City>test</ns:City>
<ns:ZipPostcode>test</ns:ZipPostcode>
<ns:Building>1</ns:Building>
</ns:CurrentAddress>
</ns:Addresses>
</ns:InputData>
</ns:AuthenticateSP>
</soapenv:Body>
</soapenv:Envelope>
This is what I currently have:
$header = Soap::header()
->name("Security")
->namespace("http://www.id3global.com/ID3gWS/2013/04")
->data([
"UsernameToken" => [
"Username" => $this->username,
"Password" => $this->password,
],
])
->mustUnderstand();
$params = [
"ProfileIDVersion" => [
"ID" => "12345",
"Version" => 0,
],
"InputData" => [
"Personal" => [
"PersonalDetails" => [
"Forename" => "Shenol",
"Surname" => "Hoines",
"DOBDay" => 28,
"DOBMonth" => 4,
"DOBYear" => 1984,
],
],
"Addresses" => [
"CurrentAddress" => [
"Country" => "test",
"Street" => "test",
"City" => "test",
"ZipPostcode" => "test",
"Building" => "1",
],
],
],
];
return Soap::to($this->url)->withHeaders($header)->call("AuthenticateSP", $params)->response;
It keeps returning this error: SoapFault with message 'An error occurred when verifying security for the message.'
Any help would be greatly appreciated.
First of all your package looks amazing. I want to try.
I just wonder if does it support wsdl? I need to load wsdl stored locally or either grab wsdl from an url.
I'm integrating with a 3rd party SOAP API that requires a wsse Username Token in the header. Is there a way within this facade to generate that or a recommended approach? I'm not seeing anything in the docs.
Home make some Soap Call?:
$soap->call('SubmitQuote', [ 'Products' => [ 'Product' => [], 'Product' => [], 'Product' => [] ] ]);
I have issue with multiple parameters in soap function call. I can assign parameters as objects to function and using native SoapClient I can create working request like this:
$soapClient = New SoapClient($this->baseURL, $options);
$response = $soapClient->my_method($apiKeys, $files);
Now, with Soap::to this is not possible as __call()
accepts only first parameter resulting xml missing files
part. This is how I thought it should work:
$response = Soap::to($this->baseURL)->my_method($apiKeys, $files);
Also notice, that $apiKeys and $files are objects:
class ApiKeys
{
protected $user_api_key = null;
protected $vendor_api_key = null;
protected $company_uuid = null;
public function __construct($user_api_key = null, $vendor_api_key = null, $company_uuid = null)
{
$this->user_api_key = $user_api_key;
$this->vendor_api_key = $vendor_api_key;
$this->company_uuid = $company_uuid;
}
}
class Files
{
protected $files = null;
protected $filenames = null;
public function __construct($files = null, $filenames = null)
{
$this->files = $files;
$this->filenames = $filenames;
}
}
And here is the wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="MyTestWsdl" targetNamespace="https://my_test.test/" xmlns:typens="https://my_test.test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="https://my_test.test/">
<xsd:complexType name="ApiKeys">
<xsd:all>
<xsd:element name="user_api_key" type="xsd:string"/>
<xsd:element name="vendor_api_key" type="xsd:string"/>
<xsd:element name="company_uuid" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="Files">
<xsd:all>
<xsd:element name="filenames" type="typens:StringArray"/>
<xsd:element name="files" type="typens:ActionWebService..Base64Array"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<message name="api-my_method">
<part name="api_keys" type="typens:ApiKeys"/>
<part name="files_in" type="typens:Files"/>
</message>
<message name="api-my_methodResponse">
<part name="return" type="typens:InvoiceStatus"/>
</message>
<portType name="ApiPort">
<operation name="my_method">
<input message="typens:api-my_method"/>
<output message="typens:api-my_methodResponse"/>
</operation>
</portType>
<binding name="ApiBinding" type="typens:ApiPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="my_method">
<soap:operation soapAction="/api/my_method"/>
<input>
<soap:body use="encoded" namespace="https://my_test.test/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="https://my_test.test/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="Service">
<port name="ApiPort" binding="typens:ApiBinding">
<soap:address location="https://my_test.test/"/>
</port>
</service>
</definitions>
Here is expected soap request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://my_test.test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:my_method>
<api_keys xsi:type="ns1:ApiKeys">
<user_api_key xsi:type="xsd:string">00000000-1111-2222-3333-444444444444</user_api_key>
<vendor_api_key xsi:type="xsd:string">00000000-1111-2222-3333-444444444444</vendor_api_key>
<company_uuid xsi:type="xsd:string">00000000-1111-2222-3333-444444444444</company_uuid>
</api_keys>
<files_in xsi:type="ns1:Files">
<filenames SOAP-ENC:arrayType="xsd:string[1]" xsi:type="ns1:StringArray">
<item xsi:type="xsd:string">file.xml</item>
</filenames>
<files SOAP-ENC:arrayType="xsd:string[1]" xsi:type="ns1:ActionWebService..Base64Array">
<item xsi:type="xsd:string">PD94bWw/PjxGaW52b2ljZT48L0ZpbnZvaWNlPg==</item>
</files>
</files_in>
</ns1:my_method>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Is it possible to add support for multiple parameters (not just array) in __call
method to make it work more like php's native SoapClient function call?
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.