Soap client call SOAP server method and returns NOT found in Symfony3

I have my first example of Soap server made in symfony3.

This is my WSDL:

<definitions name="StackOverFlowerService"
         targetNamespace="http://localhost/stackoverflower/soap/stackoverflower.wsdl"
         xmlns="http://schemas.xmlsoap.org/wsdl/"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:tns="http://localhost/stackoverflower/soap/stackoverflower.wsdl"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<message name="NewRequest">
    <part name="name" type="xsd:string"/>
</message>

<message name="NewResponse">
    <part name="status" type="xsd:string"/>
</message>

<message name="getListRequest"></message>

<message name="getListResponse">
    <part name="list" type="xsd:string"/>
</message>

<portType name="StackOverFlower_PortType">
    <operation name="newStack">
        <input message="tns:NewRequest"/>
        <output message="tns:NewResponse"/>
    </operation>
    <operation name="getList">
        <input message="tns:getListRequest"/>
        <output message="tns:getListResponse"/>
    </operation>
</portType>

<binding name="StackOverFlower_Binding" type="tns:StackOverFlower_PortType">
    <soap:binding style="rpc"
                  transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="newStack">
        <soap:operation soapAction="newStack"/>
        <input>
            <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:uniski:new"
                    use="encoded"/>
        </input>

        <output>
            <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:uniski:new"
                    use="encoded"/>
        </output>
    </operation>

    <operation name="getList">
        <soap:operation soapAction="getList"/>
        <input>
            <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:uniski:get-list"
                    use="encoded"/>
        </input>

        <output>
            <soap:body
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    namespace="urn:uniski:get-list"
                    use="encoded"/>
        </output>
    </operation>

</binding>

<service name="StackOverFlower_Service">
    <documentation>Description File of StackOverFlowerService</documentation>
    <port binding="tns:StackOverFlower_Binding" name="StackOverFlower_Port">
        <soap:address
                location="http://localhost/stackoverflower/soap/" />
    </port>
</service>

Also I have my Service:

<?php

namespace MyBundleService;

use DoctrineORMEntityManager;
use SymfonyComponentSerializerSerializer;
use SymfonyComponentSerializerEncoderXmlEncoder;
use SymfonyComponentSerializerEncoderJsonEncoder;
use SymfonyComponentSerializerNormalizerObjectNormalizer;

class StackOverFlowerService {

private $em;
private $stackoverflower;

public function __construct(EntityManager $em)
{
    $this->em = $em;
}

public function newStack($name)
{
    /*
    $stackoverflower = new StackOverFlower();
    $stackoverflower->setName($name);

    $this->em->persist($stackoverflower);
    $this->em->flush();
    */
    return "ok";
}

public function getList()
{
    $stackoverflowers = array(
        array('id' => '001', 'name' => 'stack 001'),
        array('id' => '002', 'name' => 'stack 002'),
        array('id' => '003', 'name' => 'stack 003')
    );
    return $stackoverflowers;        
}

}
}

My services.yml

services:


stackoverflower_service:
    class: MyBundleServiceStackOverFlowerService
    arguments: ["@doctrine.orm.entity_manager"]

And finally I have my unique Controller for SOAP server & SOAP client like this:

<?php

namespace MyBundleController;

use SensioBundleFrameworkExtraBundleConfigurationMethod;
use SensioBundleFrameworkExtraBundleConfigurationRoute;
use SymfonyBundleFrameworkBundleControllerController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;

class StackOverFlowerController extends Controller

{
    /**
     * @Route("/stackoverflower/soap", name="test_soap")
     * @Method("GET")
     */
public function indexAction()
{
    ini_set("soap.wsdl_cache_enabled", "0");

    $options = array(
        'uri' => 'http://uniski.com.devel/stackoverflower/soap',
        'cache_wsdl' => WSDL_CACHE_NONE,
        'exceptions' => true
    );

    $server = new SoapServer(dirname(__FILE__).'/../../../web/soap/stackoverflower.wsdl', $options);

    $server->setObject($this->get('stackoverflower_service'));

    $response = new Response();
    $response->headers->set('Content-Type', 'text/xml; charset=utf-8');

    ob_start();
    $server->handle();
    $response->setContent(ob_get_clean());

    return $response;
}

/**
 * @Route("/stackoverflower/test-new", name="test_new")
 * @Method("GET")
 */
public function testNewAction(Request $request)
{
    $service = $this->get('stackoverflower_service');
    $result = $service->newStack($request->query->get('name'));

    return $this->render('PrestigeBundle:Soap:default.html.twig', array('status' => $result));
}

/**
 * @Route("/stackoverflower/test-list", name="test_list")
 * @Method("GET")
 */
public function testGetListAction(Request $request)
{
    try {

        /*
        $service = $this->get('stackoverflower_service');
        $result = $service->getList();
        return $this->render('PrestigeBundle:Soap:default.html.twig', array('list' => $result));
        */
        $client = new SoapClient("http://uniski.com.devel/stackoverflower/soap?wsdl", array("trace" => 1, "exception" => 1));
        var_dump($client->__getFunctions());
        //die();
        $result = $client->getList('ani');
        var_dump($result);

    } catch (SoapFault $e) {
        var_dump($e);

    }
    die();
}

}

But when I call from my Navigator this link:
http://localhost/stackoverflower/test-list

Always my Navigator shows me:
enter image description here
Please! I need help! Because I see my client found the functions of my WSDL, but I dont understand this error… NOT FOUND….

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *