{"id":43,"date":"2009-10-25T14:48:04","date_gmt":"2009-10-25T13:48:04","guid":{"rendered":"http:\/\/webpiraten.de\/?p=43"},"modified":"2009-10-28T20:07:53","modified_gmt":"2009-10-28T19:07:53","slug":"soap-service-mit-kohana-und-zend-autodiscover","status":"publish","type":"post","link":"https:\/\/webpiraten.de\/index.php\/php\/soap-service-mit-kohana-und-zend-autodiscover\/","title":{"rendered":"SOAP Service mit Kohana und Zend AutoDiscover"},"content":{"rendered":"<p>Eine einfache all-in-one L\u00f6sung f\u00fcr Standard SOAP Services kann man mit dem Kohana Framework und der Zend Bibliothek realisieren.<\/p>\n<p>Dazu bedarf es lediglich eines Kohana Frontcontrollers \u00fcber den wir den Service und die WSDL ansprechen k\u00f6nnen.<\/p>\n<p>Zur automatischen Generierung der WSDL, bedienen wir uns hier der Zend AutoDiscover Klasse. Dieser Klasse \u00fcbergibt man lediglich die ServiceModel-Klasse mit enthaltenen Annotationen, die die Servicefunktionen enth\u00e4lt.<\/p>\n<p>Aus den Annotationen generiert Zend AutoDiscover eine passende WSDL.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n\/**\r\n * include libs and models\r\n *\r\n *\/\r\ninclude('Zend\/Soap\/AutoDiscover.php');\r\ninclude(APPPATH . 'models\/service.php');\r\n\r\n\/**\r\n * this class represents a controller\r\n * application\/controllers\/soap.php\r\n *\r\n * @package     SOAPService\r\n * @subpackage  ...\r\n * @author      saegefisch (xxx@xxx.xx)\r\n * @copyright   (c) 2009 xxx\r\n *\/\r\nclass Soap_Controller extends Controller\r\n{\r\n    \/**\r\n     * default constructor\r\n     *\r\n     * @param void\r\n     * @return void\r\n     *\/\r\n    public function __construct()\r\n    {\r\n        \/\/ load parent constructor\r\n        parent::__construct();\r\n    }\r\n\r\n    \/**\r\n     * service to call\r\n     *\r\n     * @param void\r\n     * @return void\r\n     *\/\r\n    public function service()\r\n    {\r\n        \/\/ disable wsdl cache\r\n        ini_set('soap.wsdl_cache_enabled', '0');\r\n\r\n        \/\/ set auth settings if needed\r\n        $settings   = array(\r\n                          'login'              =&gt; 'user',\r\n                          'password'        =&gt; 'password',\r\n                          'authentication' =&gt; SOAP_AUTHENTICATION_BASIC,\r\n                          'soap_version'   =&gt; SOAP_1_2,\r\n                          'encoding'         =&gt; 'UTF-8',\r\n                          'cache_wsdl'     =&gt; WSDL_CACHE_NONE\r\n                          );\r\n\r\n        \/\/ include user:password if needed\r\n        $wsdl = 'http:\/\/user:password@' . $_SERVER&#x5B;'HTTP_HOST'] . '\/soap\/wsdl';\r\n        $server = new SoapServer($wsdl, $settings);\r\n        $server-&gt;setClass('Service_Model');\r\n        $server-&gt;handle();\r\n    }\r\n\r\n    \/**\r\n     * wsdl to call\r\n     *\r\n     * @param void\r\n     * @return void\r\n     *\/\r\n    public function wsdl()\r\n    {\r\n        \/\/ disable wsdl cache\r\n        ini_set('soap.wsdl_cache_enabled', '0');\r\n\r\n        $wsdl = new Zend_Soap_AutoDiscover();\r\n        $wsdl-&gt;setUri('http:\/\/' . $_SERVER&#x5B;'HTTP_HOST'] . '\/soap\/service');\r\n        $wsdl-&gt;setClass('Service_Model');\r\n        $wsdl-&gt;handle();\r\n    }\r\n}\r\n\r\n<\/pre>\n<p>Hier stellen wir das Standard Model f\u00fcr unseren SOAP Service zusammen.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n\/**\r\n * this class represents a model\r\n * application\/models\/service.php\r\n *\r\n * @package     SOAPService\r\n * @subpackage  ...\r\n * @author      saegefisch (xxx@xxx.xx)\r\n * @copyright   (c) 2009\r\n *\/\r\nclass Service_Model extends Model\r\n{\r\n    \/**\r\n     * default constructor\r\n     *\r\n     * @param   void\r\n     * @return  void\r\n     *\/\r\n    public function __construct()\r\n    {\r\n        \/\/ load database library into $this-&gt;db (can be omitted if not required)\r\n        parent::__construct();\r\n    }\r\n\r\n    \/**\r\n     * dummy function\r\n     *\r\n     * @param   int $int\r\n     * @param   string $string\r\n     * @param   array $arr\r\n     * @param   object $obj\r\n     * @param   bool $bool\r\n     * @return  array\r\n     *\/\r\n    public function get_dummy_array($int, $string, $arr, $obj, $bool)\r\n    {\r\n        return array();\r\n    }\r\n\r\n    \/**\r\n     * dummy function\r\n     *\r\n     * @param   int $int\r\n     * @param   string $string\r\n     * @param   array $arr\r\n     * @param   object $obj\r\n     * @param   bool $bool\r\n     * @return  bool\r\n     *\/\r\n    public function get_dummy_boolean($int, $string, $arr, $obj, $bool)\r\n    {\r\n        return true;\r\n    }\r\n\r\n    \/**\r\n     * dummy function\r\n     *\r\n     * @param   int $int\r\n     * @param   string $string\r\n     * @param   array $arr\r\n     * @param   object $obj\r\n     * @param   bool $bool\r\n     * @return  string\r\n     *\/\r\n    public function get_dummy_string($int, $string, $arr, $obj, $bool)\r\n    {\r\n        return 'foo=bar';\r\n    }\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Eine einfache all-in-one L\u00f6sung f\u00fcr Standard SOAP Services kann man mit dem Kohana Framework und der Zend Bibliothek realisieren. Dazu bedarf es lediglich eines Kohana Frontcontrollers \u00fcber den wir den Service und die WSDL ansprechen k\u00f6nnen. Zur automatischen Generierung der WSDL, bedienen wir uns hier der Zend AutoDiscover Klasse. Dieser Klasse \u00fcbergibt man lediglich die [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,5,44,29],"tags":[45,16,48,9,14,46,49,640,47,636],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-kohana-framework","category-php","category-soap","category-zend-framework","tag-autodiscover","tag-controller","tag-generator","tag-kohana","tag-model","tag-service","tag-soa","tag-soap","tag-wsdl","tag-zend-framework"],"_links":{"self":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":13,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/43\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}