Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 KB | None | 0 0
  1. $this->setClass('WebSvcSoapFunctions');
  2. $this->setPersistence(SOAP_PERSISTENCE_SESSION);
  3.  
  4. <?xml version="1.0" encoding="UTF-8"?>
  5.  
  6. <wsdl:types>
  7.  
  8. <schema xmlns:rns="http://soap.jrimer-amp64/" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soap.jrimer-amp64/" version="1.0.0" elementFormDefault="unqualified" attributeFormDefault="unqualified">
  9.  
  10. <complexType name="versionRequest">
  11. </complexType>
  12.  
  13. <complexType name="versionResponse">
  14. <sequence>
  15. <element name="result" type="string" minOccurs="1"/>
  16. </sequence>
  17. </complexType>
  18.  
  19. <complexType name="loginRequest">
  20. <sequence>
  21. <element name="username" type="string" use="required"/>
  22. <element name="password" type="string" use="required"/>
  23. </sequence>
  24. </complexType>
  25.  
  26. <complexType name="loginResponse">
  27. <sequence>
  28. <element name="result" type="string" minOccurs="1"/>
  29. </sequence>
  30. </complexType>
  31.  
  32. <complexType name="logoutRequest">
  33. </complexType>
  34.  
  35. <complexType name="logoutResponse">
  36. <sequence>
  37. <element name="result" type="string" minOccurs="1"/>
  38. </sequence>
  39. </complexType>
  40.  
  41. </schema>
  42.  
  43. </wsdl:types>
  44.  
  45.  
  46. <wsdl:service name="XxxxxxSvc">
  47.  
  48. <wsdl:port name="XxxxxxSvc-Endpoint0" binding="tns:XxxxxxSvc-Endpoint0Binding">
  49. <soap:address location="http://soap.jrimer-amp64/"/>
  50. </wsdl:port>
  51.  
  52. </wsdl:service>
  53.  
  54.  
  55. <wsdl:portType name="portType">
  56.  
  57. <wsdl:operation name="version">
  58. <wsdl:input message="tns:versionRequest"/>
  59. <wsdl:output message="tns:versionResponse"/>
  60. </wsdl:operation>
  61. <wsdl:operation name="login">
  62. <wsdl:input message="tns:loginRequest"/>
  63. <wsdl:output message="tns:loginResponse"/>
  64. </wsdl:operation>
  65. <wsdl:operation name="logout">
  66. <wsdl:input message="tns:logoutRequest"/>
  67. <wsdl:output message="tns:logoutResponse"/>
  68. </wsdl:operation>
  69.  
  70. </wsdl:portType>
  71.  
  72.  
  73. <wsdl:binding name="XxxxxxSvc-Endpoint0Binding" type="tns:portType">
  74.  
  75. <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
  76.  
  77. <wsdl:operation name="version">
  78. <soap:operation style="document" soapAction="http://soap.jrimer-amp64/"/>
  79. <wsdl:input>
  80. <soap:body use="literal" parts="parameters"/>
  81. </wsdl:input>
  82. <wsdl:output>
  83. <soap:body use="literal" parts="parameters"/>
  84. </wsdl:output>
  85. </wsdl:operation>
  86.  
  87. <wsdl:operation name="login">
  88. <soap:operation style="document" soapAction="http://soap.jrimer-amp64/"/>
  89. <wsdl:input>
  90. <soap:body use="literal" parts="parameters"/>
  91. </wsdl:input>
  92. <wsdl:output>
  93. <soap:body use="literal" parts="parameters"/>
  94. </wsdl:output>
  95. </wsdl:operation>
  96.  
  97. <wsdl:operation name="logout">
  98. <soap:operation style="document" soapAction="http://soap.jrimer-amp64/"/>
  99. <wsdl:input>
  100. <soap:body use="literal" parts="parameters"/>
  101. </wsdl:input>
  102. <wsdl:output>
  103. <soap:body use="literal" parts="parameters"/>
  104. </wsdl:output>
  105. </wsdl:operation>
  106.  
  107. </wsdl:binding>
  108.  
  109.  
  110. <wsdl:message name="versionRequest">
  111. <wsdl:part name="parameters" element="ns0:versionRequest"/>
  112. </wsdl:message>
  113.  
  114.  
  115. <wsdl:message name="versionResponse">
  116. <wsdl:part name="parameters" element="ns0:versionResponse"/>
  117. </wsdl:message>
  118.  
  119. <wsdl:message name="loginRequest">
  120. <wsdl:part name="parameters" element="ns0:loginRequest"/>
  121. </wsdl:message>
  122.  
  123.  
  124. <wsdl:message name="loginResponse">
  125. <wsdl:part name="parameters" element="ns0:loginResponse"/>
  126. </wsdl:message>
  127.  
  128. <wsdl:message name="logoutRequest">
  129. <wsdl:part name="parameters" element="ns0:logoutRequest"/>
  130. </wsdl:message>
  131.  
  132. <wsdl:message name="logoutResponse">
  133. <wsdl:part name="parameters" element="ns0:logoutResponse"/>
  134. </wsdl:message>
  135.  
  136. class WebSvcSoapFunctions
  137. {
  138. private $username = ''; // username provided by the client during login() request
  139. private $password = ''; // password provided by the client during login() request
  140.  
  141. /**
  142. * Handle a login request
  143. *
  144. * @param string $user - Client's Username
  145. * @param string $pass - Client's Password
  146. */
  147. public function login($user,$pass)
  148. {
  149. $this->username = $user;
  150. $this->password = $pass;
  151.  
  152. // should check for validity here, but for testing, return true.
  153. return 'Successful Login. Welcome, '.$user;
  154. }
  155.  
  156. /**
  157. * Logs the client out.
  158. *
  159. */
  160. public function logout()
  161. {
  162. $this->username = '';
  163. $this->password = '';
  164. $_SESSION = array();
  165. session_destroy();
  166. return 'Logged Out Successfully.';
  167. }
  168. /**
  169. * checks if the client has logged in successfully
  170. *
  171. * @return bool - true=logged in, false = unauthenticated
  172. */
  173. private function isAuthenticated()
  174. {
  175. if (isset($this->username) && $this->username != '')
  176. {
  177. return true;
  178. }
  179. else
  180. {
  181. return false;
  182. }
  183. }
  184.  
  185. /**
  186. * Returns the version of the SOAP Server to the requesting client
  187. *
  188. */
  189. public function version()
  190. {
  191. if ($this->isAuthenticated())
  192. {
  193. return 'Affinegy Service v1.0.0';
  194. }
  195. else
  196. {
  197. return 'NOT AUTHORIZED.';
  198. }
  199. }
  200. }
  201.  
  202. ini_set("soap.wsdl_cache_enabled", "0");
  203. define('WSDL_URL','http://soap.jrimer-amp64/?wsdl');
  204. try
  205. {
  206. $client = new SoapClient(WSDL_URL, array('trace'=>true));
  207.  
  208. $request = 'version';
  209. $args = array();
  210. $SOAPResult = $client->$request($args); // call the SOAP Server's "version" function
  211. OutputLastRequestResponse($client, $request, $args, $SOAPResult);
  212.  
  213. $request = 'login';
  214. $args['username'] = 'testuser';
  215. $args['password'] = '1234';
  216. $SOAPResult = $client->$request($args); // call the SOAP Server's "login" function
  217. OutputLastRequestResponse($client, $request, $args, $SOAPResult);
  218.  
  219. $request = 'version';
  220. $args = array();
  221. $SOAPResult = $client->$request($args); // call the SOAP Server's "version" function
  222. OutputLastRequestResponse($client, $request, $args, $SOAPResult);
  223.  
  224. $request = 'logout';
  225. $args = array();
  226. $SOAPResult = $client->$request($args); // call the SOAP Server's "logout" function
  227. OutputLastRequestResponse($client, $request, $args, $SOAPResult);
  228.  
  229. $request = 'version';
  230. $SOAPResult = $client->$request($args); // call the SOAP Server's "version" function
  231. OutputLastRequestResponse($client, $request, $args, $SOAPResult);
  232.  
  233. }
  234. catch (Exception $e)
  235. {
  236. echo '<pre>FAILED: '.print_r($e,1).'</pre>'; // dump the client exception to screen
  237.  
  238. OutputLastRequestResponse($client);
  239. }
  240.  
  241. /**
  242. * Displays the request and response of the test service call
  243. *
  244. * @param SoapServer $client - Object of type SoapClient that does the request
  245. * @param string $requested - name of the SOAP function called
  246. * @param array $args - Arguments sent to the SOAP function
  247. * @param string $returned - PHP readable value returned by the client calling the provided SOAP function
  248. */
  249. function OutputLastRequestResponse($client, $requested = '', $args=array(), $returned='')
  250. {
  251. echo '<h1>XXXXXXXX SERVICE SOAP SERVER TEST</h1>';
  252. echo 'Request: <pre>'.$requested.'</pre>';
  253. echo 'Request Arguments: <pre>'.print_r($args,1).'</pre>';
  254. echo 'Returned: <pre>'.$returned.'</pre>';
  255. echo 'Raw Request: <pre>'.htmlspecialchars($client->__getLastRequestHeaders());
  256. echo htmlspecialchars($client->__getLastRequest()).'</pre>';
  257. echo 'Raw Response: <pre>'.htmlspecialchars($client->__getLastResponseHeaders())."n";
  258. echo htmlspecialchars($client->__getLastResponse()).'</pre>';
  259. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement