Ejemplo n.º 1
0
 private function parseResponse(HttpBinding $httpBinding, ResponseInterface $response, $name, &$outputHeaders)
 {
     try {
         return $httpBinding->response($response, $name, $outputHeaders);
     } finally {
         $response->getBody()->close();
     }
 }
    /**
     * @test
     */
    public function soap12()
    {
        $interpreter = new Interpreter('http://www.webservicex.net/uszip.asmx?WSDL', ['soap_version' => SOAP_1_2]);
        $builder = new RequestBuilder();
        $httpBinding = new HttpBinding($interpreter, $builder);
        $request = $httpBinding->request('GetInfoByCity', [['USCity' => 'New York']]);
        $this->assertTrue($request instanceof \Psr\Http\Message\RequestInterface);
        $response = <<<EOD
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetInfoByCityResponse xmlns="http://www.webserviceX.NET">
      <GetInfoByCityResult>some information</GetInfoByCityResult>
    </GetInfoByCityResponse>
  </soap12:Body>
</soap12:Envelope>
EOD;
        $stream = new Stream('php://memory', 'r+');
        $stream->write($response);
        $stream->rewind();
        $response = new Response($stream, 200, ['Content-Type' => 'Content-Type: application/soap+xml; charset=utf-8']);
        $response = $httpBinding->response($response, 'GetInfoByCity');
        $this->assertObjectHasAttribute('GetInfoByCityResult', $response);
    }