Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ public function __construct(Browser $browser, $wsdlContents, array $options = ar
{
$wsdl = $wsdlContents !== null ? 'data://text/plain;base64,' . base64_encode($wsdlContents) : null;

// Accept HTTP responses with error status codes as valid responses.
// This is done in order to process these error responses through the normal SOAP decoder.
// Additionally, we explicitly limit number of redirects to zero because following redirects makes little sense
// because it transforms the POST request to a GET one and hence loses the SOAP request body.
$browser = $browser->withOptions(array(
'obeySuccessCode' => false,
'followRedirects' => true,
'maxRedirects' => 0
));

$this->browser = $browser;
$this->encoder = new ClientEncoder($wsdl, $options);
$this->decoder = new ClientDecoder($wsdl, $options);
Expand Down Expand Up @@ -200,7 +210,6 @@ function (ResponseInterface $response) use ($decoder, $name) {
);
}


/**
* Returns an array of functions defined in the WSDL.
*
Expand Down
1 change: 1 addition & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testNonWsdlClientSendsPostRequestToGivenLocationForAnySoapCall()
};
$promise = new Promise(function () { });
$browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
$browser->expects($this->once())->method('withOptions')->willReturnSelf();
$browser->expects($this->once())->method('send')->with($this->callback($verify))->willReturn($promise);

$client = new Client($browser, null, array('location' => 'http://example.com', 'uri' => 'http://example.com/uri'));
Expand Down
29 changes: 24 additions & 5 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,27 @@ public function testBlzServiceNonWsdlModeReturnedWithoutOuterResultStructure()
}

/**
* @expectedException Exception
* @expectedException RuntimeException
* @expectedExeptionMessage redirects
*/
public function testBlzServiceWithInvalidBlz()
public function testBlzServiceWithRedirectLocationRejectsWithRuntimeException()
{
$this->client = new Client(new Browser($this->loop), null, array(
'location' => 'http://httpbin.org/redirect-to?url=' . rawurlencode('http://www.thomas-bayer.com/axis2/services/BLZService'),
'uri' => 'http://thomas-bayer.com/blz/',
));

$api = new Proxy($this->client);
$promise = $api->getBank('a');

$result = Block\await($promise, $this->loop);
}

/**
* @expectedException SoapFault
* @expectedExeptionMessage Keine Bank zur BLZ invalid gefunden!
*/
public function testBlzServiceWithInvalidBlzRejectsWithSoapFault()
{
$api = new Proxy($this->client);

Expand All @@ -129,13 +147,14 @@ public function testBlzServiceWithInvalidBlz()
}

/**
* @expectedException Exception
* @expectedException SoapFault
* @expectedExceptionMessage Function ("doesNotExist") is not a valid method for this service
*/
public function testBlzServiceWithInvalidMethod()
public function testBlzServiceWithInvalidMethodRejectsWithSoapFault()
{
$api = new Proxy($this->client);

$promise = $api->doesNotexist();
$promise = $api->doesNotExist();

Block\await($promise, $this->loop);
}
Expand Down