MkFramework
 All Data Structures Functions
plugin_wsdl.php
1 <?php
2 /*
3 This file is part of Mkframework.
4 
5 Mkframework is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License.
8 
9 Mkframework is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public License
15 along with Mkframework. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
24 
25  protected $tMethod;
26  protected $tmpMethod;
27  protected $url;
28  protected $sName='webservice';
29 
30  public function setName($sName){
31  $this->sName=$sName;
32  }
33 
34  public function setUrl($url){
35  $this->url=$url;
36  }
37 
38  public function addFunction($sName){
39  $this->tmpMethod=$sName;
40  }
41 
42  public function addParameter($sName,$sType){
43  $this->tMethod[$this->tmpMethod]['param'][$sName]=$sType;
44  }
45 
46  public function addReturn($sName,$sType){
47  $this->tMethod[$this->tmpMethod]['return'][$sName]=$sType;
48  }
49 
50  public function getWsdl(){
51  $sWsdl='<definitions xmlns:tns="'.$this->url.'" targetNamespace="'.$this->url.'" ';
52  $sWsdl.='xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ';
53  $sWsdl.='xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ';
54  $sWsdl.='xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="'.$this->sName.'">';
55 
56  $sWsdl.='<types>';
57  $sWsdl.='<xsd:schema targetNamespace="'.$this->url.'"/>';
58  $sWsdl.='</types>';
59 
60  $sWsdl.='<portType name="'.$this->sName.'Port">';
61  foreach($this->tMethod as $sMethod => $foo){
62  $sWsdl.='<operation name="'.$sMethod.'">';
63  $sWsdl.='<documentation>documenation</documentation>';
64  $sWsdl.='<input message="tns:'.$sMethod.'In"/>';
65  $sWsdl.='<output message="tns:'.$sMethod.'Out"/>';
66  $sWsdl.='</operation>';
67  }
68  $sWsdl.='</portType>';
69 
70 
71  $sWsdl.='<binding name="'.$this->sName.'Binding" type="tns:'.$this->sName.'Port">';
72  $sWsdl.='<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>';
73  foreach($this->tMethod as $sMethod => $foo){
74  $sWsdl.='<operation name="'.$sMethod.'">';
75  $sWsdl.='<soap:operation soapAction="'.$this->url.'#'.$sMethod.'"/>';
76  $sWsdl.='<input>';
77  $sWsdl.='<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />';
78  $sWsdl.='</input>';
79  $sWsdl.='<output>';
80  $sWsdl.='<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />';
81  $sWsdl.='</output>';
82  $sWsdl.='</operation>';
83  }
84  $sWsdl.='</binding>';
85 
86 
87  $sWsdl.='<service name="'.$this->sName.'Service">';
88  $sWsdl.='<port name="'.$this->sName.'Port" binding="tns:'.$this->sName.'Binding">';
89  $sWsdl.='<soap:address location="'.$this->url.'"/>';
90  $sWsdl.='</port>';
91  $sWsdl.='</service>';
92 
93  foreach($this->tMethod as $sMethod => $tParam){
94  $sWsdl.='<message name="'.$sMethod.'In">';
95  foreach($tParam['param'] as $sParam => $sType){
96  $sWsdl.='<part name="'.$sParam.'" type="xsd:'.$sType.'"/>';
97  }
98  $sWsdl.='</message>';
99  }
100 
101  foreach($this->tMethod as $sMethod => $tParam){
102  $sWsdl.='<message name="'.$sMethod.'Out">';
103  foreach($tParam['return'] as $sParam => $sType){
104  $sWsdl.='<part name="'.$sParam.'" type="xsd:'.$sType.'"/>';
105  }
106  $sWsdl.='</message>';
107  }
108 
109 
110  $sWsdl.='</definitions>';
111 
112 
113  return $sWsdl;
114  }
115 
116  public function show(){
117  header ("Content-Type:text/xml");
118  echo $this->getWsdl();
119  }
120 
121 }