PHP code example of codebach / soap

1. Go to this page and download the library: Download codebach/soap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codebach / soap example snippets


use FooBundle\Server\SoapRequest;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    /**
     * @Soap\Method("soapRequest")
     * @Soap\Param("request", phpType = "FooBundle\Server\SoapRequest")
     * @Soap\Result("soapResponse", phpType = "FooBundle\Server\SoapResponse")
     */
    public function soapRequestAction(SoapRequest $request)
    {
    }
}

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

/**
 * @Soap\Alias("Bar")
 * @Soap\Type("ns3")
 */
class Bar
{
    /**
     * @var string
     *
     * @Soap\ComplexType("string")
     */
    private $value;

    /**
     * @return string
     */
    public function getValue(): string
    {
        return $this->value;
    }

    /**
     * @param string $value
     */
    public function setValue(string $value)
    {
        $this->value = $value;
    }
}

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

/**
 * @Soap\Alias("Foo")
 * @Soap\Type("ns2")
 */
class Foo
{
    /**
     * @var Bar
     *
     * @Soap\ComplexType("FooBundle\Server\Bar", target="ns3")
     */
    private $bar;

    /**
     * @return Bar
     */
    public function getBar(): Bar
    {
        return $this->bar;
    }

    /**
     * @param Bar $bar
     */
    public function setBar(Bar $bar)
    {
        $this->bar = $bar;
    }
}


use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

/**
 * @Soap\Alias("SoapRequest")
 *
 * Default namespace is ns1
 */
class SoapRequest
{
    /**
     * @var Foo
     *
     * @Soap\ComplexType("FooBundle\Server\Foo", target="ns2")
     */
    private $foo;

    /**
     * @return Foo
     */
    public function getFoo(): Foo
    {
        return $this->foo;
    }

    /**
     * @param Foo $foo
     */
    public function setFoo(Foo $foo)
    {
        $this->foo = $foo;
    }
}