instance() public static method

public static instance ( ) : WSDLBuilder
return WSDLBuilder
示例#1
0
 /**
  * @test
  */
 public function shouldGenerateCorrectXML()
 {
     //given
     $tokenizer = new Tokenizer();
     $parameters1 = [Parameter::fromTokens($tokenizer->lex('string $userName'))];
     $return1 = Parameter::fromTokens($tokenizer->lex('string $uppercasedUserName'));
     $parameters2 = [Parameter::fromTokens($tokenizer->lex('int[] $numbers')), Parameter::fromTokens($tokenizer->lex('string $prefix'))];
     $return2 = Parameter::fromTokens($tokenizer->lex('string[] $numbersWithPrefix'));
     $parameters3 = [Parameter::fromTokens($tokenizer->lex('object $user { string $name int $age }'))];
     $return3 = Parameter::fromTokens($tokenizer->lex('object $userContext { int $id object $userInfo { string $name int $age } }'));
     $parameters4 = [Parameter::fromTokens($tokenizer->lex('object[] $companies { string $name int $postcode }'))];
     $return4 = Parameter::fromTokens($tokenizer->lex('string[] $companiesNames'));
     $parameters5 = [Parameter::fromTokens($tokenizer->lex('string[] $errors'))];
     $return5 = Parameter::fromTokens($tokenizer->lex('object $result { boolean $result string[] $errors }'));
     $parameters6 = [Parameter::fromTokens($tokenizer->lex('object $serviceAuth { string $token int $id }'), true), Parameter::fromTokens($tokenizer->lex('string $name')), Parameter::fromTokens($tokenizer->lex('string $surname'))];
     $return6 = Parameter::fromTokens($tokenizer->lex('string $nameWithSurname'));
     $parameters7 = [Parameter::fromTokens($tokenizer->lex('string $userToken'))];
     $return8 = Parameter::fromTokens($tokenizer->lex('string $responseForMethodWithoutParameters'));
     $builder = WSDLBuilder::instance()->setName('RpcLiteralService')->setTargetNamespace('http://foo.bar/rpcliteralservice')->setNs('http://foo.bar/rpcliteralservice/types')->setLocation('http://localhost:7777/wsdl-creator/examples/rpc_literal/service.php')->setStyle(SoapBinding::RPC)->setUse(SoapBinding::LITERAL)->setSoapVersion(BindingType::SOAP_11)->setMethod(new Method('uppercaseUserName', $parameters1, $return1))->setMethod(new Method('appendPrefixToNumbers', $parameters2, $return2))->setMethod(new Method('getUserContext', $parameters3, $return3))->setMethod(new Method('extractCompaniesNames', $parameters4, $return4))->setMethod(new Method('wrapErrors', $parameters5, $return5))->setMethod(new Method('authorizedMethod', $parameters6, $return6))->setMethod(new Method('methodWithoutReturn', $parameters7, null))->setMethod(new Method('methodWithoutParameters', [], $return8));
     $XMLProvider = new XMLProvider($builder);
     $XMLProvider->generate();
     //when
     $xml = $XMLProvider->getXml();
     //then
     $this->assertXmlStringEqualsXmlFile(Path::join(__DIR__, 'xml_file_asserts', 'correct_xml.wsdl'), $xml);
 }
 /**
  * @param string $class
  */
 public function __construct($class)
 {
     AnnotationRegistry::registerAutoloadNamespace('WSDL\\Annotation', Path::join(__DIR__, '..', '..'));
     $this->class = $class;
     $this->builder = WSDLBuilder::instance();
     $this->annotationReader = new AnnotationReader();
 }
示例#3
0
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
use WSDL\Annotation\BindingType;
use WSDL\Annotation\SoapBinding;
use WSDL\Builder\WSDLBuilder;
use WSDL\WSDL;
require_once '../../vendor/autoload.php';
require_once '../ExampleService.php';
require_once '../MethodsProvider.php';
ini_set("soap.wsdl_cache_enabled", 0);
$builder = WSDLBuilder::instance()->setName('RpcLiteralService')->setTargetNamespace('http://foo.bar/rpcliteralservice')->setNs('http://foo.bar/rpcliteralservice/types')->setLocation('http://localhost:7777/wsdl-creator/examples/rpc_literal/service.php')->setStyle(SoapBinding::RPC)->setUse(SoapBinding::LITERAL)->setSoapVersion(BindingType::SOAP_11)->setMethods(MethodsProvider::get());
$wsdl = WSDL::fromBuilder($builder);
if (isset($_GET['wsdl'])) {
    header("Content-Type: text/xml");
    echo $wsdl->create();
    exit;
}
$server = new SoapServer('http://localhost:7777/wsdl-creator/examples/rpc_literal/service.php?wsdl', ['uri' => $builder->getTargetNamespace(), 'location' => $builder->getLocation(), 'style' => SOAP_RPC, 'use' => SOAP_LITERAL]);
$server->setClass('ExampleService');
$server->handle();
示例#4
0
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
use WSDL\Annotation\BindingType;
use WSDL\Annotation\SoapBinding;
use WSDL\Builder\WSDLBuilder;
use WSDL\WSDL;
require_once '../../vendor/autoload.php';
require_once '../ExampleService.php';
require_once '../MethodsProvider.php';
ini_set("soap.wsdl_cache_enabled", 0);
$builder = WSDLBuilder::instance()->setName('DocumentLiteralWrappedService')->setTargetNamespace('http://foo.bar/documentliteralwrappedservice')->setNs('http://foo.bar/documentliteralwrappedservice/types')->setLocation('http://localhost:7777/wsdl-creator/examples/document_literal_wrapped/service.php')->setStyle(SoapBinding::DOCUMENT)->setUse(SoapBinding::LITERAL)->setSoapVersion(BindingType::SOAP_11)->setMethods(MethodsProvider::get());
$wsdl = WSDL::fromBuilder($builder);
if (isset($_GET['wsdl'])) {
    header("Content-Type: text/xml");
    echo $wsdl->create();
    exit;
}
$server = new SoapServer('http://localhost:7777/wsdl-creator/examples/document_literal_wrapped/service.php?wsdl', ['uri' => $builder->getTargetNamespace(), 'location' => $builder->getLocation(), 'style' => SOAP_DOCUMENT, 'use' => SOAP_LITERAL]);
$server->setClass('ExampleService');
$server->handle();
示例#5
0
 /**
  * @test
  */
 public function shouldThrowExceptionWhenParameterStyleIsInValid()
 {
     //given
     $WSDLBuilder = WSDLBuilder::instance();
     //when
     CatchException::when($WSDLBuilder)->setParameterStyle('INVALID');
     //then
     CatchException::assertThat()->hasMessage('Invalid parameter style [INVALID] available parameter styles: [BARE, WRAPPED]');
 }