0

I am trying to create a web service in Symfony. I have looked at these webs, and tried them all, but they do not work for me.

http://besim.pl/SoapBundle/soapserver/configuration.html

http://barandigoyen.wordpress.com/2012/07/13/como-implementar-un-web-service-wsdl-en-symfony-2/

Could anyone explain the process better, step by step, please?

Thanks a lot!!!

EDITED: The steps I have followed are:

1) Added the following to composer.json

"require":{
...
        "besimple/soap-bundle": "dev-master",
        "besimple/soap-common": "dev-master",
        "ass/xmlsecurity":      "dev-master",
        "besimple/soap-server": "dev-master",
        "besimple/soap-client": "dev-master"
...
}

2) Run the following:

$ php composer.phar self-update
$ php composer.phar update

3) Added the following to app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new BeSimple\SoapBundle\BeSimpleSoapBundle(),
        // ...
    );
}

4) Added the followin to app/config/config.yml

be_simple_soap:
cache:
    type:     disk
    lifetime: 86400
    limit:    5
services:
    AplicationService:
        namespace:      http://localhost/myproject/web/app_dev.php/ws/AplicationService
        binding:        rpc-literal
        resource:       “@StaticBundle/Controller/WebServiceController.php“
        resource_type:  annotation

5) Added the following to app/config/routing.yml

_besimple_soap:
    resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
    prefix:   /ws

6) Create the following Controller in StaticBundle

namespace myproject\StaticBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class WebServiceController extends Controller
{
    /**
     * @Soap\Method("hello")
     * @Soap\Param("name", phpType = "string")
     * @Soap\Result(phpType = "string")
     */
    public function helloAction($name)
    {
        return sprintf('Hello %s!', $name);
    }

    /**
     * @Soap\Method("goodbye")
     * @Soap\Param("name", phpType = "string")
     * @Soap\Result(phpType = "string")
     */
    public function goodbyeAction($name)
    {
        return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Goodbye %s!', $name));
    }
}

7) Access to localhost/myproject/web/app_dev.php/ws/AplicationService?wsdl and get a xml with error code 500.

4
  • can you provide your code ?? Else we cannot help you ! Commented Jul 18, 2014 at 9:07
  • I have edited it. Is it ok now to answer? Thanks. Commented Jul 18, 2014 at 11:30
  • have you added something in the security.yml ? Commented Jul 18, 2014 at 12:03
  • nothing for this purpose. Do I have to add anything? Commented Jul 18, 2014 at 12:20

2 Answers 2

1

Well, checking the logs I found the cause of this issue: correct the double quotes of the config.yml:

resource:       "@StaticBundle/Controller/WebServiceController.php"

their example has weird double quotes ;)

Sign up to request clarification or add additional context in comments.

Comments

0

In step 6 it appears you are missing the use statement for Soap in your annotation. http://besim.pl/SoapBundle/soapserver/configuration.html#annotations-for-controllers

try:

namespace myproject\StaticBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

class WebServiceController extends Controller
{
    /**
     * @Soap\Method("hello")
     * @Soap\Param("name", phpType = "string")
     * @Soap\Result(phpType = "string")
     */
    public function helloAction($name)
    {
        return sprintf('Hello %s!', $name);
    }

    /**
     * @Soap\Method("goodbye")
     * @Soap\Param("name", phpType = "string")
     * @Soap\Result(phpType = "string")
     */
    public function goodbyeAction($name)
    {
        return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Goodbye %s!', $name));
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.