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:
0
src/BeSimple/SoapBundle/Resources/doc/_static/.gitkeep
vendored
Normal file
0
src/BeSimple/SoapBundle/Resources/doc/_static/.gitkeep
vendored
Normal file
26
src/BeSimple/SoapBundle/Resources/doc/cache.rst
Normal file
26
src/BeSimple/SoapBundle/Resources/doc/cache.rst
Normal 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>`_.
|
226
src/BeSimple/SoapBundle/Resources/doc/conf.py
Normal file
226
src/BeSimple/SoapBundle/Resources/doc/conf.py
Normal 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}
|
37
src/BeSimple/SoapBundle/Resources/doc/index.rst
Normal file
37
src/BeSimple/SoapBundle/Resources/doc/index.rst
Normal 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.
|
@ -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(),
|
||||
// ...
|
||||
);
|
||||
}
|
91
src/BeSimple/SoapBundle/Resources/doc/installation_deps.rst
Normal file
91
src/BeSimple/SoapBundle/Resources/doc/installation_deps.rst
Normal 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(),
|
||||
// ...
|
||||
);
|
||||
}
|
4
src/BeSimple/SoapBundle/Resources/doc/requirements.rst
Normal file
4
src/BeSimple/SoapBundle/Resources/doc/requirements.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Requirements
|
||||
============
|
||||
|
||||
Install and enable PHP's `SOAP extension <http://www.php.net/manual/en/soap.setup.php>`.
|
@ -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
|
@ -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);
|
||||
}
|
||||
}
|
@ -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'),
|
||||
);
|
||||
}
|
@ -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
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
Tutorials
|
||||
=========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
tutorial/array
|
||||
tutorial/associative_array
|
||||
tutorial/complex_type
|
||||
tutorial/header
|
25
src/BeSimple/SoapBundle/Resources/doc/soapserver/types.rst
Normal file
25
src/BeSimple/SoapBundle/Resources/doc/soapserver/types.rst
Normal 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
|
Reference in New Issue
Block a user