├── .github └── workflows │ └── main.yaml ├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── phpunit.xml ├── src ├── HttpBinding.php ├── RequestBuilder.php └── RequestException.php └── tests ├── HttpBindingTest.php ├── RequestBuilderTest.php └── wsdl ├── airport.wsdl └── uszip.wsdl /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | strategy: 8 | matrix: 9 | operating-system: [ubuntu-latest] 10 | php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] 11 | 12 | runs-on: ${{ matrix.operating-system }} 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | 18 | - name: Setup PHP, with composer and extensions 19 | uses: shivammathur/setup-php@v2 20 | with: 21 | php-version: ${{ matrix.php-versions }} 22 | 23 | - name: Get composer cache directory 24 | id: composer-cache 25 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 26 | 27 | - name: Cache composer dependencies 28 | uses: actions/cache@v2 29 | with: 30 | path: ${{ steps.composer-cache.outputs.dir }} 31 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} 32 | restore-keys: ${{ runner.os }}-composer- 33 | 34 | - name: Install Composer dependencies 35 | run: | 36 | composer install --no-progress --prefer-dist --optimize-autoloader 37 | 38 | - name: Run Tests 39 | run: vendor/bin/phpunit --coverage-text -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /build/ 3 | .idea/ 4 | .DS_Store 5 | composer.lock 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Meng Tian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SOAP HTTP Binding [![codecov.io](https://codecov.io/github/meng-tian/soap-http-binding/coverage.svg?branch=master)](https://codecov.io/github/meng-tian/soap-http-binding?branch=master) ![workflow](https://github.com/meng-tian/soap-http-binding/actions/workflows/main.yaml/badge.svg) 2 | 3 | This library binds `SOAP 1.1` and `SOAP 1.2` messages to PSR-7 HTTP messages. 4 | 5 | ## Requirement 6 | PHP 7.1 7 | 8 | ## Install 9 | ``` 10 | composer require meng-tian/soap-http-binding 11 | ``` 12 | 13 | ## Usage 14 | `HttpBinding::request` embeds SOAP reqeust messages into PSR-7 HTTP requests. 15 | ```php 16 | use Meng\Soap\HttpBinding\HttpBinding; 17 | use Meng\Soap\HttpBinding\RequestBuilder; 18 | use Meng\Soap\Interpreter; 19 | use Laminas\Diactoros\RequestFactory; 20 | use Laminas\Diactoros\StreamFactory; 21 | 22 | $interpreter = new Interpreter('http://www.webservicex.net/airport.asmx?WSDL'); 23 | $streamFactory = new StreamFactory(); 24 | $requestFactory = new RequestFactory(); 25 | $builder = new RequestBuilder($streamFactory, $requestFactory); 26 | $httpBinding = new HttpBinding($interpreter, $builder, $streamFactory); 27 | 28 | $request = $httpBinding->request('GetAirportInformationByCountry', [['country' => 'United Kingdom']]); 29 | echo \Laminas\Diactoros\Request\Serializer::toString($request); 30 | ``` 31 | Output: 32 | ``` 33 | POST /airport.asmx HTTP/1.1 34 | Content-Length: 322 35 | SOAPAction: http://www.webserviceX.NET/GetAirportInformationByCountry 36 | Content-Type: text/xml; charset="utf-8" 37 | Host: www.webservicex.net 38 | 39 | 40 | United Kingdom 41 | 42 | ``` 43 | 44 | 45 | `HttpBinding::response` retrieves SOAP response messages from PSR-7 HTTP responses: 46 | ```php 47 | use Meng\Soap\HttpBinding\HttpBinding; 48 | use Meng\Soap\HttpBinding\RequestBuilder; 49 | use Meng\Soap\Interpreter; 50 | use Laminas\Diactoros\Response; 51 | use Laminas\Diactoros\Stream; 52 | use Laminas\Diactoros\RequestFactory; 53 | use Laminas\Diactoros\StreamFactory; 54 | 55 | $response = << 57 | 58 | 59 | 60 | some result 61 | 62 | 63 | 64 | EOD; 65 | 66 | $stream = new Stream('php://memory', 'r+'); 67 | $stream->write($response); 68 | $stream->rewind(); 69 | $response = new Response($stream, 200, ['Content-Type' => 'text/xml; charset=utf-8']); 70 | 71 | $interpreter = new Interpreter('http://www.webservicex.net/airport.asmx?WSDL'); 72 | $streamFactory = new StreamFactory(); 73 | $requestFactory = new RequestFactory(); 74 | $builder = new RequestBuilder($streamFactory, $requestFactory); 75 | $httpBinding = new HttpBinding($interpreter, $builder, $streamFactory); 76 | $response = $httpBinding->response($response, 'GetAirportInformationByCountry'); 77 | 78 | print_r($response); 79 | ``` 80 | Output: 81 | ``` 82 | stdClass Object 83 | ( 84 | [GetAirportInformationByCountryResult] => some result 85 | ) 86 | ``` 87 | 88 | 89 | This library also support `SOAP 1.2` HTTP GET binding through `RequestBuilder` class : 90 | ```php 91 | use Meng\Soap\HttpBinding\RequestBuilder; 92 | use Laminas\Diactoros\RequestFactory; 93 | use Laminas\Diactoros\StreamFactory; 94 | 95 | $streamFactory = new StreamFactory(); 96 | $requestFactory = new RequestFactory(); 97 | $builder = new RequestBuilder($streamFactory, $requestFactory); 98 | $request = $builder->isSOAP12() 99 | ->setEndpoint('http://www.endpoint.com') 100 | ->setHttpMethod('GET') 101 | ->getSoapHttpRequest(); 102 | echo \Laminas\Diactoros\Request\Serializer::toString($request); 103 | ``` 104 | Output: 105 | ``` 106 | GET / HTTP/1.1 107 | Accept: application/soap+xml 108 | Host: www.endpoint.com 109 | ``` 110 | 111 | 112 | ## License 113 | This library is released under [MIT](https://github.com/meng-tian/soap-http-binding/blob/master/LICENSE) license. 114 | 115 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "meng-tian/soap-http-binding", 3 | "description": "A PHP library for binding SOAP messages to PSR-7 HTTP messages.", 4 | "keywords": ["SOAP", "HTTP", "PSR-7"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Meng Tian", 9 | "email": "tianmeng94@hotmail.com" 10 | } 11 | ], 12 | "require": { 13 | "php": ">=7.1.0", 14 | "psr/http-factory": "~1.0", 15 | "meng-tian/php-soap-interpreter": "~2.0" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "~7.0|~9.3", 19 | "laminas/laminas-diactoros": "^2.0" 20 | }, 21 | "autoload": { 22 | "psr-4": { 23 | "Meng\\Soap\\HttpBinding\\": "src/" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tests/ 6 | 7 | 8 | 9 | 10 | src 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/HttpBinding.php: -------------------------------------------------------------------------------- 1 | interpreter = $interpreter; 19 | $this->builder = $builder; 20 | $this->streamFactory = $streamFactory; 21 | } 22 | 23 | /** 24 | * Embed SOAP messages in PSR-7 HTTP Requests 25 | * 26 | * @param string $name The name of the SOAP function to bind. 27 | * @param array $arguments An array of the arguments to the SOAP function. 28 | * @param array $options An associative array of options. 29 | * The location option is the URL of the remote Web service. 30 | * The uri option is the target namespace of the SOAP service. 31 | * The soapaction option is the action to call. 32 | * @param mixed $inputHeaders An array of headers to be bound along with the SOAP request. 33 | * @return RequestInterface 34 | * @throws RequestException If SOAP HTTP binding failed using the given parameters. 35 | */ 36 | public function request($name, array $arguments, array $options = null, $inputHeaders = null) 37 | { 38 | $soapRequest = $this->interpreter->request($name, $arguments, $options, $inputHeaders); 39 | if ($soapRequest->getSoapVersion() == '1') { 40 | $this->builder->isSOAP11(); 41 | } else { 42 | $this->builder->isSOAP12(); 43 | } 44 | $this->builder->setEndpoint($soapRequest->getEndpoint()); 45 | $this->builder->setSoapAction($soapRequest->getSoapAction()); 46 | 47 | $stream = $this->streamFactory->createStream(); 48 | $stream->write($soapRequest->getSoapMessage()); 49 | $stream->rewind(); 50 | $this->builder->setSoapMessage($stream); 51 | 52 | try { 53 | return $this->builder->getSoapHttpRequest(); 54 | } catch (RequestException $exception) { 55 | $stream->close(); 56 | throw $exception; 57 | } 58 | } 59 | 60 | /** 61 | * Retrieve SOAP messages from PSR-7 HTTP responses and interpret messages to PHP values. 62 | * 63 | * @param ResponseInterface $response 64 | * @param string $name The name of the SOAP function to unbind. 65 | * @param array $outputHeaders If supplied, this array will be filled with the headers from 66 | * the SOAP response. 67 | * @return mixed 68 | * @throws \SoapFault If the SOAP message contains SOAP faults. 69 | */ 70 | public function response(ResponseInterface $response, $name, array &$outputHeaders = null) 71 | { 72 | return $this->interpreter->response($response->getBody()->__toString(), $name, $outputHeaders); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/RequestBuilder.php: -------------------------------------------------------------------------------- 1 | streamFactory = $streamFactory; 54 | $this->requestFactory = $requestFactory; 55 | } 56 | 57 | /** 58 | * @return RequestInterface 59 | * @throws RequestException 60 | */ 61 | public function getSoapHttpRequest() 62 | { 63 | $this->validate(); 64 | $headers = $this->prepareHeaders(); 65 | $message = $this->prepareMessage(); 66 | $request = $this->requestFactory->createRequest($this->httpMethod, $this->endpoint); 67 | foreach ($headers as $key => $value) { 68 | $request = $request->withHeader($key, $value); 69 | } 70 | $request = $request->withBody($message); 71 | $this->unsetAll(); 72 | return $request; 73 | } 74 | 75 | /** 76 | * @param string $endpoint 77 | * @return self 78 | */ 79 | public function setEndpoint($endpoint) 80 | { 81 | $this->endpoint = $endpoint; 82 | return $this; 83 | } 84 | 85 | /** 86 | * @return self 87 | */ 88 | public function isSOAP11() 89 | { 90 | $this->soapVersion = self::SOAP11; 91 | return $this; 92 | } 93 | 94 | public function isSOAP12() 95 | { 96 | $this->soapVersion = self::SOAP12; 97 | return $this; 98 | } 99 | 100 | 101 | /** 102 | * @param string $soapAction 103 | * @return self 104 | */ 105 | public function setSoapAction($soapAction) 106 | { 107 | $this->soapAction = $soapAction; 108 | return $this; 109 | } 110 | 111 | /** 112 | * @param StreamInterface $message 113 | * @return self 114 | */ 115 | public function setSoapMessage(StreamInterface $message) 116 | { 117 | $this->soapMessage = $message; 118 | $this->hasSoapMessage = true; 119 | return $this; 120 | } 121 | 122 | /** 123 | * @param string $method 124 | * @return self 125 | */ 126 | public function setHttpMethod($method) 127 | { 128 | $this->httpMethod = $method; 129 | return $this; 130 | } 131 | 132 | private function validate() 133 | { 134 | $isValid = true; 135 | 136 | if (!$this->endpoint) { 137 | $isValid = false; 138 | } 139 | 140 | if (!$this->hasSoapMessage && $this->httpMethod == 'POST') { 141 | $isValid = false; 142 | } 143 | 144 | /** 145 | * SOAP 1.1 only defines HTTP binding with POST method. 146 | * @link https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383527 147 | */ 148 | if ($this->soapVersion == self::SOAP11 && $this->httpMethod != 'POST') { 149 | $isValid = false; 150 | } 151 | 152 | /** 153 | * SOAP 1.2 only defines HTTP binding with POST and GET methods. 154 | * @link https://www.w3.org/TR/2007/REC-soap12-part0-20070427/#L10309 155 | */ 156 | if ($this->soapVersion == self::SOAP12 && !in_array($this->httpMethod, ['GET', 'POST'])) { 157 | $isValid = false; 158 | } 159 | 160 | if (!$isValid) { 161 | $this->unsetAll(); 162 | throw new RequestException; 163 | } 164 | } 165 | 166 | /** 167 | * @return array 168 | */ 169 | private function prepareHeaders() 170 | { 171 | if ($this->soapVersion == self::SOAP11) { 172 | return $this->prepareSoap11Headers(); 173 | } else { 174 | return $this->prepareSoap12Headers(); 175 | } 176 | } 177 | 178 | /** 179 | * @link https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383526 180 | * @return array 181 | */ 182 | private function prepareSoap11Headers() 183 | { 184 | $headers = []; 185 | $headers['Content-Length'] = $this->soapMessage->getSize(); 186 | $headers['SOAPAction'] = $this->soapAction; 187 | $headers['Content-Type'] = 'text/xml; charset="utf-8"'; 188 | return $headers; 189 | } 190 | 191 | /** 192 | * SOSPAction header is removed in SOAP 1.2 and now expressed as a value of 193 | * an (optional) "action" parameter of the "application/soap+xml" media type. 194 | * @link https://www.w3.org/TR/soap12-part0/#L4697 195 | * @return array 196 | */ 197 | private function prepareSoap12Headers() 198 | { 199 | $headers = []; 200 | if ($this->httpMethod == 'POST') { 201 | $headers['Content-Length'] = $this->soapMessage->getSize(); 202 | $headers['Content-Type'] = 'application/soap+xml; charset="utf-8"' . '; action="' . $this->soapAction . '"'; 203 | } else { 204 | $headers['Accept'] = 'application/soap+xml'; 205 | } 206 | return $headers; 207 | } 208 | 209 | /** 210 | * @return StreamInterface 211 | */ 212 | private function prepareMessage() 213 | { 214 | if ($this->httpMethod == 'POST') { 215 | return $this->soapMessage; 216 | } else { 217 | return $this->streamFactory->createStream(); 218 | } 219 | } 220 | 221 | private function unsetAll() 222 | { 223 | $this->endpoint = null; 224 | if ($this->hasSoapMessage) { 225 | $this->soapMessage = null; 226 | $this->hasSoapMessage = false; 227 | } 228 | $this->soapAction = ''; 229 | $this->soapVersion = self::SOAP11; 230 | $this->httpMethod = 'POST'; 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /src/RequestException.php: -------------------------------------------------------------------------------- 1 | SOAP_1_1]); 20 | $streamFactory = new StreamFactory(); 21 | $requestFactory = new RequestFactory(); 22 | $builder = new RequestBuilder($streamFactory, $requestFactory); 23 | $httpBinding = new HttpBinding($interpreter, $builder, $streamFactory); 24 | $request = $httpBinding->request('GetAirportInformationByCountry', [['country' => 'United Kingdom']]); 25 | $this->assertTrue($request instanceof \Psr\Http\Message\RequestInterface); 26 | 27 | $response = << 29 | 30 | 31 | 32 | string 33 | 34 | 35 | 36 | EOD; 37 | 38 | $stream = $streamFactory->createStream(); 39 | $stream->write($response); 40 | $stream->rewind(); 41 | $response = new Response($stream, 200, ['Content-Type' => 'text/xml; charset=utf-8']); 42 | $response = $httpBinding->response($response, 'GetAirportInformationByCountry'); 43 | $this->assertObjectHasAttribute('GetAirportInformationByCountryResult', $response); 44 | } 45 | 46 | /** 47 | * @test 48 | */ 49 | public function soap12() 50 | { 51 | $interpreter = new Interpreter(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wsdl' . DIRECTORY_SEPARATOR . 'uszip.wsdl', ['soap_version' => SOAP_1_2]); 52 | $streamFactory = new StreamFactory(); 53 | $requestFactory = new RequestFactory(); 54 | $builder = new RequestBuilder($streamFactory, $requestFactory); 55 | $httpBinding = new HttpBinding($interpreter, $builder, $streamFactory); 56 | 57 | $request = $httpBinding->request('GetInfoByCity', [['USCity' => 'New York']]); 58 | $this->assertTrue($request instanceof \Psr\Http\Message\RequestInterface); 59 | 60 | $response = << 62 | 63 | 64 | 65 | some information 66 | 67 | 68 | 69 | EOD; 70 | 71 | $stream = $streamFactory->createStream(); 72 | $stream->write($response); 73 | $stream->rewind(); 74 | $response = new Response($stream, 200, ['Content-Type' => 'Content-Type: application/soap+xml; charset=utf-8']); 75 | $response = $httpBinding->response($response, 'GetInfoByCity'); 76 | $this->assertObjectHasAttribute('GetInfoByCityResult', $response); 77 | } 78 | 79 | /** 80 | * @test 81 | */ 82 | public function requestBindingFailed() 83 | { 84 | $interpreter = new Interpreter(null, ['uri' => '', 'location' => '']); 85 | $builderMock = $this->getMockBuilder('Meng\Soap\HttpBinding\RequestBuilder') 86 | ->disableOriginalConstructor() 87 | ->setMethods(['getSoapHttpRequest']) 88 | ->getMock(); 89 | $builderMock->method('getSoapHttpRequest')->willThrowException(new RequestException()); 90 | 91 | $httpBinding = new HttpBinding($interpreter, $builderMock, new StreamFactory); 92 | $this->expectException('Meng\Soap\HttpBinding\RequestException'); 93 | $httpBinding->request('some-function', []); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /tests/RequestBuilderTest.php: -------------------------------------------------------------------------------- 1 | isSOAP11() 19 | ->setEndpoint('http://www.endpoint.com') 20 | ->setSoapAction('http://www.soapaction.com') 21 | ->setSoapMessage(new Stream(fopen('php://temp', 'r'))) 22 | ->getSoapHttpRequest(); 23 | 24 | $this->assertEquals('POST', $request->getMethod()); 25 | $this->assertEquals('text/xml; charset="utf-8"', $request->getHeader('Content-Type')[0]); 26 | $this->assertTrue($request->hasHeader('Content-Length')); 27 | $this->assertTrue($request->hasHeader('SOAPAction')); 28 | $this->assertEquals('http://www.soapaction.com', $request->getHeader('SOAPAction')[0]); 29 | $this->assertEquals('http://www.endpoint.com', (string)$request->getUri()); 30 | } 31 | 32 | /** 33 | * @test 34 | */ 35 | public function soap11RequestHttpGetBinding() 36 | { 37 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 38 | $this->expectException('Meng\Soap\HttpBinding\RequestException'); 39 | $builder->setHttpMethod('GET') 40 | ->setEndpoint('http://www.endpoint.com') 41 | ->setSoapAction('http://www.soapaction.com') 42 | ->setSoapMessage(new Stream(fopen('php://temp', 'r'))) 43 | ->getSoapHttpRequest(); 44 | } 45 | 46 | /** 47 | * @test 48 | */ 49 | public function soap12Request() 50 | { 51 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 52 | $request = $builder->isSOAP12() 53 | ->setEndpoint('http://www.endpoint.com') 54 | ->setSoapAction('http://www.soapaction.com') 55 | ->setSoapMessage(new Stream(fopen('php://temp', 'r'))) 56 | ->getSoapHttpRequest(); 57 | 58 | $this->assertEquals('POST', $request->getMethod()); 59 | $this->assertTrue($request->hasHeader('Content-Type')); 60 | $this->assertEquals('application/soap+xml; charset="utf-8"; action="http://www.soapaction.com"', $request->getHeader('Content-Type')[0]); 61 | $this->assertTrue($request->hasHeader('Content-Length')); 62 | $this->assertFalse($request->hasHeader('SOAPAction')); 63 | $this->assertEquals('http://www.endpoint.com', (string)$request->getUri()); 64 | } 65 | 66 | /** 67 | * @test 68 | */ 69 | public function soap12RequestPutMethod() 70 | { 71 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 72 | $this->expectException('Meng\Soap\HttpBinding\RequestException'); 73 | $builder->isSOAP12() 74 | ->setEndpoint('http://www.endpoint.com') 75 | ->setSoapAction('http://www.soapaction.com') 76 | ->setHttpMethod('PUT') 77 | ->setSoapMessage(new Stream(fopen('php://temp', 'r'))) 78 | ->getSoapHttpRequest(); 79 | } 80 | 81 | /** 82 | * @test 83 | */ 84 | public function soap12RequestGetMethod() 85 | { 86 | $stream = fopen('php://temp', 'w'); 87 | fwrite($stream, 'some string'); 88 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 89 | $request = $builder->isSOAP12() 90 | ->setHttpMethod('GET') 91 | ->setEndpoint('http://www.endpoint.com') 92 | ->setSoapAction('http://www.soapaction.com') 93 | ->setSoapMessage(new Stream($stream, 'r')) 94 | ->getSoapHttpRequest(); 95 | 96 | $this->assertEquals('GET', $request->getMethod()); 97 | $this->assertFalse($request->hasHeader('Content-Type')); 98 | $this->assertEquals('application/soap+xml', $request->getHeader('Accept')[0]); 99 | $this->assertFalse($request->hasHeader('Content-Length')); 100 | $this->assertFalse($request->hasHeader('SOAPAction')); 101 | $this->assertEquals('http://www.endpoint.com', (string)$request->getUri()); 102 | $this->assertEquals('', $request->getBody()->getContents()); 103 | } 104 | 105 | /** 106 | * @test 107 | */ 108 | public function soapNoEndpoint() 109 | { 110 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 111 | $this->expectException('Meng\Soap\HttpBinding\RequestException'); 112 | $builder->setSoapMessage(new Stream(fopen('php://temp', 'r')))->getSoapHttpRequest(); 113 | } 114 | 115 | /** 116 | * @test 117 | */ 118 | public function soapNoMessage() 119 | { 120 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 121 | $this->expectException('Meng\Soap\HttpBinding\RequestException'); 122 | $builder->setEndpoint('http://www.endpoint.com')->getSoapHttpRequest(); 123 | } 124 | 125 | /** 126 | * @test 127 | */ 128 | public function resetAllAfterFailure() 129 | { 130 | $builder = new RequestBuilder(new StreamFactory(), new RequestFactory()); 131 | try { 132 | $builder->isSOAP12()->setEndpoint('http://www.endpoint.com')->getSoapHttpRequest(); 133 | } catch (RequestException $e) { 134 | } 135 | $this->expectException('Meng\Soap\HttpBinding\RequestException'); 136 | $builder->setHttpMethod('GET')->getSoapHttpRequest(); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /tests/wsdl/airport.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by ISO country code 139 | 140 | 141 | 142 | 143 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by city or airport name 144 | 145 | 146 | 147 | 148 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by country name 149 | 150 | 151 | 152 | 153 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by airport code 154 | 155 | 156 | 157 | 158 | 159 | 160 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by ISO country code 161 | 162 | 163 | 164 | 165 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by city or airport name 166 | 167 | 168 | 169 | 170 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by country name 171 | 172 | 173 | 174 | 175 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by airport code 176 | 177 | 178 | 179 | 180 | 181 | 182 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by ISO country code 183 | 184 | 185 | 186 | 187 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by city or airport name 188 | 189 | 190 | 191 | 192 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by country name 193 | 194 | 195 | 196 | 197 | Get Airport Code, CityOrAirport Name, Country, Country Abbrv, CountryCode,GMT Offset Runway Length in Feet, Runway Elevation in Feet,Latitude in Degree,Latitude in Minute Latitude in Second,Latitude in N/S, Longitude in Degree, Longitude in Minute, Longitude in Seconds and longitude E/W by airport code 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | -------------------------------------------------------------------------------- /tests/wsdl/uszip.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | Get State Code,City,Area Code,Time Zone,Zip Code by Zip Code 162 | 163 | 164 | 165 | 166 | Get State Code,City,Area Code,Time Zone,Zip Code by City 167 | 168 | 169 | 170 | 171 | Get State Code,City,Area Code,Time Zone,Zip Code by state 172 | 173 | 174 | 175 | 176 | Get State Code,City,Area Code,Time Zone,Zip Code by Area Code 177 | 178 | 179 | 180 | 181 | 182 | 183 | Get State Code,City,Area Code,Time Zone,Zip Code by Zip Code 184 | 185 | 186 | 187 | 188 | Get State Code,City,Area Code,Time Zone,Zip Code by City 189 | 190 | 191 | 192 | 193 | Get State Code,City,Area Code,Time Zone,Zip Code by state 194 | 195 | 196 | 197 | 198 | Get State Code,City,Area Code,Time Zone,Zip Code by Area Code 199 | 200 | 201 | 202 | 203 | 204 | 205 | Get State Code,City,Area Code,Time Zone,Zip Code by Zip Code 206 | 207 | 208 | 209 | 210 | Get State Code,City,Area Code,Time Zone,Zip Code by City 211 | 212 | 213 | 214 | 215 | Get State Code,City,Area Code,Time Zone,Zip Code by state 216 | 217 | 218 | 219 | 220 | Get State Code,City,Area Code,Time Zone,Zip Code by Area Code 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | --------------------------------------------------------------------------------