Add 'src/BeSimple/SoapBundle/' from commit 'e99f707b105c0a0472260d8d42a5a14a7fb7a211'

git-subtree-dir: src/BeSimple/SoapBundle
git-subtree-mainline: 9a8d23fa23
git-subtree-split: e99f707b10
This commit is contained in:
Francis Besset
2013-07-19 17:00:11 +02:00
94 changed files with 5786 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="besimple.soap.client.builder.class">BeSimple\SoapBundle\Soap\SoapClientBuilder</parameter>
<parameter key="besimple.soap.classmap.class">BeSimple\SoapCommon\Classmap</parameter>
</parameters>
<services>
<service id="besimple.soap.client.builder" class="%besimple.soap.client.builder.class%" abstract="true">
<argument /> <!-- wsdl URI -->
<argument type="collection">
<argument key="debug">%kernel.debug%</argument>
</argument>
<argument type="service" id="besimple.soap.classmap" />
<argument type="service" id="besimple.soap.converter.collection" />
<argument type="service" id="besimple.soap.cache" />
</service>
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" />
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
</services>
</container>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="besimple.soap.converter.collection.class">BeSimple\SoapCommon\Converter\TypeConverterCollection</parameter>
<parameter key="besimple.soap.converter.date_time.class">BeSimple\SoapCommon\Converter\DateTimeTypeConverter</parameter>
<parameter key="besimple.soap.converter.date.class">BeSimple\SoapCommon\Converter\DateTypeConverter</parameter>
</parameters>
<services>
<service id="besimple.soap.converter.collection" class="%besimple.soap.converter.collection.class%" />
<service id="besimple.soap.converter.date_time" class="%besimple.soap.converter.date_time.class%" public="false">
<tag name="besimple.soap.converter" />
</service>
<service id="besimple.soap.converter.date" class="%besimple.soap.converter.date.class%" public="false">
<tag name="besimple.soap.converter" />
</service>
</services>
</container>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="besimple.soap.definition.loader.resolver.class">Symfony\Component\Config\Loader\LoaderResolver</parameter>
<parameter key="besimple.soap.definition.loader.class">Symfony\Component\Config\Loader\DelegatingLoader</parameter>
<parameter key="besimple.soap.definition.loader.annot_dir.class">BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationDirectoryLoader</parameter>
<parameter key="besimple.soap.definition.loader.annot_file.class">BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationFileLoader</parameter>
<parameter key="besimple.soap.definition.loader.annot_class.class">BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationClassLoader</parameter>
<parameter key="besimple.soap.definition.loader.annot_complextype.class">BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader</parameter>
</parameters>
<services>
<service id="besimple.soap.definition.loader.resolver" class="%besimple.soap.definition.loader.resolver.class%" public="false" />
<service id="besimple.soap.definition.loader" class="%besimple.soap.definition.loader.class%">
<argument type="service" id="besimple.soap.definition.loader.resolver" />
</service>
<service id="besimple.soap.definition.loader.annot_file" class="%besimple.soap.definition.loader.annot_file.class%" public="false">
<tag name="besimple.soap.definition.loader" />
<argument type="service" id="file_locator" />
<argument type="service" id="besimple.soap.definition.loader.annot_class" />
</service>
<service id="besimple.soap.definition.loader.annot_class" class="%besimple.soap.definition.loader.annot_class.class%" public="false">
<tag name="besimple.soap.definition.loader" />
<argument type="service" id="annotation_reader" />
</service>
<service id="besimple.soap.definition.loader.annot_complextype" class="%besimple.soap.definition.loader.annot_complextype.class%" public="false">
<argument type="service" id="annotation_reader" />
</service>
</services>
</container>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="_webservice_call" pattern="/{webservice}">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
<default key="_format">xml</default>
<requirement key="_method">POST</requirement>
</route>
<route id="_webservice_definition" pattern="/{webservice}">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
<default key="_format">xml</default>
<requirement key="_method">GET</requirement>
</route>
</routes>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="besimple.soap.cache.class">BeSimple\SoapBundle\Cache</parameter>
<parameter key="besimple.soap.cache.dir">%kernel.cache_dir%/besimple/soap</parameter>
</parameters>
<services>
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
<argument>%kernel.debug%</argument>
<argument>%besimple.soap.cache.type%</argument>
<argument>%besimple.soap.cache.dir%/php</argument>
<argument>%besimple.soap.cache.lifetime%</argument>
<argument>%besimple.soap.cache.limit%</argument>
</service>
</services>
</container>

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<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.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.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestMessageBinder</parameter>
<parameter key="besimple.soap.binder.response.rpcliteral.class">BeSimple\SoapBundle\ServiceBinding\RpcLiteralResponseMessageBinder</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.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\SoapBundle\Converter\TypeRepository</parameter>
<parameter key="besimple.soap.server.classmap.class">BeSimple\SoapCommon\Classmap</parameter>
</parameters>
<services>
<service id="besimple.soap.response" class="%besimple.soap.response.class%" />
<service id="besimple.soap.response.listener" class="%besimple.soap.response.listener.class%">
<tag name="kernel.event_listener" event="kernel.view" method="onKernelView" />
<argument type="service" id="besimple.soap.response" />
</service>
<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.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="collection">
<argument key="cache_dir">%besimple.soap.cache.dir%</argument>
<argument key="debug">%kernel.debug%</argument>
<argument key="cache_type">null</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_response_class">%besimple.soap.binder.response.rpcliteral.class%</argument>
</argument>
<argument type="service" id="besimple.soap.cache" />
</service>
<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.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="collection">
<argument key="cache_dir">%besimple.soap.cache.dir%</argument>
<argument key="debug">%kernel.debug%</argument>
<argument key="cache_type">null</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_response_class">%besimple.soap.binder.response.documentwrapped.class%</argument>
</argument>
<argument type="service" id="besimple.soap.cache" />
</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.type.repository" class="%besimple.soap.type.repository.class%">
<call method="addXmlNamespace">
<argument>xsd</argument>
<argument>http://www.w3.org/2001/XMLSchema</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>string</argument>
<argument>xsd:string</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>boolean</argument>
<argument>xsd:boolean</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>int</argument>
<argument>xsd:int</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>float</argument>
<argument>xsd:float</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>date</argument>
<argument>xsd:date</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>dateTime</argument>
<argument>xsd:dateTime</argument>
</call>
</service>
</services>
</container>

View File

View File

@ -0,0 +1,26 @@
Cache
=====
Configuration
-------------
Configure the cache of PHP Soap WSDL in your config file:
.. code-block:: yaml
# app/config/config.yml
be_simple_soap:
cache:
type: disk
lifetime: 86400
limit: 5
The cache type can be: **none**, **disk** (default value), **memory**, **disk_memory**.
The lifetime in seconds of a WSDL file in the cache (**86400 is the default value by PHP**).
The limit is the maximum number of in-memory cached WSDL files (**5 is the default value by PHP**).
The WSDL files cached are written in cache folder of your Symfony2 application.
If you want more information you can visit the following page `PHP Soap runtime configuration <http://www.php.net/manual/en/soap.configuration.php>`_.

View File

@ -0,0 +1,226 @@
# -*- coding: utf-8 -*-
#
# BeSimpleSoapBundle documentation build configuration file, created by
# sphinx-quickstart on Mon Aug 1 22:24:10 2011.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from sphinx.highlighting import lexers
from pygments.lexers.web import PhpLexer
lexers['php'] = PhpLexer(startinline=True)
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath('_exts'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'BeSimpleSoapBundle'
copyright = u'2011, Christian Kerl, Francis Besset'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.0-DEV'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
#pygments_style = 'sphinx'
pygments_style = 'perldoc'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'BeSimpleSoapBundledoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'BeSimpleSoapBundle.tex', u'BeSimpleSoapBundle Documentation',
u'Christian Kerl, Francis Besset', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'besimplesoapbundle', u'BeSimpleSoapBundle Documentation',
[u'Christian Kerl, Francis Besset'], 1)
]
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}

View File

@ -0,0 +1,37 @@
==================
BeSimpleSoapBundle
==================
The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services.
It is based on the `ckWebServicePlugin <http://www.symfony-project.org/plugins/ckWebServicePlugin>`_ for symfony.
---------------
Reference Guide
---------------
.. toctree::
:maxdepth: 1
:numbered:
requirements
installation_composer
installation_deps
cache
----------
SoapServer
----------
.. toctree::
:maxdepth: 1
:numbered:
soapserver/configuration
soapserver/types
soapserver/tutorials
----------
SoapClient
----------
Coming soon.

View File

@ -0,0 +1,55 @@
Installation with Composer
==========================
Add `besimple/soap-bundle <https://packagist.org/packages/besimple/soap-bundle>`_ (with vendors) in your composer.json:
.. code-block:: json
{
"require": {
"besimple/soap-bundle": "dev-master",
"besimple/soap-common": "dev-master",
"ass/xmlsecurity": "dev-master"
}
}
To install the server please add `besimple/soap-server <https://packagist.org/packages/besimple/soap-server>`_ in your composer.json:
.. code-block:: json
{
"require": {
"besimple/soap-server": "dev-master"
}
}
To install the client please add `besimple/soap-client <https://packagist.org/packages/besimple/soap-client>`_ in your composer.json:
.. code-block:: json
{
"require": {
"besimple/soap-client": "dev-master"
}
}
Run this command to download the new vendors:
.. code-block:: bash
$ php composer.phar self-update
$ php composer.phar update
Enable the `BeSimpleSoapBundle <https://github.com/BeSimple/BeSimpleSoapBundle>`_ in your Kernel class
.. code-block:: php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new BeSimple\SoapBundle\BeSimpleSoapBundle(),
// ...
);
}

View File

@ -0,0 +1,91 @@
Installation with deps file (deprecated)
========================================
**The installation with deps file is deprecated.
Please prefer install the** `BeSimpleSoapBundle <https://github.com/BeSimple/BeSimpleSoapBundle>`_ **with** `Composer <http://getcomposer.org>`_.
Download `BeSimple\\SoapCommon <http://github.com/BeSimple/BeSimpleSoapCommon>`_ and `BeSimple\\SoapServer <http://github.com/BeSimple/BeSimpleSoapServer>`_ (only for the server part) and/or `BeSimple\\SoapClient <http://github.com/BeSimple/BeSimpleSoapClient>`_ (only for ther client part).
.. code-block:: ini
; deps file
[BeSimple\SoapCommon]
git=https://github.com/BeSimple/BeSimpleSoapCommon.git
target=besimple-soapcommon
[BeSimple\SoapClient]
git=https://github.com/BeSimple/BeSimpleSoapClient.git
target=besimple-soapclient
[BeSimple\SoapServer]
git=https://github.com/BeSimple/BeSimpleSoapServer.git
target=besimple-soapserver
Add `BeSimple` libraries in autoload.php
.. code-block:: php
// app/autoload.php
$loader->registerNamespaces(array(
'BeSimple\\SoapCommon' => __DIR__.'/../vendor/besimple-soapcommon/src',
'BeSimple\\SoapServer' => __DIR__.'/../vendor/besimple-soapserver/src',
'BeSimple\\SoapClient' => __DIR__.'/../vendor/besimple-soapclient/src',
// your other namespaces
));
Download `Zend\\Soap <http://github.com/BeSimple/zend-soap>`_ and `Zend\\Mime <http://github.com/BeSimple/zend-mime>`_ or add in `deps` file. `Zend` library is required only for the server part.
.. code-block:: ini
; deps file
[Zend\Soap]
git=http://github.com/BeSimple/zend-soap.git
target=/zend-framework/library/Zend/Soap
[Zend\Mime]
git=http://github.com/BeSimple/zend-mime.git
target=/zend-framework/library/Zend/Mime
Add `Zend` library in autoload.php
.. code-block:: php
// app/autoload.php
$loader->registerNamespaces(array(
'Zend' => __DIR__.'/../vendor/zend-framework/library',
// your other namespaces
));
`Download <http://github.com/BeSimple/BeSimpleSoapBundle>`_ the bundle or add in `deps` file
.. code-block:: ini
; deps file
[BeSimpleSoapBundle]
git=http://github.com/BeSimple/BeSimpleSoapBundle.git
target=/bundles/BeSimple/SoapBundle
Add `BeSimple` in autoload.php
.. code-block:: php
// app/autoload.php
$loader->registerNamespaces(array(
'BeSimple' => __DIR__.'/../vendor/bundles',
// your other namespaces
));
Add `BeSimpleSoapBundle` in your Kernel class
.. code-block:: php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new BeSimple\SoapBundle\BeSimpleSoapBundle(),
// ...
);
}

View File

@ -0,0 +1,4 @@
Requirements
============
Install and enable PHP's `SOAP extension <http://www.php.net/manual/en/soap.setup.php>`.

View File

@ -0,0 +1,70 @@
Configuration
=============
Routing
-------
Include the `BeSimpleSoapBundle`'s routing configuration in your routing file (you can choose the prefix arbitrarily):
.. code-block:: yaml
# app/config/routing.yml
_besimple_soap:
resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
prefix: /ws
Config
------
Configure your first web service in your config file:
.. code-block:: yaml
# app/config/config.yml
be_simple_soap:
services:
DemoApi:
namespace: http://mysymfonyapp.com/ws/DemoApi/1.0/
binding: rpc-literal
resource: "@AcmeDemoBundle/Controller/DemoController.php"
resource_type: annotation
Annotations for Controllers
---------------------------
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("hello")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function helloAction($name)
{
return sprintf('Hello %s!', $name);
}
/**
* @Soap\Method("goodbye")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function goodbyeAction($name)
{
return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Goodbye %s!', $name));
}
}
Get your WSDL
-------------
To access your WSDL go to the following address: http://localhost/app_dev.php/ws/DemoApi?wsdl
To read the WSDL in your browser you can call this address (without `wsdl` parameter): http://localhost/app_dev.php/ws/DemoApi

View File

@ -0,0 +1,25 @@
Array
=====
Controller
----------
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("hello")
* @Soap\Param("names", phpType = "string[]")
* @Soap\Result(phpType = "string")
*/
public function helloAction(array $names)
{
return "Hello ".implode(', ', $names);
}
}

View File

@ -0,0 +1,99 @@
Associative Array
=================
Pre-existent Type
-----------------
+------------------------------------------------+-----------------+
| Php Type | Value Type |
+================================================+=================+
| BeSimple\\SoapCommon\\Type\\KeyValue\\String | String |
+------------------------------------------------+-----------------+
| BeSimple\\SoapCommon\\Type\\KeyValue\\Boolean | Boolean |
+------------------------------------------------+-----------------+
| BeSimple\\SoapCommon\\Type\\KeyValue\\Int | Int |
+------------------------------------------------+-----------------+
| BeSimple\\SoapCommon\\Type\\KeyValue\\Float | Float |
+------------------------------------------------+-----------------+
| BeSimple\\SoapCommon\\Type\\KeyValue\\Date | DateTime object |
+------------------------------------------------+-----------------+
| BeSimple\\SoapCommon\\Type\\KeyValue\\DateTime | DateTime object |
+------------------------------------------------+-----------------+
Controller
----------
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("returnAssocArray")
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
*/
public function assocArrayOfStringAction()
{
return array(
'foo' => 'bar',
'bar' => 'foo',
);
}
/**
* @Soap\Method("sendAssocArray")
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
* @Soap\Return(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
*/
public function assocArrayOfStringAction(array $assocArray)
{
// The $assocArray it's a real associative array
// var_dump($assocArray);die;
return $assocArray;
}
}
How to create my Associative Array?
-----------------------------------
.. code-block:: php
namespace Acme\DemoBundle\Soap\Type;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use BeSimple\SoapCommon\Type\AbstractKeyValue;
class User extends AbstractKeyValue
{
/**
* @Soap\ComplexType("Acme\DemoBundle\Entity\User")
*/
protected $value;
}
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use Acme\DemoBundle\Entity\User;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("getUsers")
* @Soap\Result(phpType = "Acme\DemoBundle\Soap\Type\User[]")
*/
public function getUsers()
{
return array(
'user1' => new User('user1', 'user1@user.com'),
'user2' => new User('user2', 'user2@user.com'),
);
}

View File

@ -0,0 +1,137 @@
Complex Type
============
This tutorial explains how to do to return a complex type.
If your SOAP function takes a complex type as input, this tutorial is
valid. You'll just have to adapt the input parameters of your method.
Controller
----------
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("getUser")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "Acme\DemoBundle\Entity\User")
*/
public function getUserAction($name)
{
$user = $this->container->getDoctrine()->getRepository('MyApp:User')->findOneBy(array(
'name' => $name,
));
if (!$user) {
throw new \SoapFault('USER_NOT_FOUND', sprintf('The user with the name "%s" can not be found', $name));
}
return $user;
}
}
User class
----------
You can expose only the properties (public, protected or private) of a complex type.
**For performance reasons, we advise to create getter and setter for each property.**
.. code-block:: php
namespace Acme\DemoBundle\Entity;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
class User
{
/**
* @Soap\ComplexType("string")
*/
public $firstname;
/**
* @Soap\ComplexType("string")
*/
public $lastname;
/**
* @Soap\ComplexType("int", nillable=true)
*/
private $id;
/**
* @Soap\ComplexType("string")
*/
private $username;
/**
* @Soap\ComplexType("string")
*/
private $email;
/**
* @Soap\ComplexType("boolean")
*/
private $newsletter;
public function getId()
{
return $this->id;
}
public function getUsername()
{
return $this->username;
}
public function getEmail()
{
return $this->email;
}
public function getFirstname()
{
return $this->firstname;
}
public function setFirstname($firstname)
{
$this->firstname = $firstname;
}
public function getLastname()
{
return $this->lastname;
}
public function setLastname($lastname)
{
$this->lastname = $lastname;
}
public function hasNewsletter()
{
return $this->newsletter;
}
public function setNewsletter($newsletter)
{
$this->newletter = (Boolean) $newsletter
}
}
ComplexType
-----------
`ComplexType` accepts the following options:
* nillable: To specify that the value can be null

View File

@ -0,0 +1,89 @@
Header
======
Controller
----------
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("hello")
* @Soap\Header("api_key", phpType = "string")
* @Soap\Param("names", phpType = "string[]")
* @Soap\Result(phpType = "string")
*/
public function helloAction(array $names)
{
$soapHeaders = $this->container->get('request')->getSoapHeaders();
// You can use '1234' !== (string) $soapHeaders->get('api_key')
if (!$soapHeaders->has('api_key') || '1234' !== $soapHeaders->get('api_key')->getData()) {
throw new \SoapFault("INVALID_API_KEY", "The api_key is invalid.");
}
return "Hello ".implode(', ', $names);
}
}
Global header
-------------
If you want use a header for all actions of your controller you can declare the header like this:
.. code-block:: php
namespace Acme\DemoBundle\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* @Soap\Header("api_key", phpType = "string")
*/
class DemoController extends ContainerAware
{
/**
* @Soap\Method("hello")
* @Soap\Param("names", phpType = "string[]")
* @Soap\Result(phpType = "string")
*/
public function helloAction(array $names)
{
return "Hello ".implode(', ', $names);
}
/**
* @Soap\Method("welcome")
* @Soap\Param("names", phpType = "string[]")
* @Soap\Result(phpType = "string")
*/
public function welcomeAction($names)
{
return "Welcome ".implode(', ', $names);
}
public function setContainer(ContainerInterface $container = null)
{
parent::setContainer($container);
$this->checkApiKeyHeader();
}
private function checkApiKeyHeader()
{
$soapHeaders = $this->container->get('request')->getSoapHeaders();
// You can use '1234' !== (string) $soapHeaders->get('api_key')
if (!$soapHeaders->has('api_key') || '1234' !== $soapHeaders->get('api_key')->getData()) {
throw new \SoapFault("INVALID_API_KEY", "The api_key is invalid.");
}
}
}

View File

@ -0,0 +1,10 @@
Tutorials
=========
.. toctree::
:maxdepth: 1
tutorial/array
tutorial/associative_array
tutorial/complex_type
tutorial/header

View File

@ -0,0 +1,25 @@
Types available
===============
+----------+-----------------+
| Php Type | XML Type |
+==========+=================+
| string | `xsd:string`_ |
+----------+-----------------+
| boolean | `xsd:boolean`_ |
+----------+-----------------+
| int | `xsd:int`_ |
+----------+-----------------+
| float | `xsd:float`_ |
+----------+-----------------+
| date | `xsd:date`_ |
+----------+-----------------+
| dateTime | `xsd:dateTime`_ |
+----------+-----------------+
.. _`xsd:string`: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#string
.. _`xsd:boolean`: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#boolean
.. _`xsd:int`: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#int
.. _`xsd:float`: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#float
.. _`xsd:date`: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#date
.. _`xsd:dateTime`: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#dateTime

View File

@ -0,0 +1,7 @@
Copyright (c) 2010-2013 Christian Kerl, Francis Besset
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.