Developed with love by KnpLabs Hire us for your project!
25

LiipSoapRecorderBundle

by liip

Recorder/Player for SOAP communications

LiipSoapRecorderBundle Build Status

This bundle provide an easy way to record SOAP communications. Typical usage could be:

  • Generating a set of fixtures for functional test writing
  • Recording a scenario and being able to replay it
  • Mocking the webservice to work offline
  • ...

Installation

  1. Install this bundle like any other SF2 bundle (Composer or git submodule install + Enable it in the kernel)
  2. Replace the base class SoapClient by the new Liip\SoapRecorderBundle\Client\RecordableSoapClient

Configuration

By default the bundle does nothing, to activate it, you just need to configure it:

liip_soap_recorder:
    record:          true                 # boolean, activate or not the recording
    fetching_mode:   local_first          # can be remote, local_first or local_only
    request_folder:  /tmp/soap_request    # where to store the XML request
    response_folder: /tmp/soap_response   # where to store the XML response
    wsdl_folder:     /tmp/soap_wsdl       # where to store the WSDL of the webservice
    enable_profiler: true                 # boolean, active or not the profiler
    die_on_error:    false

Usage

To use the bundle, you can play with some config parameters:

  • record can be set to
    • true: to start communication recording
    • false: to stop it
  • fetching_mode can be set to:
    • remote: Always fetch response from the WebService
    • local_only: Always fetch response from the local recording
    • local_first: Try to fetch locally, and if not recorded yet, fetch to the WebService
  • enable_profiler can be set to:
    • true: to display SOAP records in the Symfony2 Profiler. It will delete the recorded files from the directories.
    • false: to keep the files in the directories without using the Symfony2 Profiler.
  • die_on_error can be used to define the behaviour in case you are in local_only and a record is missing:
    • false: Normal behavior, will throw an exception
    • true: Will die() with an explicit message, this is useful on Symfony2 where sometimes the generated exception is replace by an AccessDeniedException who masked the original one

Usage outside Symfony2

The heart of the bundle is the class Liip\SoapRecorderBundle\Client\RecordableSoapClient. This class is
independent, so you can use it outside of the Bundle, in any PHP 5.3 project:

  1. Replace your base class SoapClient by the new Liip\SoapRecorderBundle\Client\RecordableSoapClient
  2. Start recording by calling:
   RecordableSoapClient::setRecordFolders('/tmp/request', '/tmp/response', '/tmp/wsdl');
   RecordableSoapClient::startRecording();
   // Call your webservice like usual`
  1. Start playing your records
   RecordableSoapClient::setFetchingMode(RecordableSoapClient::FETCHING_LOCAL_FIRST);
   // Call your webservice like usual

Contributing

If you would like to contribute, just go on the project page: https://github.com/liip/LiipSoapRecorderBundle, fork it
and providing PRs.

This project comes with a functional test suite, just read the Tests/README.md for more information.

Travis CI is also running for continuous integration tests: Build Status

Requirements

PHP 5.3

Authors

License

LiipSoapRecorderBundle is licensed under the MIT License - see the LICENSE file for details

Copyright (c) David Jeanmonod - Liip AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
soap_recorder:
record: false
fetching_mode: remote
request_folder: ~
response_folder: ~
wsdl_folder: ~
enable_profiler: false
die_on_error: false
  • small code cleanup
    By , 4 years ago
  • Merge pull request #11 from gnutix/master
    By sitron, 4 years ago
  • Ensure there's a new line at the end of recorded XML files
    By gnutix, 4 years ago
  • Auto publish new release (tag included)
    By jeanmonod, 4 years ago
  • Release of new version 0.9.8
    By jeanmonod, 4 years ago
  • Fix the CHANGELOG (was brocken due to RMT)
    By jeanmonod, 4 years ago
  • 2.3 compatibility
    By lsmith77, 4 years ago
  • handle case when paths are empty
    By lsmith77, 4 years ago
  • Release of new version 0.9.7
    By jeanmonod, 4 years ago
  • Merge pull request #10 from liip/cleanups
    By jeanmonod, 4 years ago
  • various cleanups, automatically create cache folders
    By lsmith77, 4 years ago
  • Release of new version 0.9.6
    By jeanmonod, 4 years ago
  • Merge pull request #9 from liip/add-wsdl-http-authentication
    By jeanmonod, 4 years ago
  • Merge pull request #8 from liip/fix-spelling-error
    By jeanmonod, 4 years ago
  • added method to use basic auth to get the wsdl
    By , 4 years ago
  • fix spelling error in sample configuration
    By waldvogel, 4 years ago
  • Release of new version 0.9.5
    By jeanmonod, 4 years ago
  • Release of new version 0.9.4
    By jeanmonod, 4 years ago
  • Merge pull request #5 from jeanmonod/die_on_error
    By jeanmonod, 4 years ago
  • Merge pull request #4 from jeanmonod/change-sequence-in-recording
    By jeanmonod, 4 years ago
  • Merge pull request #7 from jeanmonod/data-collector-refacoring
    By jeanmonod, 4 years ago
  • Merge pull request #6 from jeanmonod/icons
    By jeanmonod, 4 years ago
  • Variable renaming in the data collector
    By jeanmonod, 4 years ago
  • Add icons in the profiler
    By jeanmonod, 4 years ago
  • DataCollector, ignore folder and hidden files in collecting, code simplification
    By jeanmonod, 4 years ago
  • Record the request before the SOAP call
    By jeanmonod, 4 years ago
  • New die_on_error parameter
    By jeanmonod, 4 years ago
  • Release of new version 0.9.3
    By jeanmonod, 4 years ago
  • Fix of the composer install
    By jeanmonod, 4 years ago
  • Code review over PR3
    By jeanmonod, 4 years ago