Go to file
Francis Besset b843acbec7 Replaced zf2 by zend-soap and zend-mime of BeSimple Repository 2011-08-07 11:33:34 +02:00
Controller New definition of complex type 2011-07-23 21:24:59 +02:00
Converter Replaced Bundle\WebServiceBundle by BeSimple\SoapBundle 2011-07-18 22:43:12 +02:00
DependencyInjection Simplified the creation of WebServiceContext 2011-07-21 22:55:59 +02:00
Resources [Doc] Moved array in first tutorial 2011-08-04 10:57:41 +03:00
ServiceBinding Added recursion of types in RpcLiteralResponseMessageBinder 2011-07-28 00:39:19 +02:00
ServiceDefinition New definition of complex type 2011-07-23 21:24:59 +02:00
Soap Replaced Bundle\WebServiceBundle by BeSimple\SoapBundle 2011-07-18 22:43:12 +02:00
Tests Replaced zf2 by zend-soap and zend-mime of BeSimple Repository 2011-08-07 11:33:34 +02:00
Util Fixed typo in Util\Collection 2011-07-24 14:41:59 +02:00
.gitignore Replaced webservice.* service name by besimple.soap.* 2011-07-18 22:59:20 +02:00
BeSimpleSoapBundle.php Replaced Bundle\WebServiceBundle by BeSimple\SoapBundle 2011-07-18 22:43:12 +02:00
CONTRIBUTORS.markdown Added Contributors file 2011-07-17 19:46:43 +02:00
README.markdown Simplified exposure functions in README 2011-07-21 20:53:49 +02:00
WebServiceContext.php New definition of complex type 2011-07-23 21:24:59 +02:00
phpunit.xml.dist Replaced zf2 by zend-soap and zend-mime of BeSimple Repository 2011-08-07 11:33:34 +02:00
vendors.php Replaced zf2 by zend-soap and zend-mime of BeSimple Repository 2011-08-07 11:33:34 +02:00

README.markdown

BeSimpleSoapBundle

The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services. It is based on the [ckWebServicePlugin] 1 for symfony.

Requirements

  • Install and enable PHP's SOAP extension

  • Download Zend\Soap

     git submodule add http://github.com/zendframework/zf2.git vendor/zend-framework
    
  • Add Zend\Soap library to app/autoload.php

     // app/autoload.php
     $loader->registerNamespaces(array(
         'Zend\\Soap' => __DIR__.'/../vendor/zend-frameword/library',
         // your other namespaces
     ));
    

QuickStart

  • Put BeSimpleSoapBundle in your vendor/bundles/BeSimple dir

    git submodule add https://github.com/BeSimple/BeSimpleSoapBundle.git vendor/bundles/BeSimple/SoapBundle
    
  • Enable BeSimpleSoapBundle in your app/AppKernel.php

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new new BeSimple\SoapBundle\BeSimpleSoapBundle(),
            // ...
        );
    }
    
  • Register the BeSimple namespace

    // app/autoload.php
    $loader->registerNamespaces(array(
        'BeSimple'   => __DIR__.'/../vendor/bundles',
        'Zend\\Soap' => __DIR__.'/../vendor/zend-frameword/library',
        // your other namespaces
    ));
    
  • Include the BeSimpleSoapBundle's routing configuration in app/config/routing.yml (you can choose the prefix arbitrarily)

    _besimple_soap:
        resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
        prefix:   /ws
    
  • Configure your first web service in app/config/config.yml

    be_simple_soap:
        services:
            DemoApi:
                namespace:     http://mysymfonyapp.com/ws/DemoApi/1.0/
                binding:       rpc-literal
                resource:      "@AcmeDemoBundle/Controller/DemoController.php"
                resource_type: annotation
    
  • Annotate your controller methods

    // src/Acme/DemoBundle/Controller/DemoController.php
    use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
    use BeSimple\SoapBundle\Soap\SoapResponse;
    
    class DemoController extends Controller
    {
        /**
         * @Soap\Method("Hello")
         * @Soap\Param("name", phpType = "string")
         * @Soap\Result(phpType = "string")
         */
        public function helloAction($name)
        {
            return new SoapResponse(sprintf('Hello %s!', $name));
        }
    }
    
  • Open your web service endpoint

    • http://localhost/app_dev.php/ws/DemoApi - HTML documentation
    • http://localhost/app_dev.php/ws/DemoApi?wsdl - WSDL file

Test

phpunit -c phpunit.xml.dist