76 Commits

Author SHA1 Message Date
e4cb612aed Created a client classmap even when it is empty 2014-04-30 10:54:07 +02:00
59ea6b1ce0 Merge pull request #33 from borissamardzija/master
Update Curl class to support CURLOPT_CAINFO and CURLOPT_CAPATH options
2014-04-25 13:36:04 +02:00
7bb849e394 Update Curl class to support CURLOPT_CAINFO and CURLOPT_CAPATH options 2014-04-25 11:16:34 +02:00
02722eae8f Merge pull request #32 from mremi/filter-request-headers
Added method to tweak HTTP headers of request
2014-04-24 17:22:00 +02:00
b7581f29b0 Removed reference to return an array of HTTP headers 2014-04-24 09:29:58 +02:00
dc6e1e0889 Merge pull request #31 from mremi/http-auth
Added extra option to configure HTTP authentication
2014-04-24 08:38:03 +02:00
f986400dc2 Merge pull request #30 from mremi/method-visibility
Updated visibility from private to protected
2014-04-24 08:36:23 +02:00
67410805ba Added method to tweak HTTP headers of request 2014-04-22 22:29:11 +02:00
2ae7515294 Added extra option to configure HTTP authentication 2014-04-22 22:05:04 +02:00
cdfc3cd5bd Updated visibility from private to protected 2014-04-22 21:53:14 +02:00
9ac755d86e [SoapBundle] Set _format route to xml 2013-12-13 15:25:20 +01:00
321dcf3058 [SoapBundle] Set wsdl request type only if the "wsdl" parameter in present in URL 2013-12-13 11:24:25 +01:00
3a2b8e32ee [SoapBundle] Enhanced SoapFault management 2013-12-13 08:26:18 +01:00
fd5154a469 Fixed typo 2013-12-10 15:25:09 +01:00
188f282a87 [SoapWsdl] Specify an empty message if the input is empty 2013-12-10 15:25:09 +01:00
1b4e262c60 [SoapBundle] Simplified conditional statement 2013-12-08 00:25:20 +01:00
60e3714602 [SoapBundle][SoapCommon] Removed unused TypeRepository in Definition\Method classes 2013-12-08 00:23:30 +01:00
1e82d7fdd7 Fix WSDL schema stylesheet including 2013-12-07 19:55:33 +01:00
8788d7595d Cleaned unused method, property, variable or parameter 2013-12-02 16:02:29 +01:00
b45224587a Added use TypeConverterInterface 2013-12-02 15:39:59 +01:00
c8baf14c75 Fixed typo 2013-12-02 15:39:39 +01:00
53849c68e0 Removed unused use statement 2013-12-02 15:35:36 +01:00
ecdf7e1872 Fixed an undefined variable
Fixed commit c830097430
Fixed issue #22
2013-11-20 08:45:12 +01:00
dcfca04db4 Merge remote-tracking branch 'origin/exception'
Conflicts:
	composer.json
	src/BeSimple/SoapBundle/composer.json
2013-11-15 10:37:55 +01:00
73efa627ce Removed old Zend dependencies in composer.json 2013-11-13 16:43:47 +01:00
d6752a41e9 [SoapWsdl] Fixed bad usage name of type included in an other ComplexType
Fixed issue #21
2013-11-13 15:46:50 +01:00
6a6661012e [SoapBundle] Enhanced exception management with Symfony2 2013-11-13 15:02:30 +01:00
10705aa9e2 Merge branch '0.1'
Conflicts:
	src/BeSimple/SoapServer/SoapResponse.php
2013-11-06 16:50:31 +01:00
bd2508f854 Merge branch '0.1' 2013-11-06 09:31:58 +01:00
259c23ee4d Merge pull request #20 from hason/patch-1
Fixed typo
2013-11-01 07:42:46 -07:00
98842b24f8 Fixed typo 2013-11-01 13:40:16 +01:00
48d305e7db Merge branch 'wsse' of https://github.com/aschamberger/BeSimpleSoap into aschamberger-wsse
Conflicts:
	.travis.yml
	src/BeSimple/SoapServer/SoapRequest.php
2013-10-30 17:00:44 +01:00
4a97c2537e Merge branch 'patch-1' of https://github.com/rekky/BeSimpleSoap into rekky-patch-1 2013-10-30 16:51:54 +01:00
b8f37d213e Fixed version besimple/soap-* version in README's 2013-10-30 16:49:47 +01:00
6e967fe811 Merge branch 'readmes' of https://github.com/aschamberger/BeSimpleSoap into aschamberger-readmes 2013-10-30 16:47:25 +01:00
00c8726bb2 Updated composer.json 2013-10-30 16:35:17 +01:00
dc4c9d2191 remove travis status in readme 2013-10-30 15:54:35 +01:00
9ddac35f18 Fix doc comment 2013-10-30 12:31:00 +01:00
ed0846da6f Fix byte length counting if strlen overloading is used 2013-10-30 11:18:22 +04:00
9827e58c56 Merge pull request #19 from rolebi/patch-1
Adding besimple/soap-wsdl to dependencies
2013-10-28 03:40:34 -07:00
e7d86b3e99 Adding besimple/soap-wsdl to dependencies
Fix missing `BeSimple\SoapWsdl\Dumper\Dumper` class in `BeSimple\SoapBundle\WebServiceContext`
2013-10-28 11:09:23 +01:00
54894b2fd9 Fixed ComplexType without alias name
Fix issue #17
2013-10-17 13:51:31 +02:00
95efa3e366 Fixed CS 2013-10-17 13:48:02 +02:00
c830097430 Rewrited Definition of WebService and WSDL dumper 2013-10-15 11:46:12 +02:00
391a3f10b8 Merge branch '0.1' 2013-10-15 11:15:10 +02:00
ebd565cd79 Fixed besimple/soap-* version 2013-09-27 21:35:39 +02:00
81ce2d7571 Merge branch '0.1' 2013-09-27 21:33:11 +02:00
461675042a fix soap header handling 2013-08-30 22:07:44 +02:00
f5a8573a4e Add readme files 2013-08-24 17:38:18 +02:00
1f1d513ea3 remove obsolete file 2013-08-24 11:01:59 +02:00
8e305da9c0 change url for check if axis is ready 2013-08-24 10:53:24 +02:00
dc3fcaf81f remove ini and try axis build 2013-08-24 09:47:34 +02:00
d8d6ca5795 fix problem with cache path 2013-08-24 09:39:56 +02:00
cbd49c3342 add php ini for travis and update travis config 2013-08-24 09:21:13 +02:00
e9388023c1 add php ini for travis and update travis config 2013-08-24 09:05:58 +02:00
76360c193e add php ini for travis and update travis config 2013-08-24 09:03:23 +02:00
155956ca04 change file permissions 2013-08-24 08:44:10 +02:00
3f41d4b7bc change file permissions 2013-08-24 08:41:59 +02:00
4fa7fd759a add phpwebserver to travis 2013-08-24 08:24:31 +02:00
2b12264304 Axis and SoapServer interop tests 2013-08-23 23:25:16 +02:00
f8a80c0361 fix wrong method call 2013-08-23 21:45:09 +02:00
19def707d3 use WsSecurityFilterClientServer from common 2013-08-23 20:59:35 +02:00
b21d758e77 remove now obsolete code 2013-08-23 20:57:37 +02:00
9bc9410172 add BinarySecurityToken resolving to key resolver 2013-08-23 20:57:07 +02:00
1cde22d8bb fix securitykey factory method call 2013-08-23 20:56:37 +02:00
8d62141a3d add workaround for cli webserver option 2013-08-23 20:55:26 +02:00
96f8415b92 added encryption to WS Security 2013-08-23 20:48:13 +02:00
5229091033 further steps with WS-Security (signing) 2013-08-23 20:47:55 +02:00
580e6f4da7 added WsSecurityFilter that supports UsernamePassword for now 2013-08-23 20:47:41 +02:00
6a5109c526 fix SoapFault handling to throw proper soap fault to client 2013-08-23 20:47:20 +02:00
5e6fd5de25 extract common code used in client/server 2013-08-23 20:43:48 +02:00
ee321fca42 fix missing 'cid:' in SwaTypeConverter 2013-08-23 20:43:22 +02:00
b5af83f9d2 add workaround for cli webserver, option implemented in client 2013-08-23 20:30:50 +02:00
9f9bab242d Fixed composer.json 2013-08-16 17:36:03 +02:00
f792f53aa2 Added composer.json 2013-08-16 17:18:40 +02:00
4d9b112bb5 Updated version to 0.2 2013-08-16 17:18:31 +02:00
153 changed files with 5104 additions and 2466 deletions

View File

@ -14,6 +14,8 @@ env:
before_script: before_script:
- composer require symfony/http-foundation:${SYMFONY_VERSION} --no-interaction --prefer-source - composer require symfony/http-foundation:${SYMFONY_VERSION} --no-interaction --prefer-source
- ./src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh
- ./src/BeSimple/SoapClient/Tests/bin/axis.sh
script: script:
- phpunit --coverage-text - phpunit --coverage-text

56
README.md Normal file
View File

@ -0,0 +1,56 @@
# BeSimpleSoap
Build SOAP and WSDL based web services
# Components
BeSimpleSoap consists of five components ...
## BeSimpleSoapBundle
The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services.
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapBundle/README.md).
## BeSimpleSoapClient
The BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA, MTOM and WS-Security.
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapClient/README.md).
## BeSimpleSoapCommon
The BeSimpleSoapCommon component contains functionylity shared by both the server and client implementations.
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapCommon/README.md).
## BeSimpleSoapServer
The BeSimpleSoapServer is a component that extends the native PHP SoapServer with further features like SwA, MTOM and WS-Security.
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapServer/README.md).
## BeSimpleSoapWsdl
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapWsdl/README.md).
# Installation
If you do not yet have composer, install it like this:
```sh
curl -s http://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin
```
Create a `composer.json` file:
```json
{
"require": {
"besimple/soap": "0.2.*@dev"
}
}
```
Now you are ready to install the library:
```sh
php /usr/local/bin/composer.phar install
```

View File

@ -23,17 +23,17 @@
"php": ">=5.3.0", "php": ">=5.3.0",
"ext-soap": "*", "ext-soap": "*",
"ext-curl": "*", "ext-curl": "*",
"ass/xmlsecurity": "dev-master", "ass/xmlsecurity": "~1.0",
"symfony/framework-bundle": "~2.0", "symfony/framework-bundle": "~2.0",
"zendframework/zend-mail": "2.1.*", "symfony/twig-bundle": "~2.0",
"zendframework/zend-mime": "2.1.*", "zendframework/zend-mime": "2.1.*"
"zendframework/zend-soap": "2.1.*"
}, },
"replace": { "replace": {
"besimple/soap-bundle": "self.version", "besimple/soap-bundle": "self.version",
"besimple/soap-client": "self.version", "besimple/soap-client": "self.version",
"besimple/soap-common": "self.version", "besimple/soap-common": "self.version",
"besimple/soap-server": "self.version" "besimple/soap-server": "self.version",
"besimple/soap-wsdl": "self.version"
}, },
"require-dev": { "require-dev": {
"ext-mcrypt": "*", "ext-mcrypt": "*",
@ -47,7 +47,7 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.1-dev" "dev-master": "0.2-dev"
} }
} }
} }

View File

@ -12,14 +12,17 @@
namespace BeSimple\SoapBundle\Controller; namespace BeSimple\SoapBundle\Controller;
use BeSimple\SoapBundle\Handler\ExceptionHandler;
use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapRequest;
use BeSimple\SoapBundle\Soap\SoapResponse; use BeSimple\SoapBundle\Soap\SoapResponse;
use BeSimple\SoapServer\Exception as SoapException; use BeSimple\SoapServer\SoapServerBuilder;
use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
/** /**
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
@ -64,6 +67,7 @@ class SoapWebServiceController extends ContainerAware
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
$this->soapServer = $webServiceContext $this->soapServer = $webServiceContext
->getServerBuilder() ->getServerBuilder()
->withSoapVersion11()
->withHandler($this) ->withHandler($this)
->build() ->build()
; ;
@ -91,14 +95,69 @@ class SoapWebServiceController extends ContainerAware
) )
)); ));
$query = $this->container->get('request')->query; $request = $this->container->get('request');
if (!$query->has('wsdl') && !$query->has('WSDL')) { $query = $request->query;
$this->container->get('request')->setRequestFormat('xml'); if ($query->has('wsdl') || $query->has('WSDL')) {
$request->setRequestFormat('wsdl');
} }
return $response; return $response;
} }
/**
* Converts an Exception to a SoapFault Response.
*
* @param Request $request The request
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
*
* @return Response
*
* @throws \LogicException When the request query parameter "_besimple_soap_webservice" does not exist
*/
public function exceptionAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
{
if (!$webservice = $request->query->get('_besimple_soap_webservice')) {
throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e);
}
$view = 'TwigBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig';
$code = $exception->getStatusCode();
$details = $this->container->get('templating')->render($view, array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
));
$handler = new ExceptionHandler($exception, $details);
if ($soapFault = $request->query->get('_besimple_soap_fault')) {
$handler->setSoapFault($soapFault);
// Remove parameter from query because cannot be Serialized in Logger
$request->query->remove('_besimple_soap_fault');
}
$server = SoapServerBuilder::createWithDefaults()
->withWsdl(__DIR__.'/../Handler/wsdl/exception.wsdl')
->withWsdlCacheNone()
->withHandler($handler)
->build()
;
ob_start();
$server->handle(
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://besim.pl/soap/exception/1.0/">'.
'<soapenv:Header/>'.
'<soapenv:Body>'.
'<ns:exception />'.
'</soapenv:Body>'.
'</soapenv:Envelope>'
);
return new Response(ob_get_clean());
}
/** /**
* This method gets called once for every SOAP header the \SoapServer received * This method gets called once for every SOAP header the \SoapServer received
* and afterwards once for the called SOAP operation. * and afterwards once for the called SOAP operation.
@ -124,13 +183,7 @@ class SoapWebServiceController extends ContainerAware
); );
// forward to controller // forward to controller
try { $response = $this->container->get('http_kernel')->handle($this->soapRequest, HttpKernelInterface::SUB_REQUEST, false);
$response = $this->container->get('http_kernel')->handle($this->soapRequest, HttpKernelInterface::SUB_REQUEST, false);
} catch (\Exception $e) {
$this->soapResponse = new Response(null, 500);
throw $e instanceof \SoapFault || $this->container->getParameter('kernel.debug') ? $e : new SoapException\ReceiverSoapFault($e->getMessage());
}
$this->setResponse($response); $this->setResponse($response);

View File

@ -12,8 +12,6 @@ namespace BeSimple\SoapBundle\Converter;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition; use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\Util\Assert; use BeSimple\SoapBundle\Util\Assert;
use BeSimple\SoapBundle\Util\QName;
use BeSimple\SoapBundle\Util\String;
/** /**
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
@ -50,8 +48,6 @@ class TypeRepository
public function fixTypeInformation(ServiceDefinition $definition) public function fixTypeInformation(ServiceDefinition $definition)
{ {
$typeMap = $this->defaultTypeMap;
foreach($definition->getAllTypes() as $type) { foreach($definition->getAllTypes() as $type) {
$phpType = $type->getPhpType(); $phpType = $type->getPhpType();
$xmlType = $type->getXmlType(); $xmlType = $type->getXmlType();
@ -67,4 +63,4 @@ class TypeRepository
$type->setXmlType($xmlType); $type->setXmlType($xmlType);
} }
} }
} }

View File

@ -13,6 +13,7 @@ namespace BeSimple\SoapBundle\Converter;
use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapRequest;
use BeSimple\SoapBundle\Soap\SoapResponse; use BeSimple\SoapBundle\Soap\SoapResponse;
use BeSimple\SoapBundle\Util\String; use BeSimple\SoapBundle\Util\String;
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
/** /**
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
@ -52,4 +53,4 @@ class XopIncludeTypeConverter implements TypeConverterInterface
{ {
return $data; return $data;
} }
} }

View File

@ -63,6 +63,8 @@ class BeSimpleSoapExtension extends Extension
$serviceConfig['name'] = $name; $serviceConfig['name'] = $name;
$this->createWebServiceContext($serviceConfig, $container); $this->createWebServiceContext($serviceConfig, $container);
} }
$container->setParameter('besimple.soap.exception_listener.controller', $config['exception_controller']);
} }
private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
@ -82,7 +84,7 @@ class BeSimpleSoapExtension extends Extension
foreach ($config as $client => $options) { foreach ($config as $client => $options) {
$definition = new DefinitionDecorator('besimple.soap.client.builder'); $definition = new DefinitionDecorator('besimple.soap.client.builder');
$context = $container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition); $container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition);
$definition->replaceArgument(0, $options['wsdl']); $definition->replaceArgument(0, $options['wsdl']);
@ -102,12 +104,8 @@ class BeSimpleSoapExtension extends Extension
$definition->replaceArgument(1, $defOptions); $definition->replaceArgument(1, $defOptions);
if (!empty($options['classmap'])) { $classmap = $this->createClientClassmap($client, $options['classmap'], $container);
$classmap = $this->createClientClassmap($client, $options['classmap'], $container); $definition->replaceArgument(2, new Reference($classmap));
$definition->replaceArgument(2, new Reference($classmap));
} else {
$definition->replaceArgument(2, null);
}
$this->createClient($client, $container); $this->createClient($client, $container);
} }
@ -116,11 +114,13 @@ class BeSimpleSoapExtension extends Extension
private function createClientClassmap($client, array $classmap, ContainerBuilder $container) private function createClientClassmap($client, array $classmap, ContainerBuilder $container)
{ {
$definition = new DefinitionDecorator('besimple.soap.classmap'); $definition = new DefinitionDecorator('besimple.soap.classmap');
$context = $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition); $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
$definition->setMethodCalls(array( if (!empty($classmap)) {
array('set', array($classmap)), $definition->setMethodCalls(array(
)); array('set', array($classmap)),
));
}
return sprintf('besimple.soap.classmap.%s', $client); return sprintf('besimple.soap.classmap.%s', $client);
} }
@ -128,7 +128,7 @@ class BeSimpleSoapExtension extends Extension
private function createClient($client, ContainerBuilder $container) private function createClient($client, ContainerBuilder $container)
{ {
$definition = new DefinitionDecorator('besimple.soap.client'); $definition = new DefinitionDecorator('besimple.soap.client');
$context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client)); $definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
} }
@ -140,7 +140,7 @@ class BeSimpleSoapExtension extends Extension
$contextId = 'besimple.soap.context.'.$config['name']; $contextId = 'besimple.soap.context.'.$config['name'];
$definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix); $definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix);
$context = $container->setDefinition($contextId, $definition); $container->setDefinition($contextId, $definition);
if (isset($config['cache_type'])) { if (isset($config['cache_type'])) {
$config['cache_type'] = $this->getCacheType($config['cache_type']); $config['cache_type'] = $this->getCacheType($config['cache_type']);
@ -148,9 +148,9 @@ class BeSimpleSoapExtension extends Extension
$options = $container $options = $container
->getDefinition('besimple.soap.context.'.$bindingSuffix) ->getDefinition('besimple.soap.context.'.$bindingSuffix)
->getArgument(5); ->getArgument(2);
$definition->replaceArgument(5, array_merge($options, $config)); $definition->replaceArgument(2, array_merge($options, $config));
} }
private function getCacheType($type) private function getCacheType($type)

View File

@ -40,6 +40,12 @@ class Configuration
$this->addServicesSection($rootNode); $this->addServicesSection($rootNode);
$this->addWsdlDumperSection($rootNode); $this->addWsdlDumperSection($rootNode);
$rootNode
->children()
->scalarNode('exception_controller')->defaultValue('BeSimpleSoapBundle:SoapWebService:exception')->end()
->end()
;
return $treeBuilder->buildTree(); return $treeBuilder->buildTree();
} }

View File

@ -2,7 +2,6 @@
namespace BeSimple\SoapBundle\EventListener; namespace BeSimple\SoapBundle\EventListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class RequestFormatListener class RequestFormatListener

View File

@ -0,0 +1,85 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\EventListener;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\EventListener\ExceptionListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* @author Francis Besset <francis.besset@gmail.com>
*/
class SoapExceptionListener extends ExceptionListener
{
/**
* @var ContainerInterface
*/
protected $container;
/**
* To avoid conflict between , the logger param is not typed:
* The parent class needs and instance of `Psr\Log\LoggerInterface` from Symfony 2.2,
* before logger is an instance of `Symfony\Component\HttpKernel\Log\LoggerInterface`.
*
* @param ContainerInterface $container A ContainerInterface instance
* @param string $controller The controller name to call
* @param LoggerInterface $logger A logger instance
*/
public function __construct(ContainerInterface $container, $controller, $logger)
{
parent::__construct($controller, $logger);
$this->container = $container;
}
public function onKernelException(GetResponseForExceptionEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$request = $event->getRequest();
if ('soap' !== $request->getRequestFormat()) {
return;
}
$attributes = $request->attributes;
if (!$webservice = $attributes->get('webservice')) {
return;
}
if (!$this->container->has(sprintf('besimple.soap.context.%s', $webservice))) {
return;
}
// hack to retrieve the current WebService name in the controller
$request->query->set('_besimple_soap_webservice', $webservice);
$exception = $event->getException();
if ($exception instanceof \SoapFault) {
$request->query->set('_besimple_soap_fault', $exception);
}
parent::onKernelException($event);
}
public static function getSubscribedEvents()
{
return array(
// Must be called before ExceptionListener of HttpKernel component
KernelEvents::EXCEPTION => array('onKernelException', -64),
);
}
}

View File

@ -0,0 +1,53 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\Handler;
use BeSimple\SoapServer\Exception\ReceiverSoapFault;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\FlattenException;
/**
* @author Francis Besset <francis.besset@gmail.com>
*/
class ExceptionHandler
{
protected $exception;
protected $details;
protected $soapFault;
public function __construct(FlattenException $exception, $details = null)
{
$this->exception = $exception;
$this->details = $details;
}
public function setSoapFault(\SoapFault $soapFault)
{
$this->soapFault = $soapFault;
}
public function __call($method, $arguments)
{
if (isset($this->soapFault)) {
throw $this->soapFault;
}
$code = $this->exception->getStatusCode();
throw new ReceiverSoapFault(
isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
null,
$this->details
);
}
}

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://besim.pl/soap/exception/1.0/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Exception" targetNamespace="http://besim.pl/soap/exception/1.0/">
<portType name="ExceptionPortType">
<operation name="exception">
<input message="tns:empty"/>
<output message="tns:empty"/>
</operation>
</portType>
<message name="empty" />
<binding name="ExceptionBinding" type="tns:ExceptionPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="exception">
<soap:operation soapAction="http://besim.pl/soap/exception/1.0/exception"/>
<input>
<soap:body use="literal" namespace="http://besim.pl/soap/exception/1.0/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="literal" namespace="http://besim.pl/soap/exception/1.0/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="ExceptionService">
<port name="ExceptionPort" binding="tns:ExceptionBinding">
<soap:address location="http://localhost/soap/Exception"/>
</port>
</service>
</definitions>

View File

@ -29,10 +29,13 @@
<service id="besimple.soap.definition.loader.annot_class" class="%besimple.soap.definition.loader.annot_class.class%" public="false"> <service id="besimple.soap.definition.loader.annot_class" class="%besimple.soap.definition.loader.annot_class.class%" public="false">
<tag name="besimple.soap.definition.loader" /> <tag name="besimple.soap.definition.loader" />
<argument type="service" id="annotation_reader" /> <argument type="service" id="annotation_reader" />
<argument type="service" id="besimple.soap.type.repository" />
</service> </service>
<service id="besimple.soap.definition.loader.annot_complextype" class="%besimple.soap.definition.loader.annot_complextype.class%" public="false"> <service id="besimple.soap.definition.loader.annot_complextype" class="%besimple.soap.definition.loader.annot_complextype.class%" public="false">
<tag name="besimple.soap.definition.loader" />
<argument type="service" id="annotation_reader" /> <argument type="service" id="annotation_reader" />
<argument type="service" id="besimple.soap.type.repository" />
</service> </service>
</services> </services>

View File

@ -6,13 +6,13 @@
<route id="_webservice_call" pattern="/{webservice}"> <route id="_webservice_call" pattern="/{webservice}">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default> <default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
<default key="_format">soap</default> <default key="_format">xml</default>
<requirement key="_method">POST</requirement> <requirement key="_method">POST</requirement>
</route> </route>
<route id="_webservice_definition" pattern="/{webservice}"> <route id="_webservice_definition" pattern="/{webservice}">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default> <default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
<default key="_format">wsdl</default> <default key="_format">xml</default>
<requirement key="_method">GET</requirement> <requirement key="_method">GET</requirement>
</route> </route>
</routes> </routes>

View File

@ -6,6 +6,7 @@
<parameters> <parameters>
<parameter key="besimple.soap.response.class">BeSimple\SoapBundle\Soap\SoapResponse</parameter> <parameter key="besimple.soap.response.class">BeSimple\SoapBundle\Soap\SoapResponse</parameter>
<parameter key="besimple.soap.response.listener.class">BeSimple\SoapBundle\EventListener\SoapResponseListener</parameter> <parameter key="besimple.soap.response.listener.class">BeSimple\SoapBundle\EventListener\SoapResponseListener</parameter>
<parameter key="besimple.soap.exception_listener.class">BeSimple\SoapBundle\EventListener\SoapExceptionListener</parameter>
<parameter key="besimple.soap.context.class">BeSimple\SoapBundle\WebServiceContext</parameter> <parameter key="besimple.soap.context.class">BeSimple\SoapBundle\WebServiceContext</parameter>
<parameter key="besimple.soap.binder.request_header.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestHeaderMessageBinder</parameter> <parameter key="besimple.soap.binder.request_header.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestHeaderMessageBinder</parameter>
<parameter key="besimple.soap.binder.request.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestMessageBinder</parameter> <parameter key="besimple.soap.binder.request.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestMessageBinder</parameter>
@ -13,8 +14,7 @@
<parameter key="besimple.soap.binder.request.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedRequestMessageBinder</parameter> <parameter key="besimple.soap.binder.request.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedRequestMessageBinder</parameter>
<parameter key="besimple.soap.binder.request_header.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedRequestHeaderMessageBinder</parameter> <parameter key="besimple.soap.binder.request_header.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedRequestHeaderMessageBinder</parameter>
<parameter key="besimple.soap.binder.response.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedResponseMessageBinder</parameter> <parameter key="besimple.soap.binder.response.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedResponseMessageBinder</parameter>
<parameter key="besimple.soap.definition.dumper.wsdl.rpcliteral.class">BeSimple\SoapBundle\ServiceDefinition\Dumper\WsdlDumper</parameter> <parameter key="besimple.soap.type.repository.class">BeSimple\SoapCommon\Definition\Type\TypeRepository</parameter>
<parameter key="besimple.soap.type.repository.class">BeSimple\SoapBundle\Converter\TypeRepository</parameter>
<parameter key="besimple.soap.server.classmap.class">BeSimple\SoapServer\Classmap</parameter> <parameter key="besimple.soap.server.classmap.class">BeSimple\SoapServer\Classmap</parameter>
</parameters> </parameters>
@ -26,11 +26,16 @@
<argument type="service" id="besimple.soap.response" /> <argument type="service" id="besimple.soap.response" />
</service> </service>
<service id="besimple.soap.exception_listener" class="%besimple.soap.exception_listener.class%">
<tag name="kernel.event_subscriber" />
<tag name="monolog.logger" channel="request" />
<argument type="service" id="service_container" />
<argument>%besimple.soap.exception_listener.controller%</argument>
<argument type="service" id="logger" on-invalid="null" />
</service>
<service id="besimple.soap.context.rpcliteral" class="%besimple.soap.context.class%" abstract="true"> <service id="besimple.soap.context.rpcliteral" class="%besimple.soap.context.class%" abstract="true">
<argument type="service" id="besimple.soap.definition.loader" /> <argument type="service" id="besimple.soap.definition.loader" />
<argument type="service" id="besimple.soap.definition.dumper.wsdl.rpcliteral" />
<argument type="service" id="besimple.soap.server.classmap" />
<argument type="service" id="besimple.soap.type.repository" />
<argument type="service" id="besimple.soap.converter.collection" /> <argument type="service" id="besimple.soap.converter.collection" />
<argument type="collection"> <argument type="collection">
<argument key="cache_dir">%besimple.soap.cache.dir%</argument> <argument key="cache_dir">%besimple.soap.cache.dir%</argument>
@ -39,15 +44,13 @@
<argument key="binder_request_header_class">%besimple.soap.binder.request_header.rpcliteral.class%</argument> <argument key="binder_request_header_class">%besimple.soap.binder.request_header.rpcliteral.class%</argument>
<argument key="binder_request_class">%besimple.soap.binder.request.rpcliteral.class%</argument> <argument key="binder_request_class">%besimple.soap.binder.request.rpcliteral.class%</argument>
<argument key="binder_response_class">%besimple.soap.binder.response.rpcliteral.class%</argument> <argument key="binder_response_class">%besimple.soap.binder.response.rpcliteral.class%</argument>
<argument key="wsdl_stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument>
</argument> </argument>
<argument type="service" id="besimple.soap.cache" /> <argument type="service" id="besimple.soap.cache" />
</service> </service>
<service id="besimple.soap.context.documentwrapped" class="%besimple.soap.context.class%" abstract="true"> <service id="besimple.soap.context.documentwrapped" class="%besimple.soap.context.class%" abstract="true">
<argument type="service" id="besimple.soap.definition.loader" /> <argument type="service" id="besimple.soap.definition.loader" />
<argument type="service" id="besimple.soap.definition.dumper.wsdl.documentwrapped" />
<argument type="service" id="besimple.soap.server.classmap" />
<argument type="service" id="besimple.soap.type.repository" />
<argument type="service" id="besimple.soap.converter.collection" /> <argument type="service" id="besimple.soap.converter.collection" />
<argument type="collection"> <argument type="collection">
<argument key="cache_dir">%besimple.soap.cache.dir%</argument> <argument key="cache_dir">%besimple.soap.cache.dir%</argument>
@ -56,46 +59,40 @@
<argument key="binder_request_header_class">%besimple.soap.binder.request_header.documentwrapped.class%</argument> <argument key="binder_request_header_class">%besimple.soap.binder.request_header.documentwrapped.class%</argument>
<argument key="binder_request_class">%besimple.soap.binder.request.documentwrapped.class%</argument> <argument key="binder_request_class">%besimple.soap.binder.request.documentwrapped.class%</argument>
<argument key="binder_response_class">%besimple.soap.binder.response.documentwrapped.class%</argument> <argument key="binder_response_class">%besimple.soap.binder.response.documentwrapped.class%</argument>
<argument key="wsdl_stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument>
</argument> </argument>
<argument type="service" id="besimple.soap.cache" /> <argument type="service" id="besimple.soap.cache" />
</service> </service>
<service id="besimple.soap.definition.dumper.wsdl.rpcliteral" class="%besimple.soap.definition.dumper.wsdl.rpcliteral.class%">
<argument type="service" id="besimple.soap.definition.loader.annot_complextype" />
<argument type="service" id="besimple.soap.type.repository" />
<argument type="collection">
<argument key="stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument>
</argument>
</service>
<service id="besimple.soap.server.classmap" class="%besimple.soap.server.classmap.class%" public="false" /> <service id="besimple.soap.server.classmap" class="%besimple.soap.server.classmap.class%" public="false" />
<service id="besimple.soap.type.repository" class="%besimple.soap.type.repository.class%"> <service id="besimple.soap.type.repository" class="%besimple.soap.type.repository.class%">
<argument type="service" id="besimple.soap.server.classmap" />
<call method="addXmlNamespace"> <call method="addXmlNamespace">
<argument>xsd</argument> <argument>xsd</argument>
<argument>http://www.w3.org/2001/XMLSchema</argument> <argument>http://www.w3.org/2001/XMLSchema</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addType">
<argument>string</argument> <argument>string</argument>
<argument>xsd:string</argument> <argument>xsd:string</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addType">
<argument>boolean</argument> <argument>boolean</argument>
<argument>xsd:boolean</argument> <argument>xsd:boolean</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addType">
<argument>int</argument> <argument>int</argument>
<argument>xsd:int</argument> <argument>xsd:int</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addType">
<argument>float</argument> <argument>float</argument>
<argument>xsd:float</argument> <argument>xsd:float</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addType">
<argument>date</argument> <argument>date</argument>
<argument>xsd:date</argument> <argument>xsd:date</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addType">
<argument>dateTime</argument> <argument>dateTime</argument>
<argument>xsd:dateTime</argument> <argument>xsd:dateTime</argument>
</call> </call>

View File

@ -11,6 +11,7 @@
namespace BeSimple\SoapBundle\ServiceBinding; namespace BeSimple\SoapBundle\ServiceBinding;
use BeSimple\SoapBundle\ServiceDefinition\Method; use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
/** /**
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
@ -23,5 +24,5 @@ interface MessageBinderInterface
* *
* @return mixed * @return mixed
*/ */
function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()); function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository);
} }

View File

@ -11,6 +11,7 @@
namespace BeSimple\SoapBundle\ServiceBinding; namespace BeSimple\SoapBundle\ServiceBinding;
use BeSimple\SoapBundle\ServiceDefinition\Method; use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
/** /**
* @author Francis Besset <francis.besset@gmail.com> * @author Francis Besset <francis.besset@gmail.com>
@ -24,10 +25,11 @@ class RpcLiteralRequestHeaderMessageBinder extends RpcLiteralRequestMessageBinde
$this->header = $header; $this->header = $header;
} }
public function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()) public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
{ {
$this->typeRepository = $typeRepository;
$headerDefinition = $messageDefinition->getHeaders()->get($this->header); $headerDefinition = $messageDefinition->getHeaders()->get($this->header);
return $this->processType($headerDefinition->getType()->getPhpType(), $message, $definitionComplexTypes); return $this->processType($headerDefinition->getType(), $message);
} }
} }

View File

@ -13,8 +13,9 @@
namespace BeSimple\SoapBundle\ServiceBinding; namespace BeSimple\SoapBundle\ServiceBinding;
use BeSimple\SoapBundle\ServiceDefinition\Method; use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType; use BeSimple\SoapCommon\Definition\Type\ArrayOfType;
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType; use BeSimple\SoapCommon\Definition\Type\ComplexType;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
use BeSimple\SoapCommon\Util\MessageBinder; use BeSimple\SoapCommon\Util\MessageBinder;
/** /**
@ -23,19 +24,20 @@ use BeSimple\SoapCommon\Util\MessageBinder;
*/ */
class RpcLiteralRequestMessageBinder implements MessageBinderInterface class RpcLiteralRequestMessageBinder implements MessageBinderInterface
{ {
private $messageRefs = array(); protected $typeRepository;
private $definitionComplexTypes;
public function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()) private $messageRefs = array();
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
{ {
$this->definitionComplexTypes = $definitionComplexTypes; $this->typeRepository = $typeRepository;
$result = array(); $result = array();
$i = 0; $i = 0;
foreach ($messageDefinition->getArguments() as $argument) { foreach ($messageDefinition->getInput()->all() as $argument) {
if (isset($message[$i])) { if (isset($message[$i])) {
$result[$argument->getName()] = $this->processType($argument->getType()->getPhpType(), $message[$i]); $result[$argument->getName()] = $this->processType($argument->getType(), $message[$i]);
} }
$i++; $i++;
@ -48,14 +50,18 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
{ {
$isArray = false; $isArray = false;
if (preg_match('/^([^\[]+)\[\]$/', $phpType, $match)) { $type = $this->typeRepository->getType($phpType);
if ($type instanceof ArrayOfType) {
$isArray = true; $isArray = true;
$array = array(); $array = array();
$phpType = $match[1];
$type = $this->typeRepository->getType($type->get('item')->getType());
} }
// @TODO Fix array reference // @TODO Fix array reference
if (isset($this->definitionComplexTypes[$phpType])) { if ($type instanceof ComplexType) {
$phpType = $type->getPhpType();
if ($isArray) { if ($isArray) {
if (isset($message->item)) { if (isset($message->item)) {
foreach ($message->item as $complexType) { foreach ($message->item as $complexType) {
@ -98,17 +104,16 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
$this->messageRefs[$hash] = $message; $this->messageRefs[$hash] = $message;
$messageBinder = new MessageBinder($message); $messageBinder = new MessageBinder($message);
foreach ($this->definitionComplexTypes[$phpType]['properties'] as $type) { foreach ($this->typeRepository->getType($phpType)->all() as $type) {
$property = $type->getName(); $property = $type->getName();
$value = $messageBinder->readProperty($property); $value = $messageBinder->readProperty($property);
if (null !== $value) { if (null !== $value) {
$value = $this->processType($type->getValue(), $value); $value = $this->processType($type->getType(), $value);
$messageBinder->writeProperty($property, $value); $messageBinder->writeProperty($property, $value);
} } elseif (!$type->isNillable()) {
// @TODO use xmlType instead of phpType
if (!$type->isNillable() && null === $value) {
throw new \SoapFault('SOAP_ERROR_COMPLEX_TYPE', sprintf('"%s:%s" cannot be null.', ucfirst($phpType), $type->getName())); throw new \SoapFault('SOAP_ERROR_COMPLEX_TYPE', sprintf('"%s:%s" cannot be null.', ucfirst($phpType), $type->getName()));
} }
} }

View File

@ -13,8 +13,9 @@
namespace BeSimple\SoapBundle\ServiceBinding; namespace BeSimple\SoapBundle\ServiceBinding;
use BeSimple\SoapBundle\ServiceDefinition\Method; use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType; use BeSimple\SoapCommon\Definition\Type\ArrayOfType;
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType; use BeSimple\SoapCommon\Definition\Type\ComplexType;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
use BeSimple\SoapCommon\Util\MessageBinder; use BeSimple\SoapCommon\Util\MessageBinder;
/** /**
@ -23,26 +24,31 @@ use BeSimple\SoapCommon\Util\MessageBinder;
*/ */
class RpcLiteralResponseMessageBinder implements MessageBinderInterface class RpcLiteralResponseMessageBinder implements MessageBinderInterface
{ {
protected $typeRepository;
private $messageRefs = array(); private $messageRefs = array();
private $definitionComplexTypes;
public function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()) public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
{ {
$this->definitionComplexTypes = $definitionComplexTypes; $this->typeRepository = $typeRepository;
return $this->processType($messageDefinition->getReturn()->getPhpType(), $message); return $this->processType($messageDefinition->getOutput()->get('return')->getType(), $message);
} }
private function processType($phpType, $message) private function processType($phpType, $message)
{ {
$isArray = false; $isArray = false;
if (preg_match('/^([^\[]+)\[\]$/', $phpType, $match)) { $type = $this->typeRepository->getType($phpType);
if ($type instanceof ArrayOfType) {
$isArray = true; $isArray = true;
$phpType = $match[1];
$type = $this->typeRepository->getType($type->get('item')->getType());
} }
if (isset($this->definitionComplexTypes[$phpType])) { if ($type instanceof ComplexType) {
$phpType = $type->getPhpType();
if ($isArray) { if ($isArray) {
$array = array(); $array = array();
@ -79,16 +85,16 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
$this->messageRefs[$hash] = $message; $this->messageRefs[$hash] = $message;
if (!$message instanceof $phpType) { if (!$message instanceof $phpType) {
throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', get_class($message), $phpType)); throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', $phpType, get_class($message)));
} }
$messageBinder = new MessageBinder($message); $messageBinder = new MessageBinder($message);
foreach ($this->definitionComplexTypes[$phpType]['properties'] as $type) { foreach ($this->typeRepository->getType($phpType)->all() as $type) {
$property = $type->getName(); $property = $type->getName();
$value = $messageBinder->readProperty($property); $value = $messageBinder->readProperty($property);
if (null !== $value) { if (null !== $value) {
$value = $this->processType($type->getValue(), $value); $value = $this->processType($type->getType(), $value);
$messageBinder->writeProperty($property, $value); $messageBinder->writeProperty($property, $value);
} }

View File

@ -10,8 +10,7 @@
namespace BeSimple\SoapBundle\ServiceBinding; namespace BeSimple\SoapBundle\ServiceBinding;
use BeSimple\SoapBundle\ServiceDefinition\Header; use BeSimple\SoapBundle\ServiceDefinition\Definition;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\Soap\SoapHeader; use BeSimple\SoapBundle\Soap\SoapHeader;
/** /**
@ -40,12 +39,12 @@ class ServiceBinder
private $responseMessageBinder; private $responseMessageBinder;
/** /**
* @param ServiceDefinition $definition * @param Definition $definition
* @param MessageBinderInterface $requestHeaderMessageBinder * @param MessageBinderInterface $requestHeaderMessageBinder
* @param MessageBinderInterface $requestMessageBinder * @param MessageBinderInterface $requestMessageBinder
* @param MessageBinderInterface $responseMessageBinder * @param MessageBinderInterface $responseMessageBinder
*/ */
public function __construct(ServiceDefinition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) { public function __construct(Definition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) {
$this->definition = $definition; $this->definition = $definition;
$this->requestHeaderMessageBinder = $requestHeaderMessageBinder; $this->requestHeaderMessageBinder = $requestHeaderMessageBinder;
@ -62,7 +61,7 @@ class ServiceBinder
*/ */
public function isServiceHeader($method, $header) public function isServiceHeader($method, $header)
{ {
return $this->definition->getMethods()->get($method)->getHeaders()->has($header); return $this->definition->getMethod($method)->getHeader($header);
} }
/** /**
@ -72,7 +71,7 @@ class ServiceBinder
*/ */
public function isServiceMethod($method) public function isServiceMethod($method)
{ {
return $this->definition->getMethods()->has($method); return null !== $this->definition->getMethod($method);
} }
/** /**
@ -84,11 +83,11 @@ class ServiceBinder
*/ */
public function processServiceHeader($method, $header, $data) public function processServiceHeader($method, $header, $data)
{ {
$methodDefinition = $this->definition->getMethods()->get($method); $methodDefinition = $this->definition->getMethod($method);
$headerDefinition = $methodDefinition->getHeaders()->get($header); $headerDefinition = $methodDefinition->getHeader($header);
$this->requestHeaderMessageBinder->setHeader($header); $this->requestHeaderMessageBinder->setHeader($header);
$data = $this->requestHeaderMessageBinder->processMessage($methodDefinition, $data, $this->definition->getDefinitionComplexTypes()); $data = $this->requestHeaderMessageBinder->processMessage($methodDefinition, $data, $this->definition->getTypeRepository());
return new SoapHeader($this->definition->getNamespace(), $headerDefinition->getName(), $data); return new SoapHeader($this->definition->getNamespace(), $headerDefinition->getName(), $data);
} }
@ -101,11 +100,11 @@ class ServiceBinder
*/ */
public function processServiceMethodArguments($method, $arguments) public function processServiceMethodArguments($method, $arguments)
{ {
$methodDefinition = $this->definition->getMethods()->get($method); $methodDefinition = $this->definition->getMethod($method);
return array_merge( return array_merge(
array('_controller' => $methodDefinition->getController()), array('_controller' => $methodDefinition->getController()),
$this->requestMessageBinder->processMessage($methodDefinition, $arguments, $this->definition->getDefinitionComplexTypes()) $this->requestMessageBinder->processMessage($methodDefinition, $arguments, $this->definition->getTypeRepository())
); );
} }
@ -117,8 +116,8 @@ class ServiceBinder
*/ */
public function processServiceMethodReturnValue($name, $return) public function processServiceMethodReturnValue($name, $return)
{ {
$methodDefinition = $this->definition->getMethods()->get($name); $methodDefinition = $this->definition->getMethod($name);
return $this->responseMessageBinder->processMessage($methodDefinition, $return, $this->definition->getDefinitionComplexTypes()); return $this->responseMessageBinder->processMessage($methodDefinition, $return, $this->definition->getTypeRepository());
} }
} }

View File

@ -1,43 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition;
class Argument
{
private $name;
private $type;
public function __construct($name = null, Type $type = null)
{
$this->setName($name);
$this->setType($type);
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getType()
{
return $this->type;
}
public function setType(Type $type)
{
$this->type = $type;
}
}

View File

@ -1,8 +1,10 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapBundle. * This file is part of the BeSimpleSoap.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
* *
* This source file is subject to the MIT license that is bundled * This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
@ -48,4 +50,4 @@ class ComplexType
{ {
$this->isNillable = (bool) $isNillable; $this->isNillable = (bool) $isNillable;
} }
} }

View File

@ -0,0 +1,44 @@
<?php
/*
* This file is part of the BeSimpleSoap.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition;
use BeSimple\SoapCommon\Definition\Definition as BaseDefinition;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
/**
* @author Christian Kerl <christian-kerl@web.de>
* @author Francis Besset <francis.besset@gmail.com>
*/
class Definition extends BaseDefinition
{
public function __construct(TypeRepository $typeRepository)
{
$this->typeRepository = $typeRepository;
$this->setOptions(array());
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function setNamespace($namespace)
{
$this->namespace = $namespace;
return $this;
}
}

View File

@ -1,18 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
interface DumperInterface
{
function dumpServiceDefinition(ServiceDefinition $definition, $endpoint);
}

View File

@ -1,80 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\Converter\TypeRepository;
use BeSimple\SoapBundle\ServiceDefinition\Type;
use Zend\Soap\Wsdl as BaseWsdl;
/**
* @author Francis Besset <francis.besset@gmail.com>
*/
class Wsdl extends BaseWsdl
{
private $typeRepository;
public function __construct(TypeRepository $typeRepository, $name, $uri, $strategy = true)
{
$this->typeRepository = $typeRepository;
parent::__construct($name, $uri, $strategy);
}
public function getType($type)
{
if ($type instanceof Type) {
return $type->getXmlType();
}
if ('\\' === $type[0]) {
$type = substr($type, 1);
}
if (!$xmlType = $this->typeRepository->getXmlTypeMapping($type)) {
$xmlType = $this->addComplexType($type);
}
return $xmlType;
}
/**
* Translate PHP type into WSDL QName
*
* @param string $type
* @return string QName
*/
public function translateType($type)
{
if (isset($this->classMap[$type])) {
return $this->classMap[$type];
}
return str_replace('\\', '.', $type);
}
public function addBindingOperationHeader(\DOMElement $bindingOperation, array $headers, array $baseBinding)
{
foreach ($headers as $header) {
$inputNode = $bindingOperation->getElementsByTagName('input')->item(0);
$headerNode = $this->toDomDocument()->createElement('soap:header');
$headerNode->setAttribute('part', $header);
foreach ($baseBinding as $name => $value) {
$headerNode->setAttribute($name, $value);
}
$inputNode->appendChild($headerNode);
}
return $bindingOperation;
}
}

View File

@ -1,177 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\Converter\TypeRepository;
use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapBundle\ServiceDefinition\Type;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
use BeSimple\SoapBundle\Util\Assert;
use BeSimple\SoapBundle\Util\QName;
/**
* @author Christian Kerl <christian-kerl@web.de>
*/
class WsdlDumper implements DumperInterface
{
private $loader;
private $typeRepository;
private $options;
private $wsdl;
private $definition;
public function __construct(AnnotationComplexTypeLoader $loader, TypeRepository $typeRepository, array $options)
{
$this->loader = $loader;
$this->typeRepository = $typeRepository;
$this->options = $options;
}
public function dumpServiceDefinition(ServiceDefinition $definition, $endpoint)
{
Assert::thatArgumentNotNull('definition', $definition);
$this->definition = $definition;
$this->wsdl = new Wsdl($this->typeRepository, $definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition));
$port = $this->wsdl->addPortType($this->getPortTypeName());
$binding = $this->wsdl->addBinding($this->getBindingName(), $this->qualify($this->getPortTypeName()));
$this->wsdl->addSoapBinding($binding, 'rpc');
$this->wsdl->addService($this->getServiceName(), $this->getPortName(), $this->qualify($this->getBindingName()), $endpoint);
foreach ($definition->getMethods() as $method) {
$requestHeaderParts =
$requestParts =
$responseParts = array();
foreach ($method->getHeaders() as $header) {
$requestHeaderParts[$header->getName()] = $this->wsdl->getType($header->getType()->getPhpType());
}
foreach ($method->getArguments() as $argument) {
$requestParts[$argument->getName()] = $this->wsdl->getType($argument->getType()->getPhpType());
}
if ($method->getReturn() !== null) {
$responseParts['return'] = $this->wsdl->getType($method->getReturn()->getPhpType());
}
if (!empty($requestHeaderParts)) {
$this->wsdl->addMessage($this->getRequestHeaderMessageName($method), $requestHeaderParts);
}
$this->wsdl->addMessage($this->getRequestMessageName($method), $requestParts);
$this->wsdl->addMessage($this->getResponseMessageName($method), $responseParts);
$portOperation = $this->wsdl->addPortOperation(
$port,
$method->getName(),
$this->qualify($this->getRequestMessageName($method)),
$this->qualify($this->getResponseMessageName($method))
);
$baseBinding =
$inputBinding =
$outputBinding = array(
'use' => 'literal',
'namespace' => $definition->getNamespace(),
'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
);
if (!empty($requestParts)) {
$portOperation->setAttribute('parameterOrder', implode(' ', array_keys($requestParts)));
$inputBinding['parts'] = implode(' ', array_keys($requestParts));
}
if (!empty($responseParts)) {
$outputBinding['parts'] = implode(' ', array_keys($responseParts));
}
$bindingOperation = $this->wsdl->addBindingOperation(
$binding,
$method->getName(),
$inputBinding,
$outputBinding
);
$bindingOperation = $this->wsdl->addBindingOperationHeader(
$bindingOperation,
array_keys($requestHeaderParts),
array_merge(array('message' => $this->qualify($this->getRequestHeaderMessageName($method))), $baseBinding)
);
$this->wsdl->addSoapOperation($bindingOperation, $this->getSoapOperationName($method));
}
$this->definition = null;
$dom = $this->wsdl->toDomDocument();
$dom->formatOutput = true;
if ($this->options['stylesheet']) {
$stylesheet = $dom->createProcessingInstruction('xml-stylesheet', sprintf('type="text/xsl" href="%s"', $this->options['stylesheet']));
$dom->insertBefore($stylesheet, $dom->documentElement);
}
return $this->wsdl->toXml();
}
protected function qualify($name, $namespace = null)
{
if($namespace === null) {
$namespace = $this->definition->getNamespace();
}
return $this->wsdl->toDomDocument()->lookupPrefix($namespace).':'.$name;
}
protected function getPortName()
{
return $this->definition->getName().'Port';
}
protected function getPortTypeName()
{
return $this->definition->getName().'PortType';
}
protected function getBindingName()
{
return $this->definition->getName().'Binding';
}
protected function getServiceName()
{
return $this->definition->getName().'Service';
}
protected function getRequestHeaderMessageName(Method $method)
{
return $method->getName().'Header';
}
protected function getRequestMessageName(Method $method)
{
return $method->getName().'Request';
}
protected function getResponseMessageName(Method $method)
{
return $method->getName().'Response';
}
protected function getSoapOperationName(Method $method)
{
return $this->definition->getNamespace().$method->getName();
}
}

View File

@ -1,95 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
use BeSimple\SoapBundle\ServiceDefinition\Strategy\ComplexType;
use BeSimple\SoapBundle\Util\String;
use Zend\Soap\Exception;
use Zend\Soap\Wsdl as BaseWsdl;
use Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface;
use Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence;
class WsdlTypeStrategy implements ComplexTypeStrategyInterface
{
/**
* Context WSDL file
*
* @var \Zend\Soap\Wsdl|null
*/
private $context;
private $loader;
private $definition;
private $typeStrategy;
private $arrayStrategy;
public function __construct(AnnotationComplexTypeLoader $loader, ServiceDefinition $definition)
{
$this->loader = $loader;
$this->definition = $definition;
}
/**
* Method accepts the current WSDL context file.
*
* @param \Zend\Soap\Wsdl $context
*/
public function setContext(BaseWsdl $context)
{
$this->context = $context;
return $this;
}
/**
* Create a complex type based on a strategy
*
* @param string $type
*
* @return string XSD type
*
* @throws \Zend\Soap\WsdlException
*/
public function addComplexType($type)
{
if (!$this->context) {
throw new \LogicException(sprintf('Cannot add complex type "%s", no context is set for this composite strategy.', $type));
}
$strategy = String::endsWith($type, '[]') ? $this->getArrayStrategy() : $this->getTypeStrategy();
return $strategy->addComplexType($type);
}
private function getArrayStrategy()
{
if (!$this->arrayStrategy) {
$this->arrayStrategy = new ArrayOfTypeSequence();
$this->arrayStrategy->setContext($this->context);
}
return $this->arrayStrategy;
}
private function getTypeStrategy()
{
if (!$this->typeStrategy) {
$this->typeStrategy = new ComplexType($this->loader, $this->definition);
$this->typeStrategy->setContext($this->context);
}
return $this->typeStrategy;
}
}

View File

@ -1,43 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition;
class Header
{
private $name;
private $type;
public function __construct($name = null, Type $type = null)
{
$this->setName($name);
$this->setType($type);
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getType()
{
return $this->type;
}
public function setType($type)
{
$this->type = $type;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapBundle. * This file is part of the BeSimpleSoap.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com> * (c) Francis Besset <francis.besset@gmail.com>
@ -14,11 +14,10 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Loader;
use BeSimple\SoapBundle\ServiceDefinition as Definition; use BeSimple\SoapBundle\ServiceDefinition as Definition;
use BeSimple\SoapBundle\ServiceDefinition\Annotation; use BeSimple\SoapBundle\ServiceDefinition\Annotation;
use BeSimple\SoapCommon\Definition\Type\ComplexType;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Annotations\Reader;
use Symfony\Component\Config\Loader\Loader; use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
/** /**
* AnnotationClassLoader loads ServiceDefinition from a PHP class and its methods. * AnnotationClassLoader loads ServiceDefinition from a PHP class and its methods.
@ -26,19 +25,23 @@ use Symfony\Component\Config\Loader\LoaderResolverInterface;
* Based on \Symfony\Component\Routing\Loader\AnnotationClassLoader * Based on \Symfony\Component\Routing\Loader\AnnotationClassLoader
* *
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
* @author Francis Besset <francis.besset@gmail.com>
*/ */
class AnnotationClassLoader extends Loader class AnnotationClassLoader extends Loader
{ {
protected $reader; protected $reader;
protected $typeRepository;
/** /**
* Constructor. * Constructor.
* *
* @param \Doctrine\Common\Annotations\Reader $reader * @param \Doctrine\Common\Annotations\Reader $reader
*/ */
public function __construct(Reader $reader) public function __construct(Reader $reader, TypeRepository $typeRepository)
{ {
$this->reader = $reader; $this->reader = $reader;
$this->typeRepository = $typeRepository;
} }
/** /**
@ -58,39 +61,26 @@ class AnnotationClassLoader extends Loader
} }
$class = new \ReflectionClass($class); $class = new \ReflectionClass($class);
$definition = new Definition\ServiceDefinition(); $definition = new Definition\Definition($this->typeRepository);
$serviceMethodHeaders = array(); $sharedHeaders = array();
foreach ($this->reader->getClassAnnotations($class) as $annotation) { foreach ($this->reader->getClassAnnotations($class) as $annotation) {
if ($annotation instanceof Annotation\Header) { if ($annotation instanceof Annotation\Header) {
$serviceMethodHeaders[$annotation->getValue()] = $annotation; $sharedHeaders[$annotation->getValue()] = $this->loadType($annotation->getPhpType());
} }
} }
foreach ($class->getMethods() as $method) { foreach ($class->getMethods() as $method) {
$serviceArguments = $serviceHeaders = $sharedHeaders;
$serviceHeaders = array(); $serviceArguments = array();
$serviceMethod = $serviceMethod =
$serviceReturn = null; $serviceReturn = null;
foreach ($serviceMethodHeaders as $annotation) {
$serviceHeaders[$annotation->getValue()] = new Definition\Header(
$annotation->getValue(),
$this->getArgumentType($method, $annotation)
);
}
foreach ($this->reader->getMethodAnnotations($method) as $annotation) { foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
if ($annotation instanceof Annotation\Header) { if ($annotation instanceof Annotation\Header) {
$serviceHeaders[$annotation->getValue()] = new Definition\Header( $serviceHeaders[$annotation->getValue()] = $this->loadType($annotation->getPhpType());
$annotation->getValue(),
$this->getArgumentType($method, $annotation)
);
} elseif ($annotation instanceof Annotation\Param) { } elseif ($annotation instanceof Annotation\Param) {
$serviceArguments[] = new Definition\Argument( $serviceArguments[$annotation->getValue()] = $this->loadType($annotation->getPhpType());
$annotation->getValue(),
$this->getArgumentType($method, $annotation)
);
} elseif ($annotation instanceof Annotation\Method) { } elseif ($annotation instanceof Annotation\Method) {
if ($serviceMethod) { if ($serviceMethod) {
throw new \LogicException(sprintf('@Soap\Method defined twice for "%s".', $method->getName())); throw new \LogicException(sprintf('@Soap\Method defined twice for "%s".', $method->getName()));
@ -105,7 +95,7 @@ class AnnotationClassLoader extends Loader
throw new \LogicException(sprintf('@Soap\Result defined twice for "%s".', $method->getName())); throw new \LogicException(sprintf('@Soap\Result defined twice for "%s".', $method->getName()));
} }
$serviceReturn = new Definition\Type($annotation->getPhpType(), $annotation->getXmlType()); $serviceReturn = $annotation->getPhpType();
} }
} }
@ -114,16 +104,21 @@ class AnnotationClassLoader extends Loader
} }
if ($serviceMethod) { if ($serviceMethod) {
$serviceMethod->setArguments($serviceArguments); foreach ($serviceHeaders as $name => $type) {
$serviceMethod->setHeaders($serviceHeaders); $serviceMethod->addHeader($name, $type);
}
foreach ($serviceArguments as $name => $type) {
$serviceMethod->addInput($name, $type);
}
if (!$serviceReturn) { if (!$serviceReturn) {
throw new \LogicException(sprintf('@Soap\Result non-existent for "%s".', $method->getName())); throw new \LogicException(sprintf('@Soap\Result non-existent for "%s".', $method->getName()));
} }
$serviceMethod->setReturn($serviceReturn); $serviceMethod->setOutput($this->loadType($serviceReturn));
$definition->getMethods()->add($serviceMethod); $definition->addMethod($serviceMethod);
} }
} }
@ -145,28 +140,28 @@ class AnnotationClassLoader extends Loader
} }
} }
/** private function loadType($phpType)
* @param \ReflectionMethod $method
* @param \BeSimple\SoapBundle\ServiceDefinition\Annotation\Param $annotation
*
* @return \BeSimple\SoapBundle\ServiceDefinition\Type
*/
private function getArgumentType(\ReflectionMethod $method, Annotation\Param $annotation)
{ {
$phpType = $annotation->getPhpType(); if (false !== $arrayOf = $this->typeRepository->getArrayOf($phpType)) {
$xmlType = $annotation->getXmlType(); $this->loadType($arrayOf);
if (null === $phpType) {
foreach ($method->getParameters() as $param) {
if ($param->name === $annotation->getName()) {
$phpType = $param->getClass()->name;
break;
}
}
} }
return new Definition\Type($phpType, $xmlType); if (!$this->typeRepository->hasType($phpType)) {
$complexTypeResolver = $this->resolve($phpType, 'annotation_complextype');
if (!$complexTypeResolver) {
throw new \Exception();
}
$loaded = $complexTypeResolver->load($phpType);
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
foreach ($loaded['properties'] as $name => $property) {
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable());
}
$this->typeRepository->addComplexType($complexType);
}
return $phpType;
} }
/** /**

View File

@ -1,7 +1,7 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapBundle. * This file is part of the BeSimpleSoap.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com> * (c) Francis Besset <francis.besset@gmail.com>
@ -65,4 +65,17 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
return $annotations; return $annotations;
} }
/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return Boolean True if this class supports the given resource, false otherwise
*/
public function supports($resource, $type = null)
{
return is_string($resource) && class_exists($resource) && 'annotation_complextype' === $type;
}
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapBundle. * This file is part of the BeSimpleSoap.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com> * (c) Francis Besset <francis.besset@gmail.com>
@ -16,7 +16,6 @@ use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\FileLoader; use Symfony\Component\Config\Loader\FileLoader;
use Symfony\Component\Config\Resource\FileResource;
/** /**
* AnnotationFileLoader loads ServiceDefinition from annotations set * AnnotationFileLoader loads ServiceDefinition from annotations set
@ -62,7 +61,7 @@ class AnnotationFileLoader extends FileLoader
$path = $this->locator->locate($file); $path = $this->locator->locate($file);
if ($class = $this->findClass($path)) { if ($class = $this->findClass($path)) {
return $definition = $this->loader->load($class, $type); return $this->loader->load($class, $type);
} }
return null; return null;

View File

@ -1,145 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition\Loader;
use BeSimple\SoapBundle\ServiceDefinition\Argument;
use BeSimple\SoapBundle\ServiceDefinition\Header;
use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapBundle\ServiceDefinition\Type;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use Symfony\Component\Config\Loader\FileLoader;
class XmlFileLoader extends FileLoader
{
public function supports($resource, $type = null)
{
return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION);
}
public function load($file, $type = null)
{
$path = $this->locator->locate($file);
$xml = $this->parseFile($path);
$definition = new ServiceDefinition();
$definition->setName((string) $xml['name']);
$definition->setNamespace((string) $xml['namespace']);
foreach($xml->header as $header) {
$definition->getHeaders()->add($this->parseHeader($header));
}
foreach($xml->method as $method) {
$definition->getMethods()->add($this->parseMethod($method));
}
return $definition;
}
/**
* @param \SimpleXMLElement $node
*
* @return \BeSimple\SoapBundle\ServiceDefinition\Header
*/
protected function parseHeader(\SimpleXMLElement $node)
{
return new Header((string)$node['name'], $this->parseType($node->type));
}
/**
* @param \SimpleXMLElement $node
*
* @return \BeSimple\SoapBundle\ServiceDefinition\Method
*/
protected function parseMethod(\SimpleXMLElement $node)
{
$method = new Method((string)$node['name'], (string)$node['controller']);
foreach($node->argument as $argument) {
$method->getArguments()->add($this->parseArgument($argument));
}
$method->setReturn($this->parseType($node->return->type));
return $method;
}
/**
* @param \SimpleXMLElement $node
*
* @return \BeSimple\SoapBundle\ServiceDefinition\Argument
*/
protected function parseArgument(\SimpleXMLElement $node)
{
$argument = new Argument((string)$node['name'], $this->parseType($node->type));
return $argument;
}
/**
* @param \SimpleXMLElement $node
*
* @return \BeSimple\SoapBundle\ServiceDefinition\Type
*/
protected function parseType(\SimpleXMLElement $node)
{
$namespaces = $node->getDocNamespaces(true);
$qname = explode(':', $node['xml-type'], 2);
$xmlType = sprintf('{%s}%s', $namespaces[$qname[0]], $qname[1]);
return new Type((string)$node['php-type'], $xmlType, (string)$node['converter']);
}
/**
* @param string $file
*
* @return \SimpleXMLElement
*/
protected function parseFile($file)
{
$dom = new \DOMDocument();
libxml_use_internal_errors(true);
if (!$dom->load($file, LIBXML_COMPACT)) {
throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors()));
}
if (!$dom->schemaValidate(__DIR__.'/schema/servicedefinition-1.0.xsd')) {
throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors()));
}
$dom->validateOnParse = true;
$dom->normalizeDocument();
libxml_use_internal_errors(false);
return simplexml_import_dom($dom);
}
protected function getXmlErrors()
{
$errors = array();
foreach (libxml_get_errors() as $error) {
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
$error->code,
trim($error->message),
$error->file ? $error->file : 'n/a',
$error->line,
$error->column
);
}
libxml_clear_errors();
libxml_use_internal_errors(false);
return $errors;
}
}

View File

@ -1,8 +1,10 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapBundle. * This file is part of the BeSimpleSoap.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
* *
* This source file is subject to the MIT license that is bundled * This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
@ -10,36 +12,22 @@
namespace BeSimple\SoapBundle\ServiceDefinition; namespace BeSimple\SoapBundle\ServiceDefinition;
use BeSimple\SoapBundle\Util\Collection; use BeSimple\SoapCommon\Definition\Method as BaseMethod;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
class Method /**
* @author Christian Kerl <christian-kerl@web.de>
* @author Francis Besset <francis.besset@gmail.com>
*/
class Method extends BaseMethod
{ {
private $name;
private $controller; private $controller;
private $arguments;
private $headers;
private $return;
public function __construct($name = null, $controller = null, array $headers = array(), array $arguments = array(), Type $return = null) public function __construct($name, $controller)
{ {
$this->setName($name); parent::__construct($name);
$this->setController($controller);
$this->setHeaders($headers);
$this->setArguments($arguments);
if ($return) { $this->controller = $controller;
$this->setReturn($return);
}
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
} }
public function getController() public function getController()
@ -47,40 +35,8 @@ class Method
return $this->controller; return $this->controller;
} }
public function setController($controller) public function getVersions()
{ {
$this->controller = $controller; return array(\SOAP_1_1);
} }
}
public function getHeaders()
{
return $this->headers;
}
public function setHeaders(array $headers)
{
$this->headers = new Collection('getName', 'BeSimple\SoapBundle\ServiceDefinition\Header');
$this->headers->addAll($headers);
}
public function getArguments()
{
return $this->arguments;
}
public function setArguments(array $arguments)
{
$this->arguments = new Collection('getName', 'BeSimple\SoapBundle\ServiceDefinition\Argument');
$this->arguments->addAll($arguments);
}
public function getReturn()
{
return $this->return;
}
public function setReturn(Type $return)
{
$this->return = $return;
}
}

View File

@ -1,151 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition;
use BeSimple\SoapBundle\Util\Collection;
use BeSimple\SoapCommon\Classmap;
class ServiceDefinition
{
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $namespace;
/**
* @var \BeSimple\SoapBundle\Util\Collection
*/
private $methods;
/**
* @var \BeSimple\SoapCommon\Classmap
*/
private $classmap;
private $complexTypes = array();
public function __construct($name = null, $namespace = null, array $methods = array(), Classmap $classmap = null)
{
$this->setName($name);
$this->setNamespace($namespace);
$this->methods = new Collection('getName', 'BeSimple\SoapBundle\ServiceDefinition\Method');
$this->setMethods($methods);
$this->classmap = $classmap;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getNamespace()
{
return $this->namespace;
}
/**
* @param string $namespace
*/
public function setNamespace($namespace)
{
$this->namespace = $namespace;
}
/**
* @return \BeSimple\SoapBundle\Util\Collection
*/
public function getMethods()
{
return $this->methods;
}
/**
* @param array $methods
*/
public function setMethods(array $methods)
{
$this->methods->addAll($methods);
}
/**
* @return array
*/
public function getAllTypes()
{
$types = array();
foreach ($this->methods as $method) {
foreach ($method->getArguments() as $argument) {
$types[] = $argument->getType();
}
foreach ($method->getHeaders() as $header) {
$types[] = $header->getType();
}
$types[] = $method->getReturn();
}
return $types;
}
public function getClassmap()
{
return $this->classmap ?: array();
}
public function setClassmap(Classmap $classmap)
{
$this->classmap = $classmap;
}
public function hasDefinitionComplexType($type)
{
return isset($this->complexTypes[$type]);
}
public function addDefinitionComplexType($type, array $definition)
{
if ($this->hasDefinitionComplexType($type)) {
return false;
}
$this->complexTypes[$type] = $definition;
return true;
}
public function getDefinitionComplexTypes()
{
return $this->complexTypes;
}
}

View File

@ -1,89 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition\Strategy;
use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
use Zend\Soap\Wsdl;
use Zend\Soap\Wsdl\ComplexTypeStrategy\AbstractComplexTypeStrategy;
/**
* @author Francis Besset <francis.besset@gmail.com>
*/
class ComplexType extends AbstractComplexTypeStrategy
{
private $loader;
private $definition;
public function __construct(AnnotationComplexTypeLoader $loader, $definition)
{
$this->loader = $loader;
$this->definition = $definition;
}
/**
* Add a complex type by recursivly using all the class properties fetched via Reflection.
*
* @param string $type Name of the class to be specified
* @return string XSD Type for the given PHP type
*/
public function addComplexType($classname)
{
$classmap = $this->definition->getClassmap();
if ($classmap->hasByClassname($classname)) {
return 'tns:'.$classmap->getByClassname($classname);
}
if (!$this->loader->supports($classname)) {
throw new \InvalidArgumentException(sprintf('Cannot add ComplexType "%s" because it is not an object or the class could not be found.', $classname));
}
$definitionComplexType = $this->loader->load($classname);
$classnameAlias = isset($definitionComplexType['alias']) ? $definitionComplexType['alias'] : $classname;
$type = $this->getContext()->translateType($classnameAlias);
$xmlType = 'tns:'.$type;
// Register type here to avoid recursion
$classmap->add($type, $classname);
$this->addXmlDefinition($definitionComplexType, $classname, $type);
return $xmlType;
}
private function addXmlDefinition(array $definitionComplexType, $classname, $type)
{
$dom = $this->getContext()->toDomDocument();
$complexType = $dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $type);
$all = $dom->createElement('xsd:all');
$elements = array();
foreach ($definitionComplexType['properties'] as $property) {
$element = $dom->createElement('xsd:element');
$element->setAttribute('name', $property->getName());
$element->setAttribute('type', $this->getContext()->getType($property->getValue()));
if ($property->isNillable()) {
$element->setAttribute('nillable', 'true');
}
$all->appendChild($element);
}
$complexType->appendChild($all);
$this->getContext()->getSchema()->appendChild($complexType);
$this->definition->addDefinitionComplexType($classname, $definitionComplexType);
}
}

View File

@ -1,60 +0,0 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceDefinition;
class Type
{
private $phpType;
private $xmlType;
private $converter;
public function __construct($phpType = null, $xmlType = null, $converter = null)
{
$this->setPhpType($phpType);
$this->setXmlType($xmlType);
$this->setConverter($converter);
}
public function getPhpType()
{
return $this->phpType;
}
public function setPhpType($phpType)
{
$phpType = $phpType;
if ($phpType[0] == '\\') {
$phpType = substr($phpType, 1);
}
$this->phpType = $phpType;
}
public function getXmlType()
{
return $this->xmlType;
}
public function setXmlType($xmlType)
{
$this->xmlType = $xmlType;
}
public function getConverter()
{
return $this->converter;
}
public function setConverter($converter)
{
$this->converter = $converter;
}
}

View File

@ -11,10 +11,7 @@
namespace BeSimple\SoapBundle\Soap; namespace BeSimple\SoapBundle\Soap;
use BeSimple\SoapBundle\Util\Collection; use BeSimple\SoapBundle\Util\Collection;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Zend\Mime\Mime;
use Zend\Mime\Message; use Zend\Mime\Message;
/** /**

View File

@ -3,6 +3,7 @@
* This file is part of the BeSimpleSoapBundle. * This file is part of the BeSimpleSoapBundle.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
* *
* This source file is subject to the MIT license that is bundled * This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
@ -10,15 +11,10 @@
namespace BeSimple\SoapBundle; namespace BeSimple\SoapBundle;
use BeSimple\SoapBundle\Converter\TypeRepository;
use BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface;
use BeSimple\SoapBundle\ServiceBinding\ServiceBinder; use BeSimple\SoapBundle\ServiceBinding\ServiceBinder;
use BeSimple\SoapBundle\ServiceDefinition\Dumper\DumperInterface;
use BeSimple\SoapCommon\Classmap;
use BeSimple\SoapCommon\Converter\TypeConverterCollection; use BeSimple\SoapCommon\Converter\TypeConverterCollection;
use BeSimple\SoapWsdl\Dumper\Dumper;
use BeSimple\SoapServer\SoapServerBuilder; use BeSimple\SoapServer\SoapServerBuilder;
use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
@ -26,43 +22,29 @@ use Symfony\Component\Config\Loader\LoaderInterface;
* WebServiceContext. * WebServiceContext.
* *
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
* @author Francis Besset <francis.besset@gmail.com>
*/ */
class WebServiceContext class WebServiceContext
{ {
private $classmap;
private $typeRepository;
private $converterRepository;
private $wsdlFileDumper;
private $options; private $options;
private $serviceDefinition; private $serviceDefinition;
private $serviceBinder; private $serviceBinder;
private $serverBuilder; private $serverBuilder;
public function __construct(LoaderInterface $loader, DumperInterface $dumper, Classmap $classmap, TypeRepository $typeRepository, TypeConverterCollection $converters, array $options) public function __construct(LoaderInterface $loader, TypeConverterCollection $converters, array $options)
{ {
$this->loader = $loader; $this->loader = $loader;
$this->wsdlFileDumper = $dumper; $this->converters = $converters;
$this->options = $options;
$this->classmap = $classmap;
$this->typeRepository = $typeRepository;
$this->converters = $converters;
// Issue #6: keep the debug because the cache is invalid
$options['debug'] = true;
$this->options = $options;
} }
public function getServiceDefinition() public function getServiceDefinition()
{ {
if (null === $this->serviceDefinition) { if (null === $this->serviceDefinition) {
$cacheDefinition = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']); $cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
if ($cacheDefinition->isFresh()) { if ($cache->isFresh()) {
$this->serviceDefinition = include (string) $cacheDefinition; $this->serviceDefinition = include (string) $cache;
} else { } else {
if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) { if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) {
throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type'])); throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type']));
@ -72,10 +54,7 @@ class WebServiceContext
$this->serviceDefinition->setName($this->options['name']); $this->serviceDefinition->setName($this->options['name']);
$this->serviceDefinition->setNamespace($this->options['namespace']); $this->serviceDefinition->setNamespace($this->options['namespace']);
$this->serviceDefinition->setClassmap($this->classmap); $cache->write('<?php return unserialize('.var_export(serialize($this->serviceDefinition), true).');');
$this->classmap = null;
$this->typeRepository->fixTypeInformation($this->serviceDefinition);
} }
} }
@ -89,19 +68,21 @@ class WebServiceContext
public function getWsdlFile($endpoint = null) public function getWsdlFile($endpoint = null)
{ {
$file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint)); $file = sprintf ('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$cacheWsdl = new ConfigCache($file, $this->options['debug']); $cache = new ConfigCache($file, $this->options['debug']);
if(!$cacheWsdl->isFresh()) { if(!$cache->isFresh()) {
$serviceDefinition = $this->getServiceDefinition(); $definition = $this->getServiceDefinition();
$cacheWsdl->write($this->wsdlFileDumper->dumpServiceDefinition($serviceDefinition, $endpoint)); if ($endpoint) {
$definition->setOption('location', $endpoint);
}
$cacheDefinition = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']); $dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
$cacheDefinition->write('<?php return unserialize('.var_export(serialize($serviceDefinition), true).');'); $cache->write($dumper->dump());
} }
return (string) $cacheWsdl; return (string) $cache;
} }
public function getServiceBinder() public function getServiceBinder()
@ -123,7 +104,7 @@ class WebServiceContext
if (null === $this->serverBuilder) { if (null === $this->serverBuilder) {
$this->serverBuilder = SoapServerBuilder::createWithDefaults() $this->serverBuilder = SoapServerBuilder::createWithDefaults()
->withWsdl($this->getWsdlFile()) ->withWsdl($this->getWsdlFile())
->withClassmap($this->getServiceDefinition()->getClassmap()) ->withClassmap($this->getServiceDefinition()->getTypeRepository()->getClassmap())
->withTypeConverters($this->converters) ->withTypeConverters($this->converters)
; ;

View File

@ -22,16 +22,16 @@
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.3.0",
"ext-soap": "*", "ext-soap": "*",
"besimple/soap-common": "0.1.*", "besimple/soap-common": "0.2.*",
"ass/xmlsecurity": "dev-master", "besimple/soap-wsdl": "0.2.*",
"zendframework/zend-mail": "2.1.*", "ass/xmlsecurity": "~1.0",
"zendframework/zend-mime": "2.1.*", "symfony/framework-bundle": "~2.0",
"zendframework/zend-soap": "2.1.*", "symfony/twig-bundle": "~2.0",
"symfony/framework-bundle": "~2.0" "zendframework/zend-mime": "2.1.*"
}, },
"suggest": { "suggest": {
"besimple/soap-client": "0.1.*", "besimple/soap-client": "0.2.*",
"besimple/soap-server": "0.1.*" "besimple/soap-server": "0.2.*"
}, },
"autoload": { "autoload": {
"psr-0": { "BeSimple\\SoapBundle": "" } "psr-0": { "BeSimple\\SoapBundle": "" }
@ -40,7 +40,7 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.1-dev" "dev-master": "0.2-dev"
} }
} }
} }

View File

@ -88,13 +88,19 @@ class Curl
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']); curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
} }
if (isset($options['login'])) { if (isset($options['login'])) {
curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']); curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);
} }
if (isset($options['local_cert'])) { if (isset($options['local_cert'])) {
curl_setopt($this->ch, CURLOPT_SSLCERT, $options['local_cert']); curl_setopt($this->ch, CURLOPT_SSLCERT, $options['local_cert']);
curl_setopt($this->ch, CURLOPT_SSLCERTPASSWD, $options['passphrase']); curl_setopt($this->ch, CURLOPT_SSLCERTPASSWD, $options['passphrase']);
} }
if (isset($options['ca_info'])) {
curl_setopt($this->ch, CURLOPT_CAINFO, $options['ca_info']);
}
if (isset($options['ca_path'])) {
curl_setopt($this->ch, CURLOPT_CAPATH, $options['ca_path']);
}
} }
/** /**
@ -128,7 +134,7 @@ class Curl
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $requestHeaders); curl_setopt($this->ch, CURLOPT_HTTPHEADER, $requestHeaders);
} }
$this->response = $this->execManualRedirect($this->followLocationMaxRedirects); $this->response = $this->execManualRedirect();
return ($this->response === false) ? false : true; return ($this->response === false) ? false : true;
} }

View File

@ -90,7 +90,7 @@ class MimeFilter implements SoapRequestFilter, SoapResponseFilter
// TODO // TODO
$headers = $multipart->getHeadersForHttp(); $headers = $multipart->getHeadersForHttp();
list($name, $contentType) = explode(': ', $headers[0]); list(, $contentType) = explode(': ', $headers[0]);
$request->setContentType($contentType); $request->setContentType($contentType);
} }
@ -135,4 +135,4 @@ class MimeFilter implements SoapRequestFilter, SoapResponseFilter
$response->setAttachments($attachmentsRecieved); $response->setAttachments($attachmentsRecieved);
} }
} }
} }

View File

@ -0,0 +1,34 @@
# BeSimpleSoapClient
The BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA, MTOM and WS-Security.
# Features (only subsets of the linked specs implemented)
* SwA: SOAP Messages with Attachments [Spec](http://www.w3.org/TR/SOAP-attachments)
* MTOM: SOAP Message Transmission Optimization Mechanism [Spec](http://www.w3.org/TR/soap12-mtom/)
* WS-Security [Spec1](http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0.pdf), [Spec2](http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0.pdf)
* WS-Adressing [Spec](http://www.w3.org/2002/ws/addr/)
# Installation
If you do not yet have composer, install it like this:
```sh
curl -s http://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin
```
Create a `composer.json` file:
```json
{
"require": {
"besimple/soap-client": "0.2.*@dev"
}
}
```
Now you are ready to install the library:
```sh
php /usr/local/bin/composer.phar install
```

View File

@ -15,6 +15,7 @@ namespace BeSimple\SoapClient;
use BeSimple\SoapCommon\Helper; use BeSimple\SoapCommon\Helper;
use BeSimple\SoapCommon\Converter\MtomTypeConverter; use BeSimple\SoapCommon\Converter\MtomTypeConverter;
use BeSimple\SoapCommon\Converter\SwaTypeConverter; use BeSimple\SoapCommon\Converter\SwaTypeConverter;
use BeSimple\SoapCommon\SoapMessage;
/** /**
* Extended SoapClient that uses a a cURL wrapper for all underlying HTTP * Extended SoapClient that uses a a cURL wrapper for all underlying HTTP
@ -40,6 +41,15 @@ class SoapClient extends \SoapClient
*/ */
protected $tracingEnabled = false; protected $tracingEnabled = false;
/**
* Work around missing header/php://input access in PHP cli webserver by
* setting headers additionally as GET parameters and SOAP request body
* explicitly as POST variable.
*
* @var boolean
*/
private $cliWebserverWorkaround = false;
/** /**
* cURL instance. * cURL instance.
* *
@ -98,7 +108,16 @@ class SoapClient extends \SoapClient
if (isset($options['soap_version'])) { if (isset($options['soap_version'])) {
$this->soapVersion = $options['soap_version']; $this->soapVersion = $options['soap_version'];
} }
// activate cli webserver workaround
if (isset($options['cli_webserver_workaround'])) {
$this->cliWebserverWorkaround = $options['cli_webserver_workaround'];
}
$this->curl = new Curl($options); $this->curl = new Curl($options);
if (isset($options['extra_options'])) {
unset($options['extra_options']);
}
$wsdlFile = $this->loadWsdl($wsdl, $options); $wsdlFile = $this->loadWsdl($wsdl, $options);
// TODO $wsdlHandler = new WsdlHandler($wsdlFile, $this->soapVersion); // TODO $wsdlHandler = new WsdlHandler($wsdlFile, $this->soapVersion);
$this->soapKernel = new SoapKernel(); $this->soapKernel = new SoapKernel();
@ -124,14 +143,47 @@ class SoapClient extends \SoapClient
private function __doHttpRequest(SoapRequest $soapRequest) private function __doHttpRequest(SoapRequest $soapRequest)
{ {
// HTTP headers // HTTP headers
$headers = array( $soapVersion = $soapRequest->getVersion();
'Content-Type:' . $soapRequest->getContentType(), $soapAction = $soapRequest->getAction();
'SOAPAction: "' . $soapRequest->getAction() . '"', if (SOAP_1_1 == $soapVersion) {
); $headers = array(
'Content-Type:' . $soapRequest->getContentType(),
'SOAPAction: "' . $soapAction . '"',
);
} else {
$headers = array(
'Content-Type:' . $soapRequest->getContentType() . '; action="' . $soapAction . '"',
);
}
$location = $soapRequest->getLocation();
$content = $soapRequest->getContent();
/*
* Work around missing header/php://input access in PHP cli webserver by
* setting headers additionally as GET parameters and SOAP request body
* explicitly as POST variable
*/
if ($this->cliWebserverWorkaround === true) {
if (strpos($location, '?') === false) {
$location .= '?';
} else {
$location .= '&';
}
$location .= SoapMessage::CONTENT_TYPE_HEADER.'='.urlencode($soapRequest->getContentType());
$location .= '&';
$location .= SoapMessage::SOAP_ACTION_HEADER.'='.urlencode($soapRequest->getAction());
$content = http_build_query(array('request' => $content));
$headers = array();
}
$headers = $this->filterRequestHeaders($soapRequest, $headers);
// execute HTTP request with cURL // execute HTTP request with cURL
$responseSuccessfull = $this->curl->exec( $responseSuccessfull = $this->curl->exec(
$soapRequest->getLocation(), $location,
$soapRequest->getContent(), $content,
$headers $headers
); );
// tracing enabled: store last request header and body // tracing enabled: store last request header and body
@ -208,6 +260,19 @@ class SoapClient extends \SoapClient
return $soapResponse; return $soapResponse;
} }
/**
* Filters HTTP headers which will be sent
*
* @param SoapRequest $soapRequest SOAP request object
* @param array $headers An array of HTTP headers
*
* @return array
*/
protected function filterRequestHeaders(SoapRequest $soapRequest, array $headers)
{
return $headers;
}
/** /**
* Get last request HTTP headers. * Get last request HTTP headers.
* *
@ -309,7 +374,7 @@ class SoapClient extends \SoapClient
* *
* @return string * @return string
*/ */
private function loadWsdl($wsdl, array $options) protected function loadWsdl($wsdl, array $options)
{ {
// option to resolve wsdl/xsd includes // option to resolve wsdl/xsd includes
$resolveRemoteIncludes = true; $resolveRemoteIncludes = true;

View File

@ -13,7 +13,6 @@
namespace BeSimple\SoapClient; namespace BeSimple\SoapClient;
use BeSimple\SoapCommon\SoapResponse as CommonSoapResponse; use BeSimple\SoapCommon\SoapResponse as CommonSoapResponse;
use BeSimple\SoapCommon\SoapMessage;
/** /**
* SoapResponse class for SoapClient. Provides factory function for response object. * SoapResponse class for SoapClient. Provides factory function for response object.
@ -44,4 +43,4 @@ class SoapResponse extends CommonSoapResponse
return $response; return $response;
} }
} }

View File

@ -0,0 +1,7 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class AttachmentRequest extends AttachmentType
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class AttachmentType
{
public $fileName;
public $binaryData;
}

View File

@ -0,0 +1,11 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class BookInformation
{
public $type;
public $isbn;
public $author;
public $title;
}

View File

@ -1,89 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.apache.org/axis2/mtomsample/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"> <definitions targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.apache.org/axis2/mtomsample/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
<types> <types>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<xsd:import namespace="http://www.w3.org/2005/05/xmlmime"/> <xsd:import namespace="http://www.w3.org/2005/05/xmlmime"/>
<xsd:complexType name="AttachmentType"> <xsd:complexType name="AttachmentType">
<xsd:sequence> <xsd:sequence>
<xsd:element minOccurs="0" name="fileName" type="xsd:string"/> <xsd:element minOccurs="0" name="fileName" type="xsd:string"/>
<xsd:element minOccurs="0" name="binaryData" type="xmime:base64Binary"/> <xsd:element minOccurs="0" name="binaryData" type="xmime:base64Binary"/>
</xsd:sequence> </xsd:sequence>
</xsd:complexType> </xsd:complexType>
<xsd:element name="AttachmentRequest" type="tns:AttachmentType"/> <xsd:element name="AttachmentRequest" type="tns:AttachmentType"/>
<xsd:element name="AttachmentResponse" type="xsd:string"/> <xsd:element name="AttachmentResponse" type="xsd:string"/>
</xsd:schema> </xsd:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://www.w3.org/2005/05/xmlmime"> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://www.w3.org/2005/05/xmlmime">
<xs:attribute name="contentType"> <xs:attribute name="contentType">
<xs:simpleType> <xs:simpleType>
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:minLength value="3"/> <xs:minLength value="3"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:attribute> </xs:attribute>
<xs:attribute name="expectedContentTypes" type="xs:string"/> <xs:attribute name="expectedContentTypes" type="xs:string"/>
<xs:complexType name="base64Binary"> <xs:complexType name="base64Binary">
<xs:simpleContent> <xs:simpleContent>
<xs:extension base="xs:base64Binary"> <xs:extension base="xs:base64Binary">
<xs:attribute ref="xmime:contentType"/> <xs:attribute ref="xmime:contentType"/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
<xs:complexType name="hexBinary"> <xs:complexType name="hexBinary">
<xs:simpleContent> <xs:simpleContent>
<xs:extension base="xs:hexBinary"> <xs:extension base="xs:hexBinary">
<xs:attribute ref="xmime:contentType"/> <xs:attribute ref="xmime:contentType"/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
</xs:schema> </xs:schema>
</types> </types>
<message name="AttachmentResponse"> <message name="AttachmentResponse">
<part name="part1" element="tns:AttachmentResponse"> <part name="part1" element="tns:AttachmentResponse">
</part> </part>
</message> </message>
<message name="AttachmentRequest"> <message name="AttachmentRequest">
<part name="part1" element="tns:AttachmentRequest"> <part name="part1" element="tns:AttachmentRequest">
</part> </part>
</message> </message>
<portType name="MTOMServicePortType"> <portType name="MTOMServicePortType">
<operation name="attachment"> <operation name="attachment">
<input message="tns:AttachmentRequest" wsaw:Action="attachment"> <input message="tns:AttachmentRequest" wsaw:Action="attachment">
</input> </input>
<output message="tns:AttachmentResponse" wsaw:Action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"> <output message="tns:AttachmentResponse" wsaw:Action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse">
</output> </output>
</operation> </operation>
</portType> </portType>
<binding name="MTOMServiceSOAP11Binding" type="tns:MTOMServicePortType"> <binding name="MTOMServiceSOAP11Binding" type="tns:MTOMServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="attachment"> <operation name="attachment">
<soap:operation soapAction="attachment" style="document"/> <soap:operation soapAction="attachment" style="document"/>
<input> <input>
<soap:body use="literal"/> <soap:body use="literal"/>
</input> </input>
<output> <output>
<soap:body use="literal"/> <soap:body use="literal"/>
</output> </output>
</operation> </operation>
</binding> </binding>
<binding name="MTOMServiceSOAP12Binding" type="tns:MTOMServicePortType"> <binding name="MTOMServiceSOAP12Binding" type="tns:MTOMServicePortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="attachment"> <operation name="attachment">
<soap12:operation soapAction="attachment" style="document"/> <soap12:operation soapAction="attachment" style="document"/>
<input> <input>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</input> </input>
<output> <output>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</output> </output>
</operation> </operation>
</binding> </binding>
<service name="MTOMSample"> <service name="MTOMSample">
<port name="MTOMSampleSOAP12port_http" binding="tns:MTOMServiceSOAP12Binding"> <port name="MTOMSampleSOAP12port_http" binding="tns:MTOMServiceSOAP12Binding">
<soap12:address location="http://localhost:8080/axis2/services/MTOMSample.MTOMSampleSOAP12port_http/"/> <soap12:address location="http://localhost:8080/axis2/services/MTOMSample.MTOMSampleSOAP12port_http/"/>
</port> </port>
<port name="MTOMSampleSOAP11port_http" binding="tns:MTOMServiceSOAP11Binding"> <port name="MTOMSampleSOAP11port_http" binding="tns:MTOMServiceSOAP11Binding">
<soap:address location="http://localhost:8080/axis2/services/MTOMSample.MTOMSampleSOAP11port_http/"/> <soap:address location="http://localhost:8080/axis2/services/MTOMSample.MTOMSampleSOAP11port_http/"/>
</port> </port>
</service> </service>
</definitions> </definitions>

View File

@ -1,162 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.besimple" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.besimple"> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.besimple" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.besimple">
<wsdl:documentation>BeSimpleSwaService</wsdl:documentation> <wsdl:documentation>BeSimpleSwaService</wsdl:documentation>
<wsdl:types> <wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.besimple"> <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.besimple">
<xs:complexType name="Exception"> <xs:complexType name="Exception">
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/> <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
<xs:element name="Exception"> <xs:element name="Exception">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" name="Exception" nillable="true" type="ns:Exception"/> <xs:element minOccurs="0" name="Exception" nillable="true" type="ns:Exception"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="uploadFile"> <xs:element name="uploadFile">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" name="data" nillable="true" type="xs:base64Binary"/> <xs:element minOccurs="0" name="data" nillable="true" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="uploadFileResponse"> <xs:element name="uploadFileResponse">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="downloadFile"> <xs:element name="downloadFile">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="downloadFileResponse"> <xs:element name="downloadFileResponse">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="0" name="data" nillable="true" type="xs:base64Binary"/> <xs:element minOccurs="0" name="data" nillable="true" type="xs:base64Binary"/>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:schema> </xs:schema>
</wsdl:types> </wsdl:types>
<wsdl:message name="downloadFileRequest"> <wsdl:message name="downloadFileRequest">
<wsdl:part name="parameters" element="ns:downloadFile"/> <wsdl:part name="parameters" element="ns:downloadFile"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="downloadFileResponse"> <wsdl:message name="downloadFileResponse">
<wsdl:part name="parameters" element="ns:downloadFileResponse"/> <wsdl:part name="parameters" element="ns:downloadFileResponse"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="Exception"> <wsdl:message name="Exception">
<wsdl:part name="parameters" element="ns:Exception"/> <wsdl:part name="parameters" element="ns:Exception"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="uploadFileRequest"> <wsdl:message name="uploadFileRequest">
<wsdl:part name="parameters" element="ns:uploadFile"/> <wsdl:part name="parameters" element="ns:uploadFile"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="uploadFileResponse"> <wsdl:message name="uploadFileResponse">
<wsdl:part name="parameters" element="ns:uploadFileResponse"/> <wsdl:part name="parameters" element="ns:uploadFileResponse"/>
</wsdl:message> </wsdl:message>
<wsdl:portType name="BeSimpleSwaServicePortType"> <wsdl:portType name="BeSimpleSwaServicePortType">
<wsdl:operation name="downloadFile"> <wsdl:operation name="downloadFile">
<wsdl:input message="ns:downloadFileRequest" wsaw:Action="urn:downloadFile"/> <wsdl:input message="ns:downloadFileRequest" wsaw:Action="urn:downloadFile"/>
<wsdl:output message="ns:downloadFileResponse" wsaw:Action="urn:downloadFileResponse"/> <wsdl:output message="ns:downloadFileResponse" wsaw:Action="urn:downloadFileResponse"/>
<wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:downloadFileException"/> <wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:downloadFileException"/>
</wsdl:operation> </wsdl:operation>
<wsdl:operation name="uploadFile"> <wsdl:operation name="uploadFile">
<wsdl:input message="ns:uploadFileRequest" wsaw:Action="urn:uploadFile"/> <wsdl:input message="ns:uploadFileRequest" wsaw:Action="urn:uploadFile"/>
<wsdl:output message="ns:uploadFileResponse" wsaw:Action="urn:uploadFileResponse"/> <wsdl:output message="ns:uploadFileResponse" wsaw:Action="urn:uploadFileResponse"/>
<wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:uploadFileException"/> <wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:uploadFileException"/>
</wsdl:operation> </wsdl:operation>
</wsdl:portType> </wsdl:portType>
<wsdl:binding name="BeSimpleSwaServiceSoap11Binding" type="ns:BeSimpleSwaServicePortType"> <wsdl:binding name="BeSimpleSwaServiceSoap11Binding" type="ns:BeSimpleSwaServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="downloadFile"> <wsdl:operation name="downloadFile">
<soap:operation soapAction="urn:downloadFile" style="document"/> <soap:operation soapAction="urn:downloadFile" style="document"/>
<wsdl:input> <wsdl:input>
<soap:body use="literal"/> <soap:body use="literal"/>
</wsdl:input> </wsdl:input>
<wsdl:output> <wsdl:output>
<soap:body use="literal"/> <soap:body use="literal"/>
</wsdl:output> </wsdl:output>
<wsdl:fault name="Exception"> <wsdl:fault name="Exception">
<soap:fault use="literal" name="Exception"/> <soap:fault use="literal" name="Exception"/>
</wsdl:fault> </wsdl:fault>
</wsdl:operation> </wsdl:operation>
<wsdl:operation name="uploadFile"> <wsdl:operation name="uploadFile">
<soap:operation soapAction="urn:uploadFile" style="document"/> <soap:operation soapAction="urn:uploadFile" style="document"/>
<wsdl:input> <wsdl:input>
<soap:body use="literal"/> <soap:body use="literal"/>
</wsdl:input> </wsdl:input>
<wsdl:output> <wsdl:output>
<soap:body use="literal"/> <soap:body use="literal"/>
</wsdl:output> </wsdl:output>
<wsdl:fault name="Exception"> <wsdl:fault name="Exception">
<soap:fault use="literal" name="Exception"/> <soap:fault use="literal" name="Exception"/>
</wsdl:fault> </wsdl:fault>
</wsdl:operation> </wsdl:operation>
</wsdl:binding> </wsdl:binding>
<wsdl:binding name="BeSimpleSwaServiceSoap12Binding" type="ns:BeSimpleSwaServicePortType"> <wsdl:binding name="BeSimpleSwaServiceSoap12Binding" type="ns:BeSimpleSwaServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="downloadFile"> <wsdl:operation name="downloadFile">
<soap12:operation soapAction="urn:downloadFile" style="document"/> <soap12:operation soapAction="urn:downloadFile" style="document"/>
<wsdl:input> <wsdl:input>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</wsdl:input> </wsdl:input>
<wsdl:output> <wsdl:output>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</wsdl:output> </wsdl:output>
<wsdl:fault name="Exception"> <wsdl:fault name="Exception">
<soap12:fault use="literal" name="Exception"/> <soap12:fault use="literal" name="Exception"/>
</wsdl:fault> </wsdl:fault>
</wsdl:operation> </wsdl:operation>
<wsdl:operation name="uploadFile"> <wsdl:operation name="uploadFile">
<soap12:operation soapAction="urn:uploadFile" style="document"/> <soap12:operation soapAction="urn:uploadFile" style="document"/>
<wsdl:input> <wsdl:input>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</wsdl:input> </wsdl:input>
<wsdl:output> <wsdl:output>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</wsdl:output> </wsdl:output>
<wsdl:fault name="Exception"> <wsdl:fault name="Exception">
<soap12:fault use="literal" name="Exception"/> <soap12:fault use="literal" name="Exception"/>
</wsdl:fault> </wsdl:fault>
</wsdl:operation> </wsdl:operation>
</wsdl:binding> </wsdl:binding>
<wsdl:binding name="BeSimpleSwaServiceHttpBinding" type="ns:BeSimpleSwaServicePortType"> <wsdl:binding name="BeSimpleSwaServiceHttpBinding" type="ns:BeSimpleSwaServicePortType">
<http:binding verb="POST"/> <http:binding verb="POST"/>
<wsdl:operation name="downloadFile"> <wsdl:operation name="downloadFile">
<http:operation location="BeSimpleSwaService/downloadFile"/> <http:operation location="BeSimpleSwaService/downloadFile"/>
<wsdl:input> <wsdl:input>
<mime:content type="text/xml" part="downloadFile"/> <mime:content type="text/xml" part="downloadFile"/>
</wsdl:input> </wsdl:input>
<wsdl:output> <wsdl:output>
<mime:content type="text/xml" part="downloadFile"/> <mime:content type="text/xml" part="downloadFile"/>
</wsdl:output> </wsdl:output>
</wsdl:operation> </wsdl:operation>
<wsdl:operation name="uploadFile"> <wsdl:operation name="uploadFile">
<http:operation location="BeSimpleSwaService/uploadFile"/> <http:operation location="BeSimpleSwaService/uploadFile"/>
<wsdl:input> <wsdl:input>
<mime:content type="text/xml" part="uploadFile"/> <mime:content type="text/xml" part="uploadFile"/>
</wsdl:input> </wsdl:input>
<wsdl:output> <wsdl:output>
<mime:content type="text/xml" part="uploadFile"/> <mime:content type="text/xml" part="uploadFile"/>
</wsdl:output> </wsdl:output>
</wsdl:operation> </wsdl:operation>
</wsdl:binding> </wsdl:binding>
<wsdl:service name="BeSimpleSwaService"> <wsdl:service name="BeSimpleSwaService">
<wsdl:port name="BeSimpleSwaServiceHttpSoap11Endpoint" binding="ns:BeSimpleSwaServiceSoap11Binding"> <wsdl:port name="BeSimpleSwaServiceHttpSoap11Endpoint" binding="ns:BeSimpleSwaServiceSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/BeSimpleSwaService.BeSimpleSwaServiceHttpSoap11Endpoint/"/> <soap:address location="http://localhost:8080/axis2/services/BeSimpleSwaService.BeSimpleSwaServiceHttpSoap11Endpoint/"/>
</wsdl:port> </wsdl:port>
<wsdl:port name="BeSimpleSwaServiceHttpSoap12Endpoint" binding="ns:BeSimpleSwaServiceSoap12Binding"> <wsdl:port name="BeSimpleSwaServiceHttpSoap12Endpoint" binding="ns:BeSimpleSwaServiceSoap12Binding">
<soap12:address location="http://localhost:8080/axis2/services/BeSimpleSwaService.BeSimpleSwaServiceHttpSoap12Endpoint/"/> <soap12:address location="http://localhost:8080/axis2/services/BeSimpleSwaService.BeSimpleSwaServiceHttpSoap12Endpoint/"/>
</wsdl:port> </wsdl:port>
<wsdl:port name="BeSimpleSwaServiceHttpEndpoint" binding="ns:BeSimpleSwaServiceHttpBinding"> <wsdl:port name="BeSimpleSwaServiceHttpEndpoint" binding="ns:BeSimpleSwaServiceHttpBinding">
<http:address location="http://localhost:8080/axis2/services/BeSimpleSwaService.BeSimpleSwaServiceHttpEndpoint/"/> <http:address location="http://localhost:8080/axis2/services/BeSimpleSwaService.BeSimpleSwaServiceHttpEndpoint/"/>
</wsdl:port> </wsdl:port>
</wsdl:service> </wsdl:service>
</wsdl:definitions> </wsdl:definitions>

View File

@ -0,0 +1,11 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class addBook
{
public $type;
public $isbn;
public $author;
public $title;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class addBookResponse
{
public $addBookReturn;
}

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class base64Binary
{
public $_;
public $contentType;
}

View File

@ -1,14 +1,14 @@
-----BEGIN PRIVATE KEY----- -----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAITlcjSvMcsbW+A5yrVOphfSqIha MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAITlcjSvMcsbW+A5yrVOphfSqIha
gpO3iqCxNuvvYeNdArU5Mc1gH4J0fvIviz23bD2PslwKOjWKQgiqJV3wy3vgBthsJzGRqyJevgSx gpO3iqCxNuvvYeNdArU5Mc1gH4J0fvIviz23bD2PslwKOjWKQgiqJV3wy3vgBthsJzGRqyJevgSx
d4ak5iFwRUyxlJguwO7gU4r2loHR9cN4W996wEqFVOuwVbUN0EIvfY7mV+L1PaPaUnKHAgMBAAEC d4ak5iFwRUyxlJguwO7gU4r2loHR9cN4W996wEqFVOuwVbUN0EIvfY7mV+L1PaPaUnKHAgMBAAEC
gYAZ6UqtLwN8YGc3fs0hMKZ9upsViuAuwPiMgED/G3twgzAF+ZLWQkmie+hMfCyf6eV200+pVm0n gYAZ6UqtLwN8YGc3fs0hMKZ9upsViuAuwPiMgED/G3twgzAF+ZLWQkmie+hMfCyf6eV200+pVm0n
Bz/8xH/oowxpX0Kk3szoB4vFghjU84GKUcrbhu/NRIm7l3drnfbzqhQkHDCx6n1CotI4Gs49cDWu Bz/8xH/oowxpX0Kk3szoB4vFghjU84GKUcrbhu/NRIm7l3drnfbzqhQkHDCx6n1CotI4Gs49cDWu
4uEAuxJkEIVY553unZjZgQJBAOJVIallNKmD0iQlvtWRmRzpmYDjt9vhNY6WBTIOx6SDn9SRaoSA 4uEAuxJkEIVY553unZjZgQJBAOJVIallNKmD0iQlvtWRmRzpmYDjt9vhNY6WBTIOx6SDn9SRaoSA
fkipQ2HXo04r78TQ674+zfZ1lRTkFG7px6ECQQCWUPHp3pSZOM1oGzJrNvNaw+MizZAZjq34npHm fkipQ2HXo04r78TQ674+zfZ1lRTkFG7px6ECQQCWUPHp3pSZOM1oGzJrNvNaw+MizZAZjq34npHm
9GRquFLG7BlCaI9QNGE7pN2ryYsYCRUMaM2e4GR0tUXxVGknAkAgrxqFU9AfCqI2Bh1gyf3KZxF7 9GRquFLG7BlCaI9QNGE7pN2ryYsYCRUMaM2e4GR0tUXxVGknAkAgrxqFU9AfCqI2Bh1gyf3KZxF7
w2axofwR8ygc6nV6FGfoUneHWubhp0/LuVAj4cRmL6Vbe8ZSaPh2Y9lviuMBAkEAicP8Q+1E4j1m w2axofwR8ygc6nV6FGfoUneHWubhp0/LuVAj4cRmL6Vbe8ZSaPh2Y9lviuMBAkEAicP8Q+1E4j1m
PPEYP51oYprANOiUFmhnWEL00+jPk+QFsd03tV6hYs/vAbwzkjuwqMHCMdJoCiH8z95IEUvc5wJA PPEYP51oYprANOiUFmhnWEL00+jPk+QFsd03tV6hYs/vAbwzkjuwqMHCMdJoCiH8z95IEUvc5wJA
MvLOuZdu4dmhOXg/YKsbMSPjFNEVskLQNSXqw6O2wIrpPg1NQvBBAOTbiuZj3vind4VPos1wc4vB MvLOuZdu4dmhOXg/YKsbMSPjFNEVskLQNSXqw6O2wIrpPg1NQvBBAOTbiuZj3vind4VPos1wc4vB
QocvdUC6dA== QocvdUC6dA==
-----END PRIVATE KEY----- -----END PRIVATE KEY-----

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class downloadFile
{
public $name;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class downloadFileResponse
{
public $data;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class getBook
{
public $isbn;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class getBookResponse
{
public $getBookReturn;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class getBooksByType
{
public $type;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class getBooksByTypeResponse
{
public $getBooksByTypeReturn;
}

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class uploadFile
{
public $data;
public $name;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop\Fixtures;
class uploadFileResponse
{
public $return;
}

View File

@ -1,100 +0,0 @@
<?php
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
require '../bootstrap.php';
class base64Binary
{
public $_;
public $contentType;
}
class AttachmentType
{
public $fileName;
public $binaryData;
}
class AttachmentRequest extends AttachmentType
{
}
class base64Binary
{
public $_;
public $contentType;
}
class AttachmentType
{
public $fileName;
public $binaryData;
}
class AttachmentRequest extends AttachmentType
{
}
class base64Binary
{
public $_;
public $contentType;
}
class AttachmentType
{
public $fileName;
public $binaryData;
}
class AttachmentRequest extends AttachmentType
{
}
$options = array(
'soap_version' => SOAP_1_1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders
'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM,
'cache_wsdl' => WSDL_CACHE_NONE,
'classmap' => array(
'base64Binary' => 'base64Binary',
'AttachmentRequest' => 'AttachmentRequest',
),
);
/*
* Deploy "axis_services/sample-mtom.aar" to Apache Axis2 to get this
* example to work.
*
* Apache Axis2 MTOM example.
*
*/
$sc = new BeSimpleSoapClient('MTOM.wsdl', $options);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
$b64 = new base64Binary();
$b64->_ = 'This is a test. :)';
$b64->contentType = 'text/plain';
$attachment = new AttachmentRequest();
$attachment->fileName = 'test123.txt';
$attachment->binaryData = $b64;
var_dump($sc->attachment($attachment));
} catch (Exception $e) {
var_dump($e);
}
// var_dump(
// $sc->__getLastRequestHeaders(),
// $sc->__getLastRequest(),
// $sc->__getLastResponseHeaders(),
// $sc->__getLastResponse()
// );

View File

@ -0,0 +1,51 @@
<?php
/*
* Deploy "axis_services/sample-mtom.aar" to Apache Axis2 to get this
* example to work.
*
* Apache Axis2 MTOM example.
*
*/
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentRequest;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentType;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\base64Binary;
use BeSimple\SoapClient\Tests\AxisInterop\TestCase;
class MtomAxisInteropTest extends TestCase
{
private $options = array(
'soap_version' => SOAP_1_1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM,
'cache_wsdl' => WSDL_CACHE_NONE,
'classmap' => array(
'base64Binary' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\base64Binary',
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentRequest',
),
);
public function testAttachment()
{
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/MTOM.wsdl', $this->options);
$b64 = new base64Binary();
$b64->_ = 'This is a test. :)';
$b64->contentType = 'text/plain';
$attachment = new AttachmentRequest();
$attachment->fileName = 'test123.txt';
$attachment->binaryData = $b64;
$this->assertEquals('File saved succesfully.', $sc->attachment($attachment));
// $fileCreatedByServer = __DIR__.'/'.$attachment->fileName;
// $this->assertEquals($b64->_, file_get_contents($fileCreatedByServer));
// unlink($fileCreatedByServer);
}
}

View File

@ -1,84 +0,0 @@
<?php
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
require '../bootstrap.php';
$options = array(
'soap_version' => SOAP_1_1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders
'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA,
'cache_wsdl' => WSDL_CACHE_NONE,
);
/*
* Deploy "axis_services/besimple-swa.aar" to Apache Axis2 to get this
* example to work.
*
* Run ant to rebuild aar.
*
* Example based on:
* http://axis.apache.org/axis2/java/core/docs/mtom-guide.html#a3
* http://wso2.org/library/1675
*
* Doesn't work directly with ?wsdl served by Apache Axis!
*
*/
$sc = new BeSimpleSoapClient('SwA.wsdl', $options);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
$file = new stdClass();
$file->name = 'upload.txt';
$file->data = 'This is a test text!';
$result = $sc->uploadFile($file);
var_dump(
$result->return
);
$file = new stdClass();
$file->name = 'upload.txt';
$result = $sc->downloadFile($file);
var_dump(
$result->data
);
$file = new stdClass();
$file->name = 'image.jpg'; // source: http://www.freeimageslive.com/galleries/light/pics/swirl3768.jpg
$file->data = file_get_contents('image.jpg');
$result = $sc->uploadFile($file);
var_dump(
$result->return
);
$crc32 = crc32($file->data);
$file = new stdClass();
$file->name = 'image.jpg';
$result = $sc->downloadFile($file);
file_put_contents('image2.jpg', $result->data);
var_dump(
crc32($result->data) === $crc32
);
} catch (Exception $e) {
var_dump($e);
}
// var_dump(
// $sc->__getLastRequestHeaders(),
// $sc->__getLastRequest(),
// $sc->__getLastResponseHeaders(),
// $sc->__getLastResponse()
// );

View File

@ -1,38 +1,38 @@
<project name="BeSimpleSwaService" default="generate.service"> <project name="BeSimpleSwaService" default="generate.service">
<property environment="env" /> <property environment="env" />
<property name="axis2.home" value="C:/axis2" /> <property name="axis2.home" value="C:/axis2" />
<property name="axis2.repo" value="${axis2.home}/repository" /> <property name="axis2.repo" value="${axis2.home}/repository" />
<property name="build.dir" value="build" /> <property name="build.dir" value="build" />
<property name="filename" value="besimple-swa.aar" /> <property name="filename" value="besimple-swa.aar" />
<path id="axis.classpath"> <path id="axis.classpath">
<fileset dir="${axis2.home}/lib"> <fileset dir="${axis2.home}/lib">
<include name="*.jar" /> <include name="*.jar" />
</fileset> </fileset>
</path> </path>
<target name="generate.service" depends="compile"> <target name="generate.service" depends="compile">
<jar destfile="${build.dir}/${filename}"> <jar destfile="${build.dir}/${filename}">
<fileset dir="resources/"> <fileset dir="resources/">
<include name="META-INF/services.xml" /> <include name="META-INF/services.xml" />
</fileset> </fileset>
<fileset dir="${build.dir}/classes"> <fileset dir="${build.dir}/classes">
<include name="besimple/service/**/*.class" /> <include name="besimple/service/**/*.class" />
</fileset> </fileset>
</jar> </jar>
<copy file="${build.dir}/${filename}" tofile="../axis_services/${filename}" overwrite="true" /> <copy file="${build.dir}/${filename}" tofile="../axis_services/${filename}" overwrite="true" />
<copy file="${build.dir}/${filename}" tofile="${axis2.repo}/services/${filename}" overwrite="true" /> <copy file="${build.dir}/${filename}" tofile="${axis2.repo}/services/${filename}" overwrite="true" />
<antcall target="clean" /> <antcall target="clean" />
</target> </target>
<target name="compile"> <target name="compile">
<mkdir dir="${build.dir}/classes" /> <mkdir dir="${build.dir}/classes" />
<javac debug="on" srcdir="src" destdir="${build.dir}/classes"> <javac debug="on" srcdir="src" destdir="${build.dir}/classes">
<classpath refid="axis.classpath" /> <classpath refid="axis.classpath" />
</javac> </javac>
</target> </target>
<target name="clean"> <target name="clean">
<delete dir="${build.dir}" /> <delete dir="${build.dir}" />
</target> </target>
</project> </project>

View File

@ -1,15 +1,15 @@
<serviceGroup> <serviceGroup>
<service name="BeSimpleSwaService"> <service name="BeSimpleSwaService">
<description>BeSimple test service for SwA.</description> <description>BeSimple test service for SwA.</description>
<parameter name="enableSwA">true</parameter> <parameter name="enableSwA">true</parameter>
<parameter name="ServiceClass" locked="false">besimple.service.BeSimpleSwaService</parameter> <parameter name="ServiceClass" locked="false">besimple.service.BeSimpleSwaService</parameter>
<operation name="uploadFile"> <operation name="uploadFile">
<actionMapping>urn:uploadFile</actionMapping> <actionMapping>urn:uploadFile</actionMapping>
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation> </operation>
<operation name="downloadFile"> <operation name="downloadFile">
<actionMapping>urn:downloadFile</actionMapping> <actionMapping>urn:downloadFile</actionMapping>
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation> </operation>
</service> </service>
</serviceGroup> </serviceGroup>

View File

@ -0,0 +1,77 @@
<?php
/*
* Deploy "axis_services/besimple-swa.aar" to Apache Axis2 to get this
* example to work.
*
* Run ant to rebuild aar.
*
* Example based on:
* http://axis.apache.org/axis2/java/core/docs/mtom-guide.html#a3
* http://wso2.org/library/1675
*
* Doesn't work directly with ?wsdl served by Apache Axis!
*
*/
use BeSimple\SoapCommon\Helper as BeSimpleSoapHelper;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFile;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFileResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\downloadFile;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\downloadFileResponse;
use BeSimple\SoapClient\Tests\AxisInterop\TestCase;
class SwaAxisInteropTest extends TestCase
{
private $options = array(
'soap_version' => SOAP_1_1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA,
'cache_wsdl' => WSDL_CACHE_NONE,
'classmap' => array(
'downloadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\downloadFile',
'downloadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\downloadFileResponse',
'uploadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFile',
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFileResponse',
),
);
public function testUploadDownloadText()
{
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $this->options);
$upload = new uploadFile();
$upload->name = 'upload.txt';
$upload->data = 'This is a test. :)';
$result = $sc->uploadFile($upload);
$this->assertEquals('File saved succesfully.', $result->return);
$download = new downloadFile();
$download->name = 'upload.txt';
$result = $sc->downloadFile($download);
$this->assertEquals($upload->data, $result->data);
}
public function testUploadDownloadImage()
{
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $this->options);
$upload = new uploadFile();
$upload->name = 'image.jpg';
$upload->data = file_get_contents(__DIR__.'/Fixtures/image.jpg'); // source: http://www.freeimageslive.com/galleries/light/pics/swirl3768.jpg;
$result = $sc->uploadFile($upload);
$this->assertEquals('File saved succesfully.', $result->return);
$download = new downloadFile();
$download->name = 'image.jpg';
$result = $sc->downloadFile($download);
$this->assertEquals($upload->data, $result->data);
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace BeSimple\SoapClient\Tests\AxisInterop;
class TestCase extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$ch = curl_init('http://localhost:8080/');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (curl_exec($ch) === false) {
$this->markTestSkipped(
'The Axis server is not started on port 8080.'
);
}
curl_close($ch);
}
}

View File

@ -1,73 +0,0 @@
<?php
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\WsAddressingFilter as BeSimpleWsAddressingFilter;
require '../bootstrap.php';
$options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders
);
/*
* Deploy "axis_services/version2.aar" to Apache Axis2 to get this example to
* work.
*
* To rebuild the "axis_services/version2.aar" the following steps need to be
* done to build a working Apache Axis2 version service with SOAP session
* enabled.
*
* 1) Go to $AXIS_HOME/samples/version and edit the following files:
*
* resources/META-INF/services.xml:
* <service name="Version2" scope="soapsession">
* ...
* </service>
*
* build.xml:
* replace version.aar with version2.aar
*
* 2) Run ant build.xml in "$AXIS_HOME/samples/version"
*
*/
$sc = new BeSimpleSoapClient('http://localhost:8080/axis2/services/Version2?wsdl', $options);
$soapKernel = $sc->getSoapKernel();
$wsaFilter = new BeSimpleWsAddressingFilter();
$soapKernel->registerFilter($wsaFilter);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
$wsaFilter->setReplyTo(BeSimpleWsAddressingFilter::ENDPOINT_REFERENCE_ANONYMOUS);
$wsaFilter->setMessageId();
var_dump($sc->getVersion());
$soapSessionId1 = $wsaFilter->getReferenceParameter('http://ws.apache.org/namespaces/axis2', 'ServiceGroupId');
echo 'ID1: ' .$soapSessionId1 . PHP_EOL;
$wsaFilter->addReferenceParameter('http://ws.apache.org/namespaces/axis2', 'axis2', 'ServiceGroupId', $soapSessionId1);
var_dump($sc->getVersion());
$soapSessionId2 = $wsaFilter->getReferenceParameter('http://ws.apache.org/namespaces/axis2', 'ServiceGroupId');
echo 'ID2: ' . $soapSessionId2 . PHP_EOL;
if ($soapSessionId1 == $soapSessionId2) {
echo PHP_EOL;
echo 'SOAP session worked :)';
}
} catch (Exception $e) {
var_dump($e);
}
// var_dump(
// $sc->__getLastRequestHeaders(),
// $sc->__getLastRequest(),
// $sc->__getLastResponseHeaders(),
// $sc->__getLastResponse()
// );

View File

@ -0,0 +1,59 @@
<?php
/*
* Deploy "axis_services/version2.aar" to Apache Axis2 to get this example to
* work.
*
* To rebuild the "axis_services/version2.aar" the following steps need to be
* done to build a working Apache Axis2 version service with SOAP session
* enabled.
*
* 1) Go to $AXIS_HOME/samples/version and edit the following files:
*
* resources/META-INF/services.xml:
* <service name="Version2" scope="soapsession">
* ...
* </service>
*
* build.xml:
* replace version.aar with version2.aar
*
* 2) Run ant build.xml in "$AXIS_HOME/samples/version"
*
*/
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\WsAddressingFilter as BeSimpleWsAddressingFilter;
use BeSimple\SoapClient\Tests\AxisInterop\TestCase;
class WsAddressingAxisInteropTest extends TestCase
{
private $options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
);
public function testSession()
{
$sc = new BeSimpleSoapClient('http://localhost:8080/axis2/services/Version2?wsdl', $this->options);
$soapKernel = $sc->getSoapKernel();
$wsaFilter = new BeSimpleWsAddressingFilter();
$soapKernel->registerFilter($wsaFilter);
$wsaFilter->setReplyTo(BeSimpleWsAddressingFilter::ENDPOINT_REFERENCE_ANONYMOUS);
$wsaFilter->setMessageId();
$version = $sc->getVersion();
$soapSessionId1 = $wsaFilter->getReferenceParameter('http://ws.apache.org/namespaces/axis2', 'ServiceGroupId');
$wsaFilter->addReferenceParameter('http://ws.apache.org/namespaces/axis2', 'axis2', 'ServiceGroupId', $soapSessionId1);
$version = $sc->getVersion();
$soapSessionId2 = $wsaFilter->getReferenceParameter('http://ws.apache.org/namespaces/axis2', 'ServiceGroupId');
$this->assertEquals($soapSessionId1, $soapSessionId2);
}
}

View File

@ -1,116 +0,0 @@
<?php
use ass\XmlSecurity\Key as XmlSecurityKey;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\WsSecurityFilter as BeSimpleWsSecurityFilter;
use BeSimple\SoapCommon\WsSecurityKey as BeSimpleWsSecurityKey;
require '../bootstrap.php';
echo '<pre>';
$options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders
);
/*
* Deploy "axis_services/library-signencr.aar" to Apache Axis2 to get this
* example to work.
*
* Links:
* http://www.dcc.uchile.cl/~pcamacho/tutorial/web/xmlsec/xmlsec.html
* http://www.aleksey.com/xmlsec/xmldsig-verifier.html
*
* Using code from axis example:
* http://www.ibm.com/developerworks/java/library/j-jws5/index.html
*
* Download key tool to export private key
* http://couchpotato.net/pkeytool/
*
* keytool -export -alias serverkey -keystore server.keystore -storepass nosecret -file servercert.cer
* openssl x509 -out servercert.pem -outform pem -in servercert.pem -inform der
*
* keytool -export -alias clientkey -keystore client.keystore -storepass nosecret -file clientcert.cer
* openssl x509 -out clientcert.pem -outform pem -in clientcert.pem -inform der
* java -jar pkeytool.jar -exportkey -keystore client.keystore -storepass nosecret -keypass clientpass -rfc -alias clientkey -file clientkey.pem
*
* C:\Program Files\Java\jre6\bin\keytool -export -alias serverkey -keystore server.keystore -storepass nosecret -file servercert.cer
* C:\xampp\apache\bin\openssl x509 -out servercert.pem -outform pem -in servercert.cer -inform der
*
* C:\Program Files\Java\jre6\bin\keytool -export -alias clientkey -keystore client.keystore -storepass nosecret -file clientcert.cer
* C:\xampp\apache\bin\openssl x509 -out clientcert.pem -outform pem -in clientcert.cer -inform der
* java -jar C:\axis2\pkeytool\pkeytool.jar -exportkey -keystore client.keystore -storepass nosecret -keypass clientpass -rfc -alias clientkey -file clientkey.pem
*
* build.properties:
* server-policy=hash-policy-server.xml
*
* allows both text and digest!
*/
class getBook {}
class getBookResponse {}
class getBooksByType {}
class getBooksByTypeResponse {}
class addBook {}
class addBookResponse {}
class BookInformation {}
$options['classmap'] = array(
'getBook' => 'getBook',
'getBookResponse' => 'getBookResponse',
'getBooksByType' => 'getBooksByType',
'getBooksByTypeResponse' => 'getBooksByTypeResponse',
'addBook' => 'addBook',
'addBookResponse' => 'addBookResponse',
'BookInformation' => 'BookInformation',
);
$sc = new BeSimpleSoapClient('WsSecuritySigEnc.wsdl', $options);
$wssFilter = new BeSimpleWsSecurityFilter();
// user key for signature and encryption
$securityKeyUser = new BeSimpleWsSecurityKey();
$securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, 'clientkey.pem', true);
$securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, 'clientcert.pem', true);
$wssFilter->setUserSecurityKeyObject($securityKeyUser);
// service key for encryption
$securityKeyService = new BeSimpleWsSecurityKey();
$securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC);
$securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, 'servercert.pem', true);
$wssFilter->setServiceSecurityKeyObject($securityKeyService);
// TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1
$wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN);
$wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1);
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
$gb = new getBook();
$gb->isbn = '0061020052';
var_dump($sc->getBook($gb));
$ab = new addBook();
$ab->isbn = '0445203498';
$ab->title = 'The Dragon Never Sleeps';
$ab->author = 'Cook, Glen';
$ab->type = 'scifi';
var_dump($sc->addBook($ab));
// getBooksByType("scifi");
} catch (Exception $e) {
var_dump($e);
}
//var_dump(
// $sc->__getLastRequestHeaders(),
// $sc->__getLastRequest(),
// $sc->__getLastResponseHeaders(),
// $sc->__getLastResponse()
//);

View File

@ -0,0 +1,106 @@
<?php
/*
* Deploy "axis_services/library-signencr.aar" to Apache Axis2 to get this
* example to work.
*
* Links:
* http://www.dcc.uchile.cl/~pcamacho/tutorial/web/xmlsec/xmlsec.html
* http://www.aleksey.com/xmlsec/xmldsig-verifier.html
*
* Using code from axis example:
* http://www.ibm.com/developerworks/java/library/j-jws5/index.html
*
* Download key tool to export private key
* http://couchpotato.net/pkeytool/
*
* keytool -export -alias serverkey -keystore server.keystore -storepass nosecret -file servercert.cer
* openssl x509 -out servercert.pem -outform pem -in servercert.pem -inform der
*
* keytool -export -alias clientkey -keystore client.keystore -storepass nosecret -file clientcert.cer
* openssl x509 -out clientcert.pem -outform pem -in clientcert.pem -inform der
* java -jar pkeytool.jar -exportkey -keystore client.keystore -storepass nosecret -keypass clientpass -rfc -alias clientkey -file clientkey.pem
*
* C:\Program Files\Java\jre6\bin\keytool -export -alias serverkey -keystore server.keystore -storepass nosecret -file servercert.cer
* C:\xampp\apache\bin\openssl x509 -out servercert.pem -outform pem -in servercert.cer -inform der
*
* C:\Program Files\Java\jre6\bin\keytool -export -alias clientkey -keystore client.keystore -storepass nosecret -file clientcert.cer
* C:\xampp\apache\bin\openssl x509 -out clientcert.pem -outform pem -in clientcert.cer -inform der
* java -jar C:\axis2\pkeytool\pkeytool.jar -exportkey -keystore client.keystore -storepass nosecret -keypass clientpass -rfc -alias clientkey -file clientkey.pem
*
* build.properties:
* server-policy=hash-policy-server.xml
*
* allows both text and digest!
*/
use ass\XmlSecurity\Key as XmlSecurityKey;
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\WsSecurityFilter as BeSimpleWsSecurityFilter;
use BeSimple\SoapCommon\WsSecurityKey as BeSimpleWsSecurityKey;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBook;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBookResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByType;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByTypeResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBook;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation;
use BeSimple\SoapClient\Tests\AxisInterop\TestCase;
class WsSecuritySigEncAxisInteropTest extends TestCase
{
private $options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'classmap' => array(
'getBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBook',
'getBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBookResponse',
'getBooksByType' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByType',
'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByTypeResponse',
'addBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBook',
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
),
);
public function testSigEnc()
{
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $this->options);
$wssFilter = new BeSimpleWsSecurityFilter();
// user key for signature and encryption
$securityKeyUser = new BeSimpleWsSecurityKey();
$securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientkey.pem', true);
$securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientcert.pem', true);
$wssFilter->setUserSecurityKeyObject($securityKeyUser);
// service key for encryption
$securityKeyService = new BeSimpleWsSecurityKey();
$securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC);
$securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__.'/Fixtures/servercert.pem', true);
$wssFilter->setServiceSecurityKeyObject($securityKeyService);
// TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1
$wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN);
$wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1);
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
$gb = new getBook();
$gb->isbn = '0061020052';
$result = $sc->getBook($gb);
$this->assertInstanceOf('BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', $result->getBookReturn);
$ab = new addBook();
$ab->isbn = '0445203498';
$ab->title = 'The Dragon Never Sleeps';
$ab->author = 'Cook, Glen';
$ab->type = 'scifi';
$this->assertTrue((bool) $sc->addBook($ab));
// getBooksByType("scifi");
}
}

View File

@ -1,79 +0,0 @@
<?php
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\WsSecurityFilter as BeSimpleWsSecurityFilter;
require '../bootstrap.php';
$options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders
);
/*
* Deploy "axis_services/library-username-digest.aar" to Apache Axis2 to get
* this example to work.
*
* Using code from axis example:
* http://www.ibm.com/developerworks/java/library/j-jws4/index.html
*
* build.properties:
* server-policy=hash-policy-server.xml
*
* allows both text and digest!
*/
class getBook {}
class getBookResponse {}
class getBooksByType {}
class getBooksByTypeResponse {}
class addBook {}
class addBookResponse {}
class BookInformation {}
$options['classmap'] = array(
'getBook' => 'getBook',
'getBookResponse' => 'getBookResponse',
'getBooksByType' => 'getBooksByType',
'getBooksByTypeResponse' => 'getBooksByTypeResponse',
'addBook' => 'addBook',
'addBookResponse' => 'addBookResponse',
'BookInformation' => 'BookInformation',
);
$sc = new BeSimpleSoapClient('WsSecurityUserPass.wsdl', $options);
$wssFilter = new BeSimpleWsSecurityFilter(true, 600);
$wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_TEXT);
//$wssFilter->addUserData( 'libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST );
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
$gb = new getBook();
$gb->isbn = '0061020052';
var_dump($sc->getBook($gb));
$ab = new addBook();
$ab->isbn = '0445203498';
$ab->title = 'The Dragon Never Sleeps';
$ab->author = 'Cook, Glen';
$ab->type = 'scifi';
var_dump($sc->addBook($ab));
// getBooksByType("scifi");
} catch (Exception $e) {
var_dump($e);
}
//var_dump(
// $sc->__getLastRequestHeaders(),
// $sc->__getLastRequest(),
// $sc->__getLastResponseHeaders(),
// $sc->__getLastResponse()
//);

View File

@ -0,0 +1,96 @@
<?php
/*
* Deploy "axis_services/library-username-digest.aar" to Apache Axis2 to get
* this example to work.
*
* Using code from axis example:
* http://www.ibm.com/developerworks/java/library/j-jws4/index.html
*
* build.properties:
* server-policy=hash-policy-server.xml
*
* allows both text and digest!
*/
use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use BeSimple\SoapClient\WsSecurityFilter as BeSimpleWsSecurityFilter;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBook;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBookResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByType;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByTypeResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBook;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse;
use BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation;
use BeSimple\SoapClient\Tests\AxisInterop\TestCase;
class WsSecurityUserPassAxisInteropTest extends TestCase
{
private $options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
'classmap' => array(
'getBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBook',
'getBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBookResponse',
'getBooksByType' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByType',
'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByTypeResponse',
'addBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBook',
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
),
);
public function testUserPassText()
{
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options);
$wssFilter = new BeSimpleWsSecurityFilter(true, 600);
$wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_TEXT);
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
$gb = new getBook();
$gb->isbn = '0061020052';
$result = $sc->getBook($gb);
$this->assertInstanceOf('BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', $result->getBookReturn);
$ab = new addBook();
$ab->isbn = '0445203498';
$ab->title = 'The Dragon Never Sleeps';
$ab->author = 'Cook, Glen';
$ab->type = 'scifi';
$this->assertTrue((bool) $sc->addBook($ab));
// getBooksByType("scifi");
}
public function testUserPassDigest()
{
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options);
$wssFilter = new BeSimpleWsSecurityFilter(true, 600);
$wssFilter->addUserData( 'libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST );
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
$gb = new getBook();
$gb->isbn = '0061020052';
$result = $sc->getBook($gb);
$this->assertInstanceOf('BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', $result->getBookReturn);
$ab = new addBook();
$ab->isbn = '0445203498';
$ab->title = 'The Dragon Never Sleeps';
$ab->author = 'Cook, Glen';
$ab->type = 'scifi';
$this->assertTrue((bool) $sc->addBook($ab));
// getBooksByType("scifi");
}
}

View File

@ -0,0 +1,7 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class AttachmentRequest extends AttachmentType
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class AttachmentType
{
public $fileName;
public $binaryData;
}

View File

@ -0,0 +1,11 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class BookInformation
{
public $type;
public $isbn;
public $author;
public $title;
}

View File

@ -1,89 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.apache.org/axis2/mtomsample/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"> <definitions targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.apache.org/axis2/mtomsample/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
<types> <types>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2/mtomsample/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<xsd:import namespace="http://www.w3.org/2005/05/xmlmime"/> <xsd:import namespace="http://www.w3.org/2005/05/xmlmime"/>
<xsd:complexType name="AttachmentType"> <xsd:complexType name="AttachmentType">
<xsd:sequence> <xsd:sequence>
<xsd:element minOccurs="0" name="fileName" type="xsd:string"/> <xsd:element minOccurs="0" name="fileName" type="xsd:string"/>
<xsd:element minOccurs="0" name="binaryData" type="xmime:base64Binary"/> <xsd:element minOccurs="0" name="binaryData" type="xmime:base64Binary"/>
</xsd:sequence> </xsd:sequence>
</xsd:complexType> </xsd:complexType>
<xsd:element name="AttachmentRequest" type="tns:AttachmentType"/> <xsd:element name="AttachmentRequest" type="tns:AttachmentType"/>
<xsd:element name="AttachmentResponse" type="xsd:string"/> <xsd:element name="AttachmentResponse" type="xsd:string"/>
</xsd:schema> </xsd:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://www.w3.org/2005/05/xmlmime"> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://www.w3.org/2005/05/xmlmime">
<xs:attribute name="contentType"> <xs:attribute name="contentType">
<xs:simpleType> <xs:simpleType>
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:minLength value="3"/> <xs:minLength value="3"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:attribute> </xs:attribute>
<xs:attribute name="expectedContentTypes" type="xs:string"/> <xs:attribute name="expectedContentTypes" type="xs:string"/>
<xs:complexType name="base64Binary"> <xs:complexType name="base64Binary">
<xs:simpleContent> <xs:simpleContent>
<xs:extension base="xs:base64Binary"> <xs:extension base="xs:base64Binary">
<xs:attribute ref="xmime:contentType"/> <xs:attribute ref="xmime:contentType"/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
<xs:complexType name="hexBinary"> <xs:complexType name="hexBinary">
<xs:simpleContent> <xs:simpleContent>
<xs:extension base="xs:hexBinary"> <xs:extension base="xs:hexBinary">
<xs:attribute ref="xmime:contentType"/> <xs:attribute ref="xmime:contentType"/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
</xs:schema> </xs:schema>
</types> </types>
<message name="AttachmentResponse"> <message name="AttachmentResponse">
<part name="part1" element="tns:AttachmentResponse"> <part name="part1" element="tns:AttachmentResponse">
</part> </part>
</message> </message>
<message name="AttachmentRequest"> <message name="AttachmentRequest">
<part name="part1" element="tns:AttachmentRequest"> <part name="part1" element="tns:AttachmentRequest">
</part> </part>
</message> </message>
<portType name="MTOMServicePortType"> <portType name="MTOMServicePortType">
<operation name="attachment"> <operation name="attachment">
<input message="tns:AttachmentRequest" wsaw:Action="attachment"> <input message="tns:AttachmentRequest" wsaw:Action="attachment">
</input> </input>
<output message="tns:AttachmentResponse" wsaw:Action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"> <output message="tns:AttachmentResponse" wsaw:Action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse">
</output> </output>
</operation> </operation>
</portType> </portType>
<binding name="MTOMServiceSOAP11Binding" type="tns:MTOMServicePortType"> <binding name="MTOMServiceSOAP11Binding" type="tns:MTOMServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="attachment"> <operation name="attachment">
<soap:operation soapAction="attachment" style="document"/> <soap:operation soapAction="attachment" style="document"/>
<input> <input>
<soap:body use="literal"/> <soap:body use="literal"/>
</input> </input>
<output> <output>
<soap:body use="literal"/> <soap:body use="literal"/>
</output> </output>
</operation> </operation>
</binding> </binding>
<binding name="MTOMServiceSOAP12Binding" type="tns:MTOMServicePortType"> <binding name="MTOMServiceSOAP12Binding" type="tns:MTOMServicePortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="attachment"> <operation name="attachment">
<soap12:operation soapAction="attachment" style="document"/> <soap12:operation soapAction="attachment" style="document"/>
<input> <input>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</input> </input>
<output> <output>
<soap12:body use="literal"/> <soap12:body use="literal"/>
</output> </output>
</operation> </operation>
</binding> </binding>
<service name="MTOMSample"> <service name="MTOMSample">
<port name="MTOMSampleSOAP12port_http" binding="tns:MTOMServiceSOAP12Binding"> <port name="MTOMSampleSOAP12port_http" binding="tns:MTOMServiceSOAP12Binding">
<soap12:address location="http://web/BeSimpleSoapClient/tests/ServerInterop/MTOMServer.php"/> <soap12:address location="http://localhost:8081/ServerInterop/MTOMServer.php"/>
</port> </port>
<port name="MTOMSampleSOAP11port_http" binding="tns:MTOMServiceSOAP11Binding"> <port name="MTOMSampleSOAP11port_http" binding="tns:MTOMServiceSOAP11Binding">
<soap:address location="http://web/BeSimpleSoapClient/tests/ServerInterop/MTOMServer.php"/> <soap:address location="http://localhost:8081/ServerInterop/MTOMServer.php"/>
</port> </port>
</service> </service>
</definitions> </definitions>

View File

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.besimple" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.besimple">
<wsdl:documentation>BeSimpleSwaService</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.besimple">
<xs:complexType name="Exception">
<xs:sequence>
<xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Exception">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="Exception" nillable="true" type="ns:Exception"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="uploadFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="data" nillable="true" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="uploadFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="downloadFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="downloadFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="data" nillable="true" type="xs:base64Binary"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="downloadFileRequest">
<wsdl:part name="parameters" element="ns:downloadFile"/>
</wsdl:message>
<wsdl:message name="downloadFileResponse">
<wsdl:part name="parameters" element="ns:downloadFileResponse"/>
</wsdl:message>
<wsdl:message name="Exception">
<wsdl:part name="parameters" element="ns:Exception"/>
</wsdl:message>
<wsdl:message name="uploadFileRequest">
<wsdl:part name="parameters" element="ns:uploadFile"/>
</wsdl:message>
<wsdl:message name="uploadFileResponse">
<wsdl:part name="parameters" element="ns:uploadFileResponse"/>
</wsdl:message>
<wsdl:portType name="BeSimpleSwaServicePortType">
<wsdl:operation name="downloadFile">
<wsdl:input message="ns:downloadFileRequest" wsaw:Action="urn:downloadFile"/>
<wsdl:output message="ns:downloadFileResponse" wsaw:Action="urn:downloadFileResponse"/>
<wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:downloadFileException"/>
</wsdl:operation>
<wsdl:operation name="uploadFile">
<wsdl:input message="ns:uploadFileRequest" wsaw:Action="urn:uploadFile"/>
<wsdl:output message="ns:uploadFileResponse" wsaw:Action="urn:uploadFileResponse"/>
<wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:uploadFileException"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BeSimpleSwaServiceSoap11Binding" type="ns:BeSimpleSwaServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="downloadFile">
<soap:operation soapAction="urn:downloadFile" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="Exception">
<soap:fault use="literal" name="Exception"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="uploadFile">
<soap:operation soapAction="urn:uploadFile" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="Exception">
<soap:fault use="literal" name="Exception"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="BeSimpleSwaServiceSoap12Binding" type="ns:BeSimpleSwaServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="downloadFile">
<soap12:operation soapAction="urn:downloadFile" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="Exception">
<soap12:fault use="literal" name="Exception"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="uploadFile">
<soap12:operation soapAction="urn:uploadFile" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="Exception">
<soap12:fault use="literal" name="Exception"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="BeSimpleSwaServiceHttpBinding" type="ns:BeSimpleSwaServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="downloadFile">
<http:operation location="BeSimpleSwaService/downloadFile"/>
<wsdl:input>
<mime:content type="text/xml" part="downloadFile"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="downloadFile"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="uploadFile">
<http:operation location="BeSimpleSwaService/uploadFile"/>
<wsdl:input>
<mime:content type="text/xml" part="uploadFile"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="uploadFile"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BeSimpleSwaService">
<wsdl:port name="BeSimpleSwaServiceHttpSoap11Endpoint" binding="ns:BeSimpleSwaServiceSoap11Binding">
<soap:address location="http://localhost:8081/ServerInterop/SwAServer.php"/>
</wsdl:port>
<wsdl:port name="BeSimpleSwaServiceHttpSoap12Endpoint" binding="ns:BeSimpleSwaServiceSoap12Binding">
<soap12:address location="http://localhost:8081/ServerInterop/SwAServer.php"/>
</wsdl:port>
<wsdl:port name="BeSimpleSwaServiceHttpEndpoint" binding="ns:BeSimpleSwaServiceHttpBinding">
<http:address location="http://localhost:8081/ServerInterop/SwAServer.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ws.sosnoski.com/library/wsdl"
xmlns:wns="http://ws.sosnoski.com/library/wsdl"
xmlns:tns="http://ws.sosnoski.com/library/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.sosnoski.com/library/wsdl"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://ws.sosnoski.com/library/types"/>
<element name="getBook">
<complexType>
<sequence>
<element name="isbn" type="string"/>
</sequence>
</complexType>
</element>
<element name="getBookResponse">
<complexType>
<sequence>
<element name="getBookReturn" minOccurs="0" type="tns:BookInformation"/>
</sequence>
</complexType>
</element>
<element name="getBooksByType">
<complexType>
<sequence>
<element name="type" type="string"/>
</sequence>
</complexType>
</element>
<element name="getBooksByTypeResponse">
<complexType>
<sequence>
<element name="getBooksByTypeReturn" minOccurs="0" maxOccurs="unbounded" type="tns:BookInformation"/>
</sequence>
</complexType>
</element>
<element name="addBook">
<complexType>
<sequence>
<element name="type" type="string"/>
<element name="isbn" type="string"/>
<element name="author" minOccurs="0" maxOccurs="unbounded" type="string"/>
<element name="title" type="string"/>
</sequence>
</complexType>
</element>
<element name="addBookResponse">
<complexType>
<sequence>
<element name="addBookReturn" type="boolean"/>
</sequence>
</complexType>
</element>
</schema>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.sosnoski.com/library/types"
xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="BookInformation">
<sequence>
<element name="author" minOccurs="0" maxOccurs="unbounded" type="string"/>
<element name="title" type="string"/>
</sequence>
<attribute name="type" use="required" type="string"/>
<attribute name="isbn" use="required" type="string"/>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getBookRequest">
<wsdl:part element="wns:getBook" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBookResponse">
<wsdl:part element="wns:getBookResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBooksByTypeRequest">
<wsdl:part element="wns:getBooksByType" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBooksByTypeResponse">
<wsdl:part element="wns:getBooksByTypeResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="addBookRequest">
<wsdl:part element="wns:addBook" name="parameters"/>
</wsdl:message>
<wsdl:message name="addBookResponse">
<wsdl:part element="wns:addBookResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="Library">
<wsdl:operation name="getBook">
<wsdl:input message="wns:getBookRequest" name="getBookRequest"/>
<wsdl:output message="wns:getBookResponse" name="getBookResponse"/>
</wsdl:operation>
<wsdl:operation name="getBooksByType">
<wsdl:input message="wns:getBooksByTypeRequest" name="getBooksByTypeRequest"/>
<wsdl:output message="wns:getBooksByTypeResponse" name="getBooksByTypeResponse"/>
</wsdl:operation>
<wsdl:operation name="addBook">
<wsdl:input message="wns:addBookRequest" name="addBookRequest"/>
<wsdl:output message="wns:addBookResponse" name="addBookResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LibrarySoapBinding" type="wns:Library">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getBook">
<wsdlsoap:operation soapAction="urn:getBook"/>
<wsdl:input name="getBookRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getBookResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getBooksByType">
<wsdlsoap:operation soapAction="urn:getBooksByType"/>
<wsdl:input name="getBooksByTypeRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getBooksByTypeResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addBook">
<wsdlsoap:operation soapAction="urn:addBook"/>
<wsdl:input name="addBookRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="addBookResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="library-signencr">
<wsdl:port binding="wns:LibrarySoapBinding" name="library">
<wsdlsoap:address location="http://localhost:8081/ServerInterop/WsSecuritySigEncServer.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ws.sosnoski.com/library/wsdl"
xmlns:wns="http://ws.sosnoski.com/library/wsdl"
xmlns:tns="http://ws.sosnoski.com/library/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.sosnoski.com/library/wsdl"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://ws.sosnoski.com/library/types"/>
<element name="getBook">
<complexType>
<sequence>
<element name="isbn" type="string"/>
</sequence>
</complexType>
</element>
<element name="getBookResponse">
<complexType>
<sequence>
<element name="getBookReturn" minOccurs="0" type="tns:BookInformation"/>
</sequence>
</complexType>
</element>
<element name="getBooksByType">
<complexType>
<sequence>
<element name="type" type="string"/>
</sequence>
</complexType>
</element>
<element name="getBooksByTypeResponse">
<complexType>
<sequence>
<element name="getBooksByTypeReturn" minOccurs="0" maxOccurs="unbounded" type="tns:BookInformation"/>
</sequence>
</complexType>
</element>
<element name="addBook">
<complexType>
<sequence>
<element name="type" type="string"/>
<element name="isbn" type="string"/>
<element name="author" minOccurs="0" maxOccurs="unbounded" type="string"/>
<element name="title" type="string"/>
</sequence>
</complexType>
</element>
<element name="addBookResponse">
<complexType>
<sequence>
<element name="addBookReturn" type="boolean"/>
</sequence>
</complexType>
</element>
</schema>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.sosnoski.com/library/types"
xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="BookInformation">
<sequence>
<element name="author" minOccurs="0" maxOccurs="unbounded" type="string"/>
<element name="title" type="string"/>
</sequence>
<attribute name="type" use="required" type="string"/>
<attribute name="isbn" use="required" type="string"/>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getBookRequest">
<wsdl:part element="wns:getBook" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBookResponse">
<wsdl:part element="wns:getBookResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBooksByTypeRequest">
<wsdl:part element="wns:getBooksByType" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBooksByTypeResponse">
<wsdl:part element="wns:getBooksByTypeResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="addBookRequest">
<wsdl:part element="wns:addBook" name="parameters"/>
</wsdl:message>
<wsdl:message name="addBookResponse">
<wsdl:part element="wns:addBookResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="Library">
<wsdl:operation name="getBook">
<wsdl:input message="wns:getBookRequest" name="getBookRequest"/>
<wsdl:output message="wns:getBookResponse" name="getBookResponse"/>
</wsdl:operation>
<wsdl:operation name="getBooksByType">
<wsdl:input message="wns:getBooksByTypeRequest" name="getBooksByTypeRequest"/>
<wsdl:output message="wns:getBooksByTypeResponse" name="getBooksByTypeResponse"/>
</wsdl:operation>
<wsdl:operation name="addBook">
<wsdl:input message="wns:addBookRequest" name="addBookRequest"/>
<wsdl:output message="wns:addBookResponse" name="addBookResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LibrarySoapBinding" type="wns:Library">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getBook">
<wsdlsoap:operation soapAction="urn:getBook"/>
<wsdl:input name="getBookRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getBookResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getBooksByType">
<wsdlsoap:operation soapAction="urn:getBooksByType"/>
<wsdl:input name="getBooksByTypeRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getBooksByTypeResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addBook">
<wsdlsoap:operation soapAction="urn:addBook"/>
<wsdl:input name="addBookRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="addBookResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="library-username">
<wsdl:port binding="wns:LibrarySoapBinding" name="library">
<wsdlsoap:address location="http://localhost:8081/ServerInterop/WsSecurityUserPassServer.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@ -0,0 +1,11 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class addBook
{
public $type;
public $isbn;
public $author;
public $title;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class addBookResponse
{
public $addBookReturn;
}

View File

@ -0,0 +1,9 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class base64Binary
{
public $_;
public $contentType;
}

View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICoDCCAgkCBEnhw2IwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNVBAYTAk5aMRMw
EQYDVQQIEwpXZWxsaW5ndG9uMRowGAYDVQQHExFQYXJhcGFyYXVtdSBCZWFjaDEq
MCgGA1UEChMhU29zbm9za2kgU29mdHdhcmUgQXNzb2NpYXRlcyBMdGQuMRAwDgYD
VQQLEwdVbmtub3duMRgwFgYDVQQDEw9EZW5uaXMgU29zbm9za2kwHhcNMDkwNDEy
MTAzMzA2WhcNMzYwODI3MTAzMzA2WjCBljELMAkGA1UEBhMCTloxEzARBgNVBAgT
CldlbGxpbmd0b24xGjAYBgNVBAcTEVBhcmFwYXJhdW11IEJlYWNoMSowKAYDVQQK
EyFTb3Nub3NraSBTb2Z0d2FyZSBBc3NvY2lhdGVzIEx0ZC4xEDAOBgNVBAsTB1Vu
a25vd24xGDAWBgNVBAMTD0Rlbm5pcyBTb3Nub3NraTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEAhOVyNK8xyxtb4DnKtU6mF9KoiFqCk7eKoLE26+9h410CtTkx
zWAfgnR+8i+LPbdsPY+yXAo6NYpCCKolXfDLe+AG2GwnMZGrIl6+BLF3hqTmIXBF
TLGUmC7A7uBTivaWgdH1w3hb33rASoVU67BVtQ3QQi99juZX4vU9o9pScocCAwEA
ATANBgkqhkiG9w0BAQUFAAOBgQBMNPo1KAGbz8Jl6HGbtAcetieSJ3bEAXmv1tcj
ysBS67AXzdu1Ac+onHh2EpzBM7kuGbw+trU+AhulooPpewIQRApXP1F0KHRDcbqW
jwvknS6HnomN9572giLGKn2601bHiRUj35hiA8aLmMUBppIRPFFAoQ0QUBCPx+m8
/0n33w==
-----END CERTIFICATE-----

View File

@ -0,0 +1,14 @@
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAITlcjSvMcsbW+A5yrVOphfSqIha
gpO3iqCxNuvvYeNdArU5Mc1gH4J0fvIviz23bD2PslwKOjWKQgiqJV3wy3vgBthsJzGRqyJevgSx
d4ak5iFwRUyxlJguwO7gU4r2loHR9cN4W996wEqFVOuwVbUN0EIvfY7mV+L1PaPaUnKHAgMBAAEC
gYAZ6UqtLwN8YGc3fs0hMKZ9upsViuAuwPiMgED/G3twgzAF+ZLWQkmie+hMfCyf6eV200+pVm0n
Bz/8xH/oowxpX0Kk3szoB4vFghjU84GKUcrbhu/NRIm7l3drnfbzqhQkHDCx6n1CotI4Gs49cDWu
4uEAuxJkEIVY553unZjZgQJBAOJVIallNKmD0iQlvtWRmRzpmYDjt9vhNY6WBTIOx6SDn9SRaoSA
fkipQ2HXo04r78TQ674+zfZ1lRTkFG7px6ECQQCWUPHp3pSZOM1oGzJrNvNaw+MizZAZjq34npHm
9GRquFLG7BlCaI9QNGE7pN2ryYsYCRUMaM2e4GR0tUXxVGknAkAgrxqFU9AfCqI2Bh1gyf3KZxF7
w2axofwR8ygc6nV6FGfoUneHWubhp0/LuVAj4cRmL6Vbe8ZSaPh2Y9lviuMBAkEAicP8Q+1E4j1m
PPEYP51oYprANOiUFmhnWEL00+jPk+QFsd03tV6hYs/vAbwzkjuwqMHCMdJoCiH8z95IEUvc5wJA
MvLOuZdu4dmhOXg/YKsbMSPjFNEVskLQNSXqw6O2wIrpPg1NQvBBAOTbiuZj3vind4VPos1wc4vB
QocvdUC6dA==
-----END PRIVATE KEY-----

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class downloadFile
{
public $name;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class downloadFileResponse
{
public $data;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class getBook
{
public $isbn;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class getBookResponse
{
public $getBookReturn;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class getBooksByType
{
public $type;
}

View File

@ -0,0 +1,8 @@
<?php
namespace BeSimple\SoapClient\Tests\ServerInterop\Fixtures;
class getBooksByTypeResponse
{
public $getBooksByTypeReturn;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICoDCCAgkCBEnhwzMwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNVBAYTAk5aMRMw
EQYDVQQIEwpXZWxsaW5ndG9uMRowGAYDVQQHExFQYXJhcGFyYXVtdSBCZWFjaDEq
MCgGA1UEChMhU29zbm9za2kgU29mdHdhcmUgQXNzb2NpYXRlcyBMdGQuMRAwDgYD
VQQLEwdVbmtub3duMRgwFgYDVQQDEw9EZW5uaXMgU29zbm9za2kwHhcNMDkwNDEy
MTAzMjE5WhcNMzYwODI3MTAzMjE5WjCBljELMAkGA1UEBhMCTloxEzARBgNVBAgT
CldlbGxpbmd0b24xGjAYBgNVBAcTEVBhcmFwYXJhdW11IEJlYWNoMSowKAYDVQQK
EyFTb3Nub3NraSBTb2Z0d2FyZSBBc3NvY2lhdGVzIEx0ZC4xEDAOBgNVBAsTB1Vu
a25vd24xGDAWBgNVBAMTD0Rlbm5pcyBTb3Nub3NraTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEA1H3mjQCF9uce2jmm/Yq9kE4ytfvkp4c8G90cDfJXJvOiGQds
p2vDZXKuCkHQ7vsBBXPNTt8J/d8ZbEwyuB9Ccz5pJqi6Ig6Y2/mEsPthDyh5SrJV
yQ/wxUGwmfSuwdrIMnplMTq+OR9BOfT3CvjSvuy9d6BQNo4wOMkDvmZTtI8CAwEA
ATANBgkqhkiG9w0BAQUFAAOBgQCqv4475QaqlKcN2QCZJbLVKZEX+76XLQurGkgf
2fCgesRHjfUfOHyTTlhWQdEKTcBB2XviUyyW6I//fmKfXUIiQqvgh4LHdXRPEXDf
Y9nr89MjyQpDlnl6AlrvSej30a9iwVRUeVk4d6gxWHMRonKBFgh+TGexxUXHtPkf
B1Pdtg==
-----END CERTIFICATE-----

View File

@ -0,0 +1,14 @@
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANR95o0AhfbnHto5pv2KvZBOMrX7
5KeHPBvdHA3yVybzohkHbKdrw2VyrgpB0O77AQVzzU7fCf3fGWxMMrgfQnM+aSaouiIOmNv5hLD7
YQ8oeUqyVckP8MVBsJn0rsHayDJ6ZTE6vjkfQTn09wr40r7svXegUDaOMDjJA75mU7SPAgMBAAEC
gYEAmw+EvkAzggkGKpkHkt07l6J4vvQh116ILo0be9HsZzBCiaExWLr6y3z0I+gDX2ErTZ9Dotp/
oBK9qpmwKUwmYD3ogbB2AEDtN29qQxzrJR8dD742zAY6s2SrvU+HVvNmp84UutEtMceP9LsqKX3o
9ZwhY4GefkoJPdumYZa+hYECQQDzNgSE5+bZfWQnd+o59vWpF+ZGWegIW9aEb+O5jnb5msYtJGGx
SJ1UWV+c/xn2xO/djXCLVh0EFjMLgr/4g45tAkEA36pbTesmnXB4m/9Q87Ljkgo1mRXGfq5na3bU
k1FrXjxEBaumpssniyy7tT6TWiwGBIelmWCI1dv4shcQFnPBawJBAJwGDFIi3zKpQWYchJOY/bHz
lhONu9AY8n5VtValsWehRf9RtqZfuiaRi0gRU1u+rU6JXSjWHpkvkKGSyIqqAuUCQG321q8HZtPP
AS1JKKa4E9SwOkvKfe24l1YpdTf8trn9DUBwdR3aEdYGJz9jxZR2wnqlqlAvOvdSEAKW/izbuoMC
QBn5SLa7Zk2e9N5bmcV9Wa1VRC8wawKu+qO/Qj4UcmTH8bSrr4/kqh2TpMxSZ99HeCDJkSK0XZME
y+Vn2DLefIc=
-----END PRIVATE KEY-----

Some files were not shown because too many files have changed in this diff Show More