Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Soap Bundle Laravel Package

besimple/soap-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require besimple/soap-bundle
    

    Enable the bundle in config/bundles.php:

    return [
        // ...
        BeSimple\SoapBundle\BeSimpleSoapBundle::class => ['all' => true],
    ];
    
  2. First Use Case: Consuming a SOAP Service Define a client in config/packages/besimple_soap.yaml:

    besimple_soap:
        clients:
            example:
                wsdl: "http://example.com/service?wsdl"
                options:
                    trace: true
                    exceptions: true
    

    Use the client in a service/controller:

    use BeSimple\SoapBundle\Client\SoapClient;
    
    public function callService(SoapClient $client)
    {
        $result = $client->call('ServiceMethod', ['param1' => 'value']);
        return $result;
    }
    
  3. First Use Case: Exposing a SOAP Service Define a server in config/packages/besimple_soap.yaml:

    besimple_soap:
        servers:
            example:
                uri: "/soap"
                class: "AppBundle\Service\SoapService"
                options:
                    classmap: ["AppBundle\\"]
    

    Implement a service class:

    namespace AppBundle\Service;
    
    class SoapService
    {
        public function someMethod($param1) {
            return "Processed: " . $param1;
        }
    }
    

Implementation Patterns

Consuming SOAP Services

  1. Dependency Injection Inject SoapClient into controllers/services:

    public function __construct(SoapClient $client) {
        $this->client = $client;
    }
    
  2. Dynamic WSDL Loading Load WSDL dynamically in runtime:

    $client = $this->get('besimple_soap.client.example');
    $client->setWsdl('http://new-service.com?wsdl');
    
  3. Error Handling Use exceptions: true in config to throw SOAP faults as exceptions:

    try {
        $result = $client->call('FaultyMethod');
    } catch (\SoapFault $fault) {
        // Handle error
    }
    
  4. Logging Enable trace: true for debugging:

    options:
        trace: true
    

Exposing SOAP Services

  1. Class Mapping Use classmap to auto-discover methods:

    options:
        classmap: ["AppBundle\\"]
    
  2. Custom Logic Implement BeSimple\SoapBundle\Server\ServerInterface for advanced use cases.

  3. Security Secure endpoints with Symfony’s security system (e.g., @IsGranted annotations).

  4. Performance Cache WSDL responses if static:

    options:
        cache_wsdl: true
    

Gotchas and Tips

Pitfalls

  1. WSDL Caching

    • Disable cache_wsdl if WSDL changes frequently.
    • Clear cache after updates:
      php bin/console cache:clear
      
  2. Namespace Conflicts

    • Ensure SOAP method names don’t clash with PHP reserved keywords (e.g., new, return).
    • Use underscores or prefixes if needed.
  3. Large Payloads

    • Increase soap.wsdl_cache and soap.wsdl_cache_dir limits in php.ini if handling large WSDLs.
  4. Debugging

    • Enable trace: true and check Symfony logs for raw SOAP requests/responses:
      php bin/console debug:container | grep besimple_soap
      

Tips

  1. Type Hints Use PHP 7.4+ return type hints for SOAP responses:

    public function getUserData(): array {
        return $this->client->call('GetUser', ['id' => 1]);
    }
    
  2. Testing Mock SoapClient in PHPUnit:

    $mock = $this->createMock(SoapClient::class);
    $mock->method('call')->willReturn(['data' => 'test']);
    $this->container->set('besimple_soap.client.example', $mock);
    
  3. Documentation Generate WSDL docs with besimple_soap.wsdl_generator:

    besimple_soap:
        wsdl_generator:
            enabled: true
            output_dir: "%kernel.project_dir%/var/cache/wsdl"
    
  4. Extensions Extend BeSimple\SoapBundle\Client\SoapClient for custom logic (e.g., headers, namespaces):

    class CustomSoapClient extends SoapClient {
        public function addHeader($header) {
            $this->__setSoapHeaders([new SoapHeader(null, $header)]);
        }
    }
    
  5. Symfony 5+ Compatibility

    • Use autoconfigure: false in bundles.php if encountering autowiring issues:
      BeSimple\SoapBundle\BeSimpleSoapBundle::class => ['all' => true, 'autoconfigure' => false],
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope