## Getting Started
This package (`cleverage/soap-process-bundle`) simplifies SOAP service integration in Laravel/Symfony applications. For **v3.0**, ensure your environment meets the new **PHP 8.5** and **Symfony 8** requirements before installation.
1. **Installation**:
```bash
composer require cleverage/soap-process-bundle
For Laravel, publish the config:
php artisan vendor:publish --provider="Cleverage\SoapProcessBundle\SoapProcessBundle"
config/soap_process.php:
'clients' => [
'example' => [
'wsdl' => 'https://example.com/soap?wsdl',
'options' => [
'trace' => true,
'exceptions' => true,
],
],
],
Inject the client into a service and call SOAP methods:
use Cleverage\SoapProcessBundle\Client\ClientInterface;
public function __construct(private ClientInterface $soapClient) {}
public function callSoapService() {
$result = $this->soapClient->call('example', 'MethodName', ['arg1' => 'value']);
return $result;
}
Leverage Laravel/Symfony’s DI container to inject ClientInterface into services:
// Laravel (Service Provider)
$this->app->bind(ClientInterface::class, function ($app) {
return $app->make('cleverage.soap_process.client');
});
Centralize SOAP endpoints in config/soap_process.php for maintainability:
'clients' => [
'inventory' => [
'wsdl' => env('SOAP_INVENTORY_WSDL'),
'options' => [
'login' => env('SOAP_USERNAME'),
'password' => env('SOAP_PASSWORD'),
],
],
],
Use try-catch with SoapFault for robust error handling:
try {
$response = $this->soapClient->call('example', 'GetData');
} catch (SoapFault $fault) {
Log::error("SOAP Error: {$fault->getMessage()}");
throw new \RuntimeException('SOAP service unavailable');
}
Mock SOAP responses in tests using Laravel’s HTTP testing or PHPUnit:
// Example: Mocking a SOAP response
$mockHandler = $this->getMockBuilder(SoapClient::class)
->disableOriginalConstructor()
->onlyMethods(['__doRequest'])
->getMock();
$mockHandler->method('__doRequest')->willReturn('<soap:Envelope>...</soap:Envelope>');
$this->soapClient->setClient($mockHandler);
v2.x if needed.
composer require php:^8.5 and update Symfony to ^8.0.php artisan cache:clear
options:
'options' => [
'local_cert' => 'path/to/cert.pem',
'passphrase' => 'cert_password',
],
'trace' => true to client options to log raw SOAP requests/responses in Laravel logs.DOMDocument to validate SOAP responses:
$dom = new DOMDocument();
$dom->loadXML($response);
if ($dom->schemaValidate('schema.xsd')) { ... }
config('soap_process.clients.example.wsdl') with environment variables:
'wsdl' => env('SOAP_EXAMPLE_WSDL', 'default.wsdl'),
Cleverage\SoapProcessBundle\Client\Client to add pre/post-processing logic.Psr\Log\LoggerInterface to cleverage.soap_process.logger.
NO_UPDATE_NEEDED would **not** apply here due to the breaking changes and new features.
How can I help you explore Laravel packages today?