Controller
  1. namespace Acme\ApiBundle\Controller;
  2.  
  3.  
  4. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7.  
  8. class SoapServiceController extends Controller
  9. {
  10. public function indexAction()
  11. {
  12. $server = new \SoapServer('/home/kallosz/www/acme.project/src/Acme/soap.wsdl');
  13. $server->setObject($this->get('soap_service'));
  14.  
  15. $response = new Response();
  16. $response->headers->set('Content-Type', 'text/xml; charset=utf-8');
  17.  
  18. $server->handle();
  19. if(ob_get_length() > 0) {
  20. $response->setContent(ob_get_clean());
  21. }
  22. return $response;
  23. }
  24. }

Service
  1. namespace Acme\ApiBundle\Services;
  2.  
  3. use \SimpleXMLElement;
  4.  
  5. class SoapService
  6. {
  7.  
  8. public function sendSms($name)
  9. {/*
  10.   $soap = new SimpleXMLElement('<soap/>');
  11.   $errors = $soap->addChild('errors');
  12.   $errors->addChild('error', $name);
  13. */
  14. return 'testsend'.$name;
  15. }
  16.  
  17. public function getSms($name)
  18. {/*
  19.   $soap = new SimpleXMLElement('<soap/>');
  20.   $errors = $soap->addcslashes(str, charlist)Child('errors');
  21.   $errors->addChild('error', $name);
  22. */
  23. return 'testget'.$name;
  24. }
  25. }

WSDL
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  3. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  6. xmlns:tns="urn:acme"
  7. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  8. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  9. xmlns="http://schemas.xmlsoap.org/wsdl/"
  10. targetNamespace="urn:acme">
  11. <types>
  12. <xsd:schema targetNamespace="urn:acme">
  13. <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
  14. <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
  15. </xsd:schema>
  16. </types>
  17. <message name="getSmsRequest">
  18. <part name="name" type="xsd:string" />
  19. </message>
  20. <message name="getSmsResponse">
  21. <part name="return" type="xsd:string" />
  22. </message>
  23. <portType name="avmePortType">
  24. <operation name="getSms">
  25. <documentation>Hello World</documentation>
  26. <input message="tns:getSmsRequest"/>
  27. <output message="tns:getSmsResponse"/>
  28. </operation>
  29. </portType>
  30. <binding name="acmeBinding" type="tns:acmePortType">
  31. <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  32. <operation name="getSms">
  33. <soap:operation soapAction="urn:acme#getSms" style="rpc"/>
  34. <input>
  35. <soap:body use="encoded" namespace="urn:acme"
  36. encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  37. </input>
  38. <output>
  39. <soap:body use="encoded" namespace="urn:acme"
  40. encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  41. </output>
  42. </operation>
  43. </binding>
  44. <service name="acme">
  45. <port name="acmePort" binding="tns:acmeBinding">
  46. <soap:address location="http://acme.project/app_dev.php/api/soap" />
  47. </port>
  48. </service>
  49. </definitions>


Testowy plik klienta
  1. $client = new \Soapclient('http://acme.project/app_dev.php/api/soap?wsdl');
  2. $result = $client->hello('test');
  3. var_dump($result);


Problemem jest ciągła odpowiedź null nie ważne jaką zmianę dokonam w WSDL czy pozostałych plikach. Co jakiś czas pojawi się błąd dotyczący braku procedury getSms.

Problem został rozwiązany.
Winowajcą był cache smile.gif

Temat można zamknąć.