2017-05-03 4 views
0

私はSymfony3で非常に簡単なSOAP呼び出しを実装しようとしています。 完全に動作しますが、何も返しません。私のコントローラでSOAPサーバーSymfony応答の設定方法

私はちょうどこの

public function indexAction() 
{ 
    $server = new \SoapServer($this->get('kernel')->getRootDir()."/../web/soap/test.wsdl"); 
    $server->setObject($this->get('serv.soapservice')); 

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

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

    return $response; 
} 

のようにそれを呼び出し、呼び出された関数は、この

public function hello($param) 
{ 
    return 'Hello, '.$param->name; 
} 

私はSOAPUIでそれを試してみましたが、それは完璧に動作しますが、石鹸のリターンは似ているように見えますこの

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/symfony/test/web/app_dev.php/en/soap"> 
    <SOAP-ENV:Body> 
     <ns1:helloResponse/> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

このような関数の応答は返されません

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/symfony/test/web/app_dev.php/en/soap"> 
    <SOAP-ENV:Body> 
     <ns1:helloResponse> 
      <out>Hello John</out> 
     <ns1:helloResponse/> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

どのように返すことができますか?

答えて

0

最後に問題が見つかりました。私はちょうど私がhello関数で返す方法を変更する必要があります。 これは今のように見え、素晴らしい作品です。

public function hello($param) 
{ 
    $response = array(); 
    $response['out']='Hello, '.$param->name; 
    return $response; 
} 
関連する問題