3 * Created on Oct 19, 2008
5 * The pupose of this file is to manage the wsdl
7 * To change the template for this generated file go to
8 * Window - Preferences - PHPeclipse - PHP - Code Templates
12 * Heres how this works.. its simple... When you define an exportable function
13 * you simple create your function (myFunction($whatever)) and then add it to mfapi_wsdlFunctions
15 * $mfapi_exportedFunctions["myfunctionname"] = "myFunction";
16 * note that "myfunctionname" serves no purpose except as a place holder in the array - i.e. make it unique
18 * The XSD is created like so: myFunctionResponse myFunction(myFunctionRequest) - simple eh?
19 * Now, myFunctionResponce/Request (all of these things actually) have only one format
20 * class { string: stringpass[] }
22 * This means data is passed into your function looking like this (the xsd produced makes it unbounded):
23 * $object->stringpass[0] = "something";
24 * $object->stringpass[1] = "something";
26 * And you need to pass out the same way, i.e.:
27 * $mypassout = new dataContainer();
28 * $mypassout->stringpass[0] = "something";
32 * I was planning on implementing a way for functions to define "real" schemas and have
33 * the above as a default, but for now, this will do. Technically its not a "kind" thing
34 * to do because the only person who knows what the funtions expects and what the function
35 * returns is the person coding the function. But this will change, and later this will be the
36 * default, but you'll be expected to define a schema for your function, unless your function
37 * really is just returning a list of strings. This becomes important later on when
38 * the web comes into play because in order for the website to be able to accept input for
39 * foreign data, it'll need to know how to format a form (for example)
41 * I expect this will take the form of something like
42 * function myFunction();
43 * function myFunctionInSchema();
44 * function myFunctionOutSchema();
45 * or maybe these will take the form of some functional array.. It requires some
46 * thought, but you'll still just define the one thing in the wsdlFunctions array.
49 * $mfapi_exportedFunctions has the following format
51 * $mfapi_exportedFunctions[funcname] = "name";
53 * format simplified at commit 694 in home repo
56 // this the class used to pass around data between soap connections
57 // Im really not a fan of OO in php...
62 // function for generation of XSD
63 function sp_generateXSD($location, $soapFunctions)
69 $return .='<?xml version="1.0" encoding="UTF-8"?>'."\n";
70 $return .='<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://minifed.sourceforge.net/res/" targetNamespace="http://minifed.sourceforge.net/res/" version="0.1">'."\n";
71 foreach($soapFunctions as $key => $val) {
73 // check the function exists first
74 if(function_exists($val)) {
75 // request type for function
76 //$return .='<xsd:element name="'.$val.'Request" targetNamespace="http://minifed.sourceforge.net/res/">'."\n";
77 $return .='<xsd:element xmlns:ns="http://minifed.sourceforge.net/res/" name="'.$val.'Request" type="ns:'.$val.'Request"/>'."\n";
78 $return .='<xsd:complexType name="'.$val.'Request">'."\n";
79 $return .='<xsd:sequence>'."\n";
80 $return .='<xsd:element name="stringpass" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>'."\n";
81 //$return .='<xsd:element name="stringpass" type="xsd:string"/>'."\n";
82 $return .='</xsd:sequence>'."\n";
83 $return .='</xsd:complexType>'."\n";
84 //$return .='</xsd:element>'."\n";
86 // response type for function
87 //$return .='<xsd:element name="'.$val.'Responce" targetNamespace="http://minifed.sourceforge.net/res/">'."\n";
88 $return .='<xsd:element xmlns:ns="http://minifed.sourceforge.net/res/" name="'.$val.'Response" type="ns:'.$val.'Response"/>'."\n";
89 $return .='<xsd:complexType name="'.$val.'Response">'."\n";
90 $return .='<xsd:sequence>'."\n";
91 $return .='<xsd:element name="stringpass" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>'."\n";
92 //$return .='<xsd:element name="stringpass" type="xsd:string" />'."\n";
93 $return .='</xsd:sequence>'."\n";
94 $return .='</xsd:complexType>'."\n";
95 //$return .='</xsd:element>'."\n";
98 $return .='</xsd:schema>'."\n";
103 // This function was greatly simplified at commit 694.
104 // I need to generate as xsd as well
105 function sp_generateWSDL($location, $soapFunctions)
111 $retarray .= '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n";
112 $retarray .= '<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://minifed.sourceforge.net/res/" ';
113 $retarray .= 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="minifedAPI" ';
114 $retarray .= 'targetNamespace="http://minifed.sourceforge.net/res/">'."\n";
119 $retarray .= '<wsdl:types>'."\n";
120 //$retarray .= '<xsd:schema targetNamespace="http://minifed.sourceforge.net/res/">'."\n";
121 $retarray .= '<xsd:schema>'."\n";
122 $retarray .= '<xsd:import schemaLocation="'.$location.'?xsd" namespace="http://minifed.sourceforge.net/res/" />'."\n";
123 //$retarray .= mfapi_generateXSD("none");
124 $retarray .= '</xsd:schema>'."\n";
125 $retarray .= '</wsdl:types>'."\n";
127 // now the message types
128 foreach($soapFunctions as $key => $val) {
130 // check the function exists first
131 if(function_exists($val)) {
132 $retarray .= '<wsdl:message name="'.$val.'Request">'."\n";
133 $retarray .= "\t".'<wsdl:part name="parameters" element="tns:'.$val.'Request"/>'."\n";
134 $retarray .= '</wsdl:message>'."\n";
135 $retarray .= '<wsdl:message name="'.$val.'Response">'."\n";
136 $retarray .= "\t".'<wsdl:part name="parameters" element="tns:'.$val.'Response"/>'."\n";
137 $retarray .= '</wsdl:message>'."\n";
144 // now the port types
145 $retarray .= '<wsdl:portType name="minifedAPIPortType">'."\n";
146 foreach($soapFunctions as $key => $val) {
147 // check the function exists first
148 if(function_exists($val)) {
150 $retarray .= "\t".'<wsdl:operation name="'.$val.'">'."\n";
151 $retarray .= "\t\t".'<wsdl:input message="tns:'.$val.'Request"/>'."\n";
152 $retarray .= "\t\t".'<wsdl:output message="tns:'.$val.'Response"/>'."\n";
153 $retarray .= "\t".'</wsdl:operation>'."\n";
156 $retarray .= '</wsdl:portType>'."\n";
161 $retarray .= '<wsdl:binding name="mfapiSOAP" type="tns:minifedAPIPortType">'."\n";
162 $retarray .= "\t".'<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>'."\n";
163 foreach($soapFunctions as $key => $val) {
164 if(function_exists($val)) {
166 $retarray .= "\t".'<wsdl:operation name="'.$val.'">'."\n";
167 $retarray .= "\t\t".'<soap:operation soapAction="" />'."\n";
168 $retarray .= "\t\t".'<wsdl:input>'."\n";
169 $retarray .= "\t\t\t".'<soap:body use="literal" />'."\n";
170 $retarray .= "\t\t".'</wsdl:input>'."\n";
171 $retarray .= "\t\t".'<wsdl:output>'."\n";
172 $retarray .= "\t\t\t".'<soap:body use="literal" />'."\n";
173 $retarray .= "\t\t".'</wsdl:output>'."\n";
175 $retarray .= "\t".'</wsdl:operation>'."\n";
179 $retarray .= '</wsdl:binding>'."\n";
184 $retarray .= '<wsdl:service name="minifedAPI">'."\n";
185 $retarray .= "\t".'<wsdl:port binding="tns:mfapiSOAP" name="mfapiPort">'."\n";
186 $retarray .= "\t\t".'<soap:address location="'.$location.'"/>'."\n";
187 $retarray .= "\t".'</wsdl:port>'."\n";
188 $retarray .= '</wsdl:service>'."\n";
189 $retarray .= '</wsdl:definitions>'."\n";
192 // and return the array