PHP code example of goetas-webservices / soap-server
1. Go to this page and download the library: Download goetas-webservices/soap-server library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
goetas-webservices / soap-server example snippets
// composer auto loader
n container class
// the name was defined by --dest-class=GlobalWeather/Container/SoapServerContainer
// parameter during the generation process
$container = new SoapServerContainer();
// create a JMS serializer instance
$serializer = SoapContainerBuilder::createSerializerBuilderFromContainer($container)->build();
// get the metadata from the container
$metadata = $container->get('goetas_webservices.soap.metadata_reader');
$handler = new class() {
function anAction($someParam)
{
return 'OK 123';
}
function someAction($someParam, HeadersIncoming $headersIncoming)
{
$headers = $headersIncoming->getRawheader();
// perform some checks on $headers here
return 'OK 123';
}
function anotherAction($someParam, HeadersOutgoing $headersOutgoing)
{
// reply with custom headers
$headersOutgoing->addHeader(new Header(new SomeHeaderData()));
// reply with custom headers in pure xml
$dom = new DOMDocument();
$dom->appendChild($dom->createElement('foo', 'bar'));
$headersOutgoing->addHeader(new Header($dom->documentElement));
return 'OK 456';
}
function someErrAction($someParam)
{
throw new CustomExcpetion(); // converted in a soap fault
}
};
$router = new DefaultRouter(new ConfiguredRoute($handler));
$factory = new ServerFactory($metadata, $serializer, $router);
// get the soap server
$server = $factory->getServer('test.wsdl');
// create psr7 request
$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals();
// let the server handle the request
$response = $server->handle($request);
// send the response to the client (using laminas/laminas-httphandlerrunner)
$emitter = new \Laminas\HttpHandlerRunner\Emitter\SapiEmitter();
$emitter->emit($response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.