├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── lib ├── changelog ├── class.nusoap_base.php ├── class.soap_fault.php ├── class.soap_parser.php ├── class.soap_server.php ├── class.soap_transport_http.php ├── class.soap_val.php ├── class.soapclient.php ├── class.wsdl.php ├── class.wsdlcache.php ├── class.xmlschema.php └── nusoapmime.php └── samples ├── client1.php ├── client2.php ├── client3.php ├── getfile1client.php ├── getfile2client.php ├── index.html ├── mimeclient.php ├── sslclient.php ├── wsdlclient1.php ├── wsdlclient10.php ├── wsdlclient11.php ├── wsdlclient12.php ├── wsdlclient13.php ├── wsdlclient14.php ├── wsdlclient15.php ├── wsdlclient2.php ├── wsdlclient3.php ├── wsdlclient3b.php ├── wsdlclient3c.php ├── wsdlclient4.php ├── wsdlclient5.php ├── wsdlclient6.php ├── wsdlclient7.php ├── wsdlclient8.php └── wsdlclient9.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | (This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.) 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | {description} 474 | Copyright (C) {year} {fullname} 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | {signature of Ty Coon}, 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | nusoap 2 | ====== 3 | 4 | NuSphere's NuSOAP for Packagist/Composer 5 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codecasts/nusoap-php7", 3 | "description": "NuSOAP re-packaged for Packagist/Composer", 4 | "license": "LGPLv2", 5 | "authors": [ 6 | { 7 | "name": "Dietrich Ayala", 8 | "homepage": "http://sourceforge.net/u/dietricha/profile/" 9 | }, 10 | { 11 | "name": "Scott Nichol", 12 | "homepage": "http://sourceforge.net/u/snichol/profile/" 13 | } 14 | ], 15 | "autoload": { 16 | "classmap": ["lib/"] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/changelog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecasts/nusoap-php7/f6022920c02d1e353652583472ab6051ef72444c/lib/changelog -------------------------------------------------------------------------------- /lib/class.nusoap_base.php: -------------------------------------------------------------------------------- 1 | 81 | * @author Scott Nichol 82 | * @version $Id: class.nusoap_base.php,v 1.56 2010/04/26 20:15:08 snichol Exp $ 83 | * @access public 84 | */ 85 | class nusoap_base { 86 | /** 87 | * Identification for HTTP headers. 88 | * 89 | * @var string 90 | * @access private 91 | */ 92 | var $title = 'NuSOAP'; 93 | /** 94 | * Version for HTTP headers. 95 | * 96 | * @var string 97 | * @access private 98 | */ 99 | var $version = '0.9.5'; 100 | /** 101 | * CVS revision for HTTP headers. 102 | * 103 | * @var string 104 | * @access private 105 | */ 106 | var $revision = '$Revision: 1.56 $'; 107 | /** 108 | * Current error string (manipulated by getError/setError) 109 | * 110 | * @var string 111 | * @access private 112 | */ 113 | var $error_str = ''; 114 | /** 115 | * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) 116 | * 117 | * @var string 118 | * @access private 119 | */ 120 | var $debug_str = ''; 121 | /** 122 | * toggles automatic encoding of special characters as entities 123 | * (should always be true, I think) 124 | * 125 | * @var boolean 126 | * @access private 127 | */ 128 | var $charencoding = true; 129 | /** 130 | * the debug level for this instance 131 | * 132 | * @var integer 133 | * @access private 134 | */ 135 | var $debugLevel; 136 | 137 | /** 138 | * set schema version 139 | * 140 | * @var string 141 | * @access public 142 | */ 143 | var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; 144 | 145 | /** 146 | * charset encoding for outgoing messages 147 | * 148 | * @var string 149 | * @access public 150 | */ 151 | var $soap_defencoding = 'ISO-8859-1'; 152 | //var $soap_defencoding = 'UTF-8'; 153 | 154 | /** 155 | * namespaces in an array of prefix => uri 156 | * 157 | * this is "seeded" by a set of constants, but it may be altered by code 158 | * 159 | * @var array 160 | * @access public 161 | */ 162 | var $namespaces = array( 163 | 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', 164 | 'xsd' => 'http://www.w3.org/2001/XMLSchema', 165 | 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 166 | 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' 167 | ); 168 | 169 | /** 170 | * namespaces used in the current context, e.g. during serialization 171 | * 172 | * @var array 173 | * @access private 174 | */ 175 | var $usedNamespaces = array(); 176 | 177 | /** 178 | * XML Schema types in an array of uri => (array of xml type => php type) 179 | * is this legacy yet? 180 | * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. 181 | * @var array 182 | * @access public 183 | */ 184 | var $typemap = array( 185 | 'http://www.w3.org/2001/XMLSchema' => array( 186 | 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', 187 | 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', 188 | 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', 189 | // abstract "any" types 190 | 'anyType'=>'string','anySimpleType'=>'string', 191 | // derived datatypes 192 | 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', 193 | 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', 194 | 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', 195 | 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), 196 | 'http://www.w3.org/2000/10/XMLSchema' => array( 197 | 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', 198 | 'float'=>'double','dateTime'=>'string', 199 | 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), 200 | 'http://www.w3.org/1999/XMLSchema' => array( 201 | 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', 202 | 'float'=>'double','dateTime'=>'string', 203 | 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), 204 | 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), 205 | 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), 206 | 'http://xml.apache.org/xml-soap' => array('Map') 207 | ); 208 | 209 | /** 210 | * XML entities to convert 211 | * 212 | * @var array 213 | * @access public 214 | * @deprecated 215 | * @see expandEntities 216 | */ 217 | var $xmlEntities = array('quot' => '"','amp' => '&', 218 | 'lt' => '<','gt' => '>','apos' => "'"); 219 | 220 | /** 221 | * constructor 222 | * 223 | * @access public 224 | */ 225 | function __construct() { 226 | $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; 227 | } 228 | 229 | /** 230 | * gets the global debug level, which applies to future instances 231 | * 232 | * @return integer Debug level 0-9, where 0 turns off 233 | * @access public 234 | */ 235 | function getGlobalDebugLevel() { 236 | return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; 237 | } 238 | 239 | /** 240 | * sets the global debug level, which applies to future instances 241 | * 242 | * @param int $level Debug level 0-9, where 0 turns off 243 | * @access public 244 | */ 245 | function setGlobalDebugLevel($level) { 246 | $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; 247 | } 248 | 249 | /** 250 | * gets the debug level for this instance 251 | * 252 | * @return int Debug level 0-9, where 0 turns off 253 | * @access public 254 | */ 255 | function getDebugLevel() { 256 | return $this->debugLevel; 257 | } 258 | 259 | /** 260 | * sets the debug level for this instance 261 | * 262 | * @param int $level Debug level 0-9, where 0 turns off 263 | * @access public 264 | */ 265 | function setDebugLevel($level) { 266 | $this->debugLevel = $level; 267 | } 268 | 269 | /** 270 | * adds debug data to the instance debug string with formatting 271 | * 272 | * @param string $string debug data 273 | * @access private 274 | */ 275 | function debug($string){ 276 | if ($this->debugLevel > 0) { 277 | $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); 278 | } 279 | } 280 | 281 | /** 282 | * adds debug data to the instance debug string without formatting 283 | * 284 | * @param string $string debug data 285 | * @access public 286 | */ 287 | function appendDebug($string){ 288 | if ($this->debugLevel > 0) { 289 | // it would be nice to use a memory stream here to use 290 | // memory more efficiently 291 | $this->debug_str .= $string; 292 | } 293 | } 294 | 295 | /** 296 | * clears the current debug data for this instance 297 | * 298 | * @access public 299 | */ 300 | function clearDebug() { 301 | // it would be nice to use a memory stream here to use 302 | // memory more efficiently 303 | $this->debug_str = ''; 304 | } 305 | 306 | /** 307 | * gets the current debug data for this instance 308 | * 309 | * @return debug data 310 | * @access public 311 | */ 312 | function &getDebug() { 313 | // it would be nice to use a memory stream here to use 314 | // memory more efficiently 315 | return $this->debug_str; 316 | } 317 | 318 | /** 319 | * gets the current debug data for this instance as an XML comment 320 | * this may change the contents of the debug data 321 | * 322 | * @return debug data as an XML comment 323 | * @access public 324 | */ 325 | function &getDebugAsXMLComment() { 326 | // it would be nice to use a memory stream here to use 327 | // memory more efficiently 328 | while (strpos($this->debug_str, '--')) { 329 | $this->debug_str = str_replace('--', '- -', $this->debug_str); 330 | } 331 | $ret = ""; 332 | return $ret; 333 | } 334 | 335 | /** 336 | * expands entities, e.g. changes '<' to '<'. 337 | * 338 | * @param string $val The string in which to expand entities. 339 | * @access private 340 | */ 341 | function expandEntities($val) { 342 | if ($this->charencoding) { 343 | $val = str_replace('&', '&', $val); 344 | $val = str_replace("'", ''', $val); 345 | $val = str_replace('"', '"', $val); 346 | $val = str_replace('<', '<', $val); 347 | $val = str_replace('>', '>', $val); 348 | } 349 | return $val; 350 | } 351 | 352 | /** 353 | * returns error string if present 354 | * 355 | * @return mixed error string or false 356 | * @access public 357 | */ 358 | function getError(){ 359 | if($this->error_str != ''){ 360 | return $this->error_str; 361 | } 362 | return false; 363 | } 364 | 365 | /** 366 | * sets error string 367 | * 368 | * @return boolean $string error string 369 | * @access private 370 | */ 371 | function setError($str){ 372 | $this->error_str = $str; 373 | } 374 | 375 | /** 376 | * detect if array is a simple array or a struct (associative array) 377 | * 378 | * @param mixed $val The PHP array 379 | * @return string (arraySimple|arrayStruct) 380 | * @access private 381 | */ 382 | function isArraySimpleOrStruct($val) { 383 | $keyList = array_keys($val); 384 | foreach ($keyList as $keyListValue) { 385 | if (!is_int($keyListValue)) { 386 | return 'arrayStruct'; 387 | } 388 | } 389 | return 'arraySimple'; 390 | } 391 | 392 | /** 393 | * serializes PHP values in accordance w/ section 5. Type information is 394 | * not serialized if $use == 'literal'. 395 | * 396 | * @param mixed $val The value to serialize 397 | * @param string $name The name (local part) of the XML element 398 | * @param string $type The XML schema type (local part) for the element 399 | * @param string $name_ns The namespace for the name of the XML element 400 | * @param string $type_ns The namespace for the type of the element 401 | * @param array $attributes The attributes to serialize as name=>value pairs 402 | * @param string $use The WSDL "use" (encoded|literal) 403 | * @param boolean $soapval Whether this is called from soapval. 404 | * @return string The serialized element, possibly with child elements 405 | * @access public 406 | */ 407 | function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { 408 | $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); 409 | $this->appendDebug('value=' . $this->varDump($val)); 410 | $this->appendDebug('attributes=' . $this->varDump($attributes)); 411 | 412 | if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { 413 | $this->debug("serialize_val: serialize soapval"); 414 | $xml = $val->serialize($use); 415 | $this->appendDebug($val->getDebug()); 416 | $val->clearDebug(); 417 | $this->debug("serialize_val of soapval returning $xml"); 418 | return $xml; 419 | } 420 | // force valid name if necessary 421 | if (is_numeric($name)) { 422 | $name = '__numeric_' . $name; 423 | } elseif (! $name) { 424 | $name = 'noname'; 425 | } 426 | // if name has ns, add ns prefix to name 427 | $xmlns = ''; 428 | if($name_ns){ 429 | $prefix = 'nu'.rand(1000,9999); 430 | $name = $prefix.':'.$name; 431 | $xmlns .= " xmlns:$prefix=\"$name_ns\""; 432 | } 433 | // if type is prefixed, create type prefix 434 | if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ 435 | // need to fix this. shouldn't default to xsd if no ns specified 436 | // w/o checking against typemap 437 | $type_prefix = 'xsd'; 438 | } elseif($type_ns){ 439 | $type_prefix = 'ns'.rand(1000,9999); 440 | $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; 441 | } 442 | // serialize attributes if present 443 | $atts = ''; 444 | if($attributes){ 445 | foreach($attributes as $k => $v){ 446 | $atts .= " $k=\"".$this->expandEntities($v).'"'; 447 | } 448 | } 449 | // serialize null value 450 | if (is_null($val)) { 451 | $this->debug("serialize_val: serialize null"); 452 | if ($use == 'literal') { 453 | // TODO: depends on minOccurs 454 | $xml = "<$name$xmlns$atts/>"; 455 | $this->debug("serialize_val returning $xml"); 456 | return $xml; 457 | } else { 458 | if (isset($type) && isset($type_prefix)) { 459 | $type_str = " xsi:type=\"$type_prefix:$type\""; 460 | } else { 461 | $type_str = ''; 462 | } 463 | $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; 464 | $this->debug("serialize_val returning $xml"); 465 | return $xml; 466 | } 467 | } 468 | // serialize if an xsd built-in primitive type 469 | if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ 470 | $this->debug("serialize_val: serialize xsd built-in primitive type"); 471 | if (is_bool($val)) { 472 | if ($type == 'boolean') { 473 | $val = $val ? 'true' : 'false'; 474 | } elseif (! $val) { 475 | $val = 0; 476 | } 477 | } else if (is_string($val)) { 478 | $val = $this->expandEntities($val); 479 | } 480 | if ($use == 'literal') { 481 | $xml = "<$name$xmlns$atts>$val"; 482 | $this->debug("serialize_val returning $xml"); 483 | return $xml; 484 | } else { 485 | $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val"; 486 | $this->debug("serialize_val returning $xml"); 487 | return $xml; 488 | } 489 | } 490 | // detect type and serialize 491 | $xml = ''; 492 | switch(true) { 493 | case (is_bool($val) || $type == 'boolean'): 494 | $this->debug("serialize_val: serialize boolean"); 495 | if ($type == 'boolean') { 496 | $val = $val ? 'true' : 'false'; 497 | } elseif (! $val) { 498 | $val = 0; 499 | } 500 | if ($use == 'literal') { 501 | $xml .= "<$name$xmlns$atts>$val"; 502 | } else { 503 | $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val"; 504 | } 505 | break; 506 | case (is_int($val) || is_long($val) || $type == 'int'): 507 | $this->debug("serialize_val: serialize int"); 508 | if ($use == 'literal') { 509 | $xml .= "<$name$xmlns$atts>$val"; 510 | } else { 511 | $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val"; 512 | } 513 | break; 514 | case (is_float($val)|| is_double($val) || $type == 'float'): 515 | $this->debug("serialize_val: serialize float"); 516 | if ($use == 'literal') { 517 | $xml .= "<$name$xmlns$atts>$val"; 518 | } else { 519 | $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val"; 520 | } 521 | break; 522 | case (is_string($val) || $type == 'string'): 523 | $this->debug("serialize_val: serialize string"); 524 | $val = $this->expandEntities($val); 525 | if ($use == 'literal') { 526 | $xml .= "<$name$xmlns$atts>$val"; 527 | } else { 528 | $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val"; 529 | } 530 | break; 531 | case is_object($val): 532 | $this->debug("serialize_val: serialize object"); 533 | if (get_class($val) == 'soapval') { 534 | $this->debug("serialize_val: serialize soapval object"); 535 | $pXml = $val->serialize($use); 536 | $this->appendDebug($val->getDebug()); 537 | $val->clearDebug(); 538 | } else { 539 | if (! $name) { 540 | $name = get_class($val); 541 | $this->debug("In serialize_val, used class name $name as element name"); 542 | } else { 543 | $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); 544 | } 545 | foreach(get_object_vars($val) as $k => $v){ 546 | $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); 547 | } 548 | } 549 | if(isset($type) && isset($type_prefix)){ 550 | $type_str = " xsi:type=\"$type_prefix:$type\""; 551 | } else { 552 | $type_str = ''; 553 | } 554 | if ($use == 'literal') { 555 | $xml .= "<$name$xmlns$atts>$pXml"; 556 | } else { 557 | $xml .= "<$name$xmlns$type_str$atts>$pXml"; 558 | } 559 | break; 560 | break; 561 | case (is_array($val) || $type): 562 | // detect if struct or array 563 | $valueType = $this->isArraySimpleOrStruct($val); 564 | if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ 565 | $this->debug("serialize_val: serialize array"); 566 | $i = 0; 567 | if(is_array($val) && count($val)> 0){ 568 | foreach($val as $v){ 569 | if(is_object($v) && get_class($v) == 'soapval'){ 570 | $tt_ns = $v->type_ns; 571 | $tt = $v->type; 572 | } elseif (is_array($v)) { 573 | $tt = $this->isArraySimpleOrStruct($v); 574 | } else { 575 | $tt = gettype($v); 576 | } 577 | $array_types[$tt] = 1; 578 | // TODO: for literal, the name should be $name 579 | $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); 580 | ++$i; 581 | } 582 | if(count($array_types) > 1){ 583 | $array_typename = 'xsd:anyType'; 584 | } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { 585 | if ($tt == 'integer') { 586 | $tt = 'int'; 587 | } 588 | $array_typename = 'xsd:'.$tt; 589 | } elseif(isset($tt) && $tt == 'arraySimple'){ 590 | $array_typename = 'SOAP-ENC:Array'; 591 | } elseif(isset($tt) && $tt == 'arrayStruct'){ 592 | $array_typename = 'unnamed_struct_use_soapval'; 593 | } else { 594 | // if type is prefixed, create type prefix 595 | if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ 596 | $array_typename = 'xsd:' . $tt; 597 | } elseif ($tt_ns) { 598 | $tt_prefix = 'ns' . rand(1000, 9999); 599 | $array_typename = "$tt_prefix:$tt"; 600 | $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; 601 | } else { 602 | $array_typename = $tt; 603 | } 604 | } 605 | $array_type = $i; 606 | if ($use == 'literal') { 607 | $type_str = ''; 608 | } else if (isset($type) && isset($type_prefix)) { 609 | $type_str = " xsi:type=\"$type_prefix:$type\""; 610 | } else { 611 | $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; 612 | } 613 | // empty array 614 | } else { 615 | if ($use == 'literal') { 616 | $type_str = ''; 617 | } else if (isset($type) && isset($type_prefix)) { 618 | $type_str = " xsi:type=\"$type_prefix:$type\""; 619 | } else { 620 | $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; 621 | } 622 | } 623 | // TODO: for array in literal, there is no wrapper here 624 | $xml = "<$name$xmlns$type_str$atts>".$xml.""; 625 | } else { 626 | // got a struct 627 | $this->debug("serialize_val: serialize struct"); 628 | if(isset($type) && isset($type_prefix)){ 629 | $type_str = " xsi:type=\"$type_prefix:$type\""; 630 | } else { 631 | $type_str = ''; 632 | } 633 | if ($use == 'literal') { 634 | $xml .= "<$name$xmlns$atts>"; 635 | } else { 636 | $xml .= "<$name$xmlns$type_str$atts>"; 637 | } 638 | foreach($val as $k => $v){ 639 | // Apache Map 640 | if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { 641 | $xml .= ''; 642 | $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); 643 | $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); 644 | $xml .= ''; 645 | } else { 646 | $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); 647 | } 648 | } 649 | $xml .= ""; 650 | } 651 | break; 652 | default: 653 | $this->debug("serialize_val: serialize unknown"); 654 | $xml .= 'not detected, got '.gettype($val).' for '.$val; 655 | break; 656 | } 657 | $this->debug("serialize_val returning $xml"); 658 | return $xml; 659 | } 660 | 661 | /** 662 | * serializes a message 663 | * 664 | * @param string $body the XML of the SOAP body 665 | * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array 666 | * @param array $namespaces optional the namespaces used in generating the body and headers 667 | * @param string $style optional (rpc|document) 668 | * @param string $use optional (encoded|literal) 669 | * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) 670 | * @return string the message 671 | * @access public 672 | */ 673 | function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ 674 | // TODO: add an option to automatically run utf8_encode on $body and $headers 675 | // if $this->soap_defencoding is UTF-8. Not doing this automatically allows 676 | // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 677 | 678 | $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); 679 | $this->debug("headers:"); 680 | $this->appendDebug($this->varDump($headers)); 681 | $this->debug("namespaces:"); 682 | $this->appendDebug($this->varDump($namespaces)); 683 | 684 | // serialize namespaces 685 | $ns_string = ''; 686 | foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ 687 | $ns_string .= " xmlns:$k=\"$v\""; 688 | } 689 | if($encodingStyle) { 690 | $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; 691 | } 692 | 693 | // serialize headers 694 | if($headers){ 695 | if (is_array($headers)) { 696 | $xml = ''; 697 | foreach ($headers as $k => $v) { 698 | if (is_object($v) && get_class($v) == 'soapval') { 699 | $xml .= $this->serialize_val($v, false, false, false, false, false, $use); 700 | } else { 701 | $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); 702 | } 703 | } 704 | $headers = $xml; 705 | $this->debug("In serializeEnvelope, serialized array of headers to $headers"); 706 | } 707 | $headers = "".$headers.""; 708 | } 709 | // serialize envelope 710 | return 711 | 'soap_defencoding .'"?'.">". 712 | '". 713 | $headers. 714 | "". 715 | $body. 716 | "". 717 | ""; 718 | } 719 | 720 | /** 721 | * formats a string to be inserted into an HTML stream 722 | * 723 | * @param string $str The string to format 724 | * @return string The formatted string 725 | * @access public 726 | * @deprecated 727 | */ 728 | function formatDump($str){ 729 | $str = htmlspecialchars($str); 730 | return nl2br($str); 731 | } 732 | 733 | /** 734 | * contracts (changes namespace to prefix) a qualified name 735 | * 736 | * @param string $qname qname 737 | * @return string contracted qname 738 | * @access private 739 | */ 740 | function contractQname($qname){ 741 | // get element namespace 742 | //$this->xdebug("Contract $qname"); 743 | if (strrpos($qname, ':')) { 744 | // get unqualified name 745 | $name = substr($qname, strrpos($qname, ':') + 1); 746 | // get ns 747 | $ns = substr($qname, 0, strrpos($qname, ':')); 748 | $p = $this->getPrefixFromNamespace($ns); 749 | if ($p) { 750 | return $p . ':' . $name; 751 | } 752 | return $qname; 753 | } else { 754 | return $qname; 755 | } 756 | } 757 | 758 | /** 759 | * expands (changes prefix to namespace) a qualified name 760 | * 761 | * @param string $qname qname 762 | * @return string expanded qname 763 | * @access private 764 | */ 765 | function expandQname($qname){ 766 | // get element prefix 767 | if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ 768 | // get unqualified name 769 | $name = substr(strstr($qname,':'),1); 770 | // get ns prefix 771 | $prefix = substr($qname,0,strpos($qname,':')); 772 | if(isset($this->namespaces[$prefix])){ 773 | return $this->namespaces[$prefix].':'.$name; 774 | } else { 775 | return $qname; 776 | } 777 | } else { 778 | return $qname; 779 | } 780 | } 781 | 782 | /** 783 | * returns the local part of a prefixed string 784 | * returns the original string, if not prefixed 785 | * 786 | * @param string $str The prefixed string 787 | * @return string The local part 788 | * @access public 789 | */ 790 | function getLocalPart($str){ 791 | if($sstr = strrchr($str,':')){ 792 | // get unqualified name 793 | return substr( $sstr, 1 ); 794 | } else { 795 | return $str; 796 | } 797 | } 798 | 799 | /** 800 | * returns the prefix part of a prefixed string 801 | * returns false, if not prefixed 802 | * 803 | * @param string $str The prefixed string 804 | * @return mixed The prefix or false if there is no prefix 805 | * @access public 806 | */ 807 | function getPrefix($str){ 808 | if($pos = strrpos($str,':')){ 809 | // get prefix 810 | return substr($str,0,$pos); 811 | } 812 | return false; 813 | } 814 | 815 | /** 816 | * pass it a prefix, it returns a namespace 817 | * 818 | * @param string $prefix The prefix 819 | * @return mixed The namespace, false if no namespace has the specified prefix 820 | * @access public 821 | */ 822 | function getNamespaceFromPrefix($prefix){ 823 | if (isset($this->namespaces[$prefix])) { 824 | return $this->namespaces[$prefix]; 825 | } 826 | //$this->setError("No namespace registered for prefix '$prefix'"); 827 | return false; 828 | } 829 | 830 | /** 831 | * returns the prefix for a given namespace (or prefix) 832 | * or false if no prefixes registered for the given namespace 833 | * 834 | * @param string $ns The namespace 835 | * @return mixed The prefix, false if the namespace has no prefixes 836 | * @access public 837 | */ 838 | function getPrefixFromNamespace($ns) { 839 | foreach ($this->namespaces as $p => $n) { 840 | if ($ns == $n || $ns == $p) { 841 | $this->usedNamespaces[$p] = $n; 842 | return $p; 843 | } 844 | } 845 | return false; 846 | } 847 | 848 | /** 849 | * returns the time in ODBC canonical form with microseconds 850 | * 851 | * @return string The time in ODBC canonical form with microseconds 852 | * @access public 853 | */ 854 | function getmicrotime() { 855 | if (function_exists('gettimeofday')) { 856 | $tod = gettimeofday(); 857 | $sec = $tod['sec']; 858 | $usec = $tod['usec']; 859 | } else { 860 | $sec = time(); 861 | $usec = 0; 862 | } 863 | return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); 864 | } 865 | 866 | /** 867 | * Returns a string with the output of var_dump 868 | * 869 | * @param mixed $data The variable to var_dump 870 | * @return string The output of var_dump 871 | * @access public 872 | */ 873 | function varDump($data) { 874 | ob_start(); 875 | var_dump($data); 876 | $ret_val = ob_get_contents(); 877 | ob_end_clean(); 878 | return $ret_val; 879 | } 880 | 881 | /** 882 | * represents the object as a string 883 | * 884 | * @return string 885 | * @access public 886 | */ 887 | function __toString() { 888 | return $this->varDump($this); 889 | } 890 | } 891 | 892 | // XML Schema Datatype Helper Functions 893 | 894 | //xsd:dateTime helpers 895 | 896 | /** 897 | * convert unix timestamp to ISO 8601 compliant date string 898 | * 899 | * @param int $timestamp Unix time stamp 900 | * @param boolean $utc Whether the time stamp is UTC or local 901 | * @return mixed ISO 8601 date string or false 902 | * @access public 903 | */ 904 | function timestamp_to_iso8601($timestamp,$utc=true){ 905 | $datestr = date('Y-m-d\TH:i:sO',$timestamp); 906 | $pos = strrpos($datestr, "+"); 907 | if ($pos === FALSE) { 908 | $pos = strrpos($datestr, "-"); 909 | } 910 | if ($pos !== FALSE) { 911 | if (strlen($datestr) == $pos + 5) { 912 | $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); 913 | } 914 | } 915 | if($utc){ 916 | $pattern = '/'. 917 | '([0-9]{4})-'. // centuries & years CCYY- 918 | '([0-9]{2})-'. // months MM- 919 | '([0-9]{2})'. // days DD 920 | 'T'. // separator T 921 | '([0-9]{2}):'. // hours hh: 922 | '([0-9]{2}):'. // minutes mm: 923 | '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... 924 | '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's 925 | '/'; 926 | 927 | if(preg_match($pattern,$datestr,$regs)){ 928 | return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); 929 | } 930 | return false; 931 | } else { 932 | return $datestr; 933 | } 934 | } 935 | 936 | /** 937 | * convert ISO 8601 compliant date string to unix timestamp 938 | * 939 | * @param string $datestr ISO 8601 compliant date string 940 | * @return mixed Unix timestamp (int) or false 941 | * @access public 942 | */ 943 | function iso8601_to_timestamp($datestr){ 944 | $pattern = '/'. 945 | '([0-9]{4})-'. // centuries & years CCYY- 946 | '([0-9]{2})-'. // months MM- 947 | '([0-9]{2})'. // days DD 948 | 'T'. // separator T 949 | '([0-9]{2}):'. // hours hh: 950 | '([0-9]{2}):'. // minutes mm: 951 | '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... 952 | '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's 953 | '/'; 954 | if(preg_match($pattern,$datestr,$regs)){ 955 | // not utc 956 | if($regs[8] != 'Z'){ 957 | $op = substr($regs[8],0,1); 958 | $h = substr($regs[8],1,2); 959 | $m = substr($regs[8],strlen($regs[8])-2,2); 960 | if($op == '-'){ 961 | $regs[4] = $regs[4] + $h; 962 | $regs[5] = $regs[5] + $m; 963 | } elseif($op == '+'){ 964 | $regs[4] = $regs[4] - $h; 965 | $regs[5] = $regs[5] - $m; 966 | } 967 | } 968 | return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); 969 | // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); 970 | } else { 971 | return false; 972 | } 973 | } 974 | 975 | /** 976 | * sleeps some number of microseconds 977 | * 978 | * @param string $usec the number of microseconds to sleep 979 | * @access public 980 | * @deprecated 981 | */ 982 | function usleepWindows($usec) 983 | { 984 | $start = gettimeofday(); 985 | 986 | do 987 | { 988 | $stop = gettimeofday(); 989 | $timePassed = 1000000 * ($stop['sec'] - $start['sec']) 990 | + $stop['usec'] - $start['usec']; 991 | } 992 | while ($timePassed < $usec); 993 | } 994 | 995 | 996 | ?> -------------------------------------------------------------------------------- /lib/class.soap_fault.php: -------------------------------------------------------------------------------- 1 | 11 | * @version $Id: class.soap_fault.php,v 1.14 2007/04/11 15:49:47 snichol Exp $ 12 | * @access public 13 | */ 14 | class nusoap_fault extends nusoap_base { 15 | /** 16 | * The fault code (client|server) 17 | * @var string 18 | * @access private 19 | */ 20 | var $faultcode; 21 | /** 22 | * The fault actor 23 | * @var string 24 | * @access private 25 | */ 26 | var $faultactor; 27 | /** 28 | * The fault string, a description of the fault 29 | * @var string 30 | * @access private 31 | */ 32 | var $faultstring; 33 | /** 34 | * The fault detail, typically a string or array of string 35 | * @var mixed 36 | * @access private 37 | */ 38 | var $faultdetail; 39 | 40 | /** 41 | * constructor 42 | * 43 | * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) 44 | * @param string $faultactor only used when msg routed between multiple actors 45 | * @param string $faultstring human readable error message 46 | * @param mixed $faultdetail detail, typically a string or array of string 47 | */ 48 | function __construct($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ 49 | parent::__construct(); 50 | $this->faultcode = $faultcode; 51 | $this->faultactor = $faultactor; 52 | $this->faultstring = $faultstring; 53 | $this->faultdetail = $faultdetail; 54 | } 55 | 56 | /** 57 | * serialize a fault 58 | * 59 | * @return string The serialization of the fault instance. 60 | * @access public 61 | */ 62 | function serialize(){ 63 | $ns_string = ''; 64 | foreach($this->namespaces as $k => $v){ 65 | $ns_string .= "\n xmlns:$k=\"$v\""; 66 | } 67 | $return_msg = 68 | 'soap_defencoding.'"?>'. 69 | '\n". 70 | ''. 71 | ''. 72 | $this->serialize_val($this->faultcode, 'faultcode'). 73 | $this->serialize_val($this->faultactor, 'faultactor'). 74 | $this->serialize_val($this->faultstring, 'faultstring'). 75 | $this->serialize_val($this->faultdetail, 'detail'). 76 | ''. 77 | ''. 78 | ''; 79 | return $return_msg; 80 | } 81 | } 82 | 83 | /** 84 | * Backward compatibility 85 | */ 86 | class soap_fault extends nusoap_fault { 87 | } 88 | 89 | 90 | ?> -------------------------------------------------------------------------------- /lib/class.soap_parser.php: -------------------------------------------------------------------------------- 1 | 11 | * @author Scott Nichol 12 | * @version $Id: class.soap_parser.php,v 1.42 2010/04/26 20:15:08 snichol Exp $ 13 | * @access public 14 | */ 15 | class nusoap_parser extends nusoap_base { 16 | 17 | var $xml = ''; 18 | var $xml_encoding = ''; 19 | var $method = ''; 20 | var $root_struct = ''; 21 | var $root_struct_name = ''; 22 | var $root_struct_namespace = ''; 23 | var $root_header = ''; 24 | var $document = ''; // incoming SOAP body (text) 25 | // determines where in the message we are (envelope,header,body,method) 26 | var $status = ''; 27 | var $position = 0; 28 | var $depth = 0; 29 | var $default_namespace = ''; 30 | var $namespaces = array(); 31 | var $message = array(); 32 | var $parent = ''; 33 | var $fault = false; 34 | var $fault_code = ''; 35 | var $fault_str = ''; 36 | var $fault_detail = ''; 37 | var $depth_array = array(); 38 | var $debug_flag = true; 39 | var $soapresponse = NULL; // parsed SOAP Body 40 | var $soapheader = NULL; // parsed SOAP Header 41 | var $responseHeaders = ''; // incoming SOAP headers (text) 42 | var $body_position = 0; 43 | // for multiref parsing: 44 | // array of id => pos 45 | var $ids = array(); 46 | // array of id => hrefs => pos 47 | var $multirefs = array(); 48 | // toggle for auto-decoding element content 49 | var $decode_utf8 = true; 50 | 51 | /** 52 | * constructor that actually does the parsing 53 | * 54 | * @param string $xml SOAP message 55 | * @param string $encoding character encoding scheme of message 56 | * @param string $method method for which XML is parsed (unused?) 57 | * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 58 | * @access public 59 | */ 60 | function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ 61 | parent::__construct(); 62 | $this->xml = $xml; 63 | $this->xml_encoding = $encoding; 64 | $this->method = $method; 65 | $this->decode_utf8 = $decode_utf8; 66 | 67 | // Check whether content has been read. 68 | if(!empty($xml)){ 69 | // Check XML encoding 70 | $pos_xml = strpos($xml, '', $pos_xml + 2) - $pos_xml + 1); 73 | if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { 74 | $xml_encoding = $res[1]; 75 | if (strtoupper($xml_encoding) != $encoding) { 76 | $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; 77 | $this->debug($err); 78 | if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { 79 | $this->setError($err); 80 | return; 81 | } 82 | // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed 83 | } else { 84 | $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); 85 | } 86 | } else { 87 | $this->debug('No encoding specified in XML declaration'); 88 | } 89 | } else { 90 | $this->debug('No XML declaration'); 91 | } 92 | $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); 93 | // Create an XML parser - why not xml_parser_create_ns? 94 | $this->parser = xml_parser_create($this->xml_encoding); 95 | // Set the options for parsing the XML data. 96 | //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); 97 | xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); 98 | xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); 99 | // Set the object for the parser. 100 | xml_set_object($this->parser, $this); 101 | // Set the element handlers for the parser. 102 | xml_set_element_handler($this->parser, 'start_element','end_element'); 103 | xml_set_character_data_handler($this->parser,'character_data'); 104 | 105 | // Parse the XML file. 106 | if(!xml_parse($this->parser,$xml,true)){ 107 | // Display an error message. 108 | $err = sprintf('XML error parsing SOAP payload on line %d: %s', 109 | xml_get_current_line_number($this->parser), 110 | xml_error_string(xml_get_error_code($this->parser))); 111 | $this->debug($err); 112 | $this->debug("XML payload:\n" . $xml); 113 | $this->setError($err); 114 | } else { 115 | $this->debug('in nusoap_parser ctor, message:'); 116 | $this->appendDebug($this->varDump($this->message)); 117 | $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); 118 | // get final value 119 | $this->soapresponse = $this->message[$this->root_struct]['result']; 120 | // get header value 121 | if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ 122 | $this->soapheader = $this->message[$this->root_header]['result']; 123 | } 124 | // resolve hrefs/ids 125 | if(sizeof($this->multirefs) > 0){ 126 | foreach($this->multirefs as $id => $hrefs){ 127 | $this->debug('resolving multirefs for id: '.$id); 128 | $idVal = $this->buildVal($this->ids[$id]); 129 | if (is_array($idVal) && isset($idVal['!id'])) { 130 | unset($idVal['!id']); 131 | } 132 | foreach($hrefs as $refPos => $ref){ 133 | $this->debug('resolving href at pos '.$refPos); 134 | $this->multirefs[$id][$refPos] = $idVal; 135 | } 136 | } 137 | } 138 | } 139 | xml_parser_free($this->parser); 140 | unset($this->parser); 141 | } else { 142 | $this->debug('xml was empty, didn\'t parse!'); 143 | $this->setError('xml was empty, didn\'t parse!'); 144 | } 145 | } 146 | 147 | /** 148 | * start-element handler 149 | * 150 | * @param resource $parser XML parser object 151 | * @param string $name element name 152 | * @param array $attrs associative array of attributes 153 | * @access private 154 | */ 155 | function start_element($parser, $name, $attrs) { 156 | // position in a total number of elements, starting from 0 157 | // update class level pos 158 | $pos = $this->position++; 159 | // and set mine 160 | $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); 161 | // depth = how many levels removed from root? 162 | // set mine as current global depth and increment global depth value 163 | $this->message[$pos]['depth'] = $this->depth++; 164 | 165 | // else add self as child to whoever the current parent is 166 | if($pos != 0){ 167 | $this->message[$this->parent]['children'] .= '|'.$pos; 168 | } 169 | // set my parent 170 | $this->message[$pos]['parent'] = $this->parent; 171 | // set self as current parent 172 | $this->parent = $pos; 173 | // set self as current value for this depth 174 | $this->depth_array[$this->depth] = $pos; 175 | // get element prefix 176 | if(strpos($name,':')){ 177 | // get ns prefix 178 | $prefix = substr($name,0,strpos($name,':')); 179 | // get unqualified name 180 | $name = substr(strstr($name,':'),1); 181 | } 182 | // set status 183 | if ($name == 'Envelope' && $this->status == '') { 184 | $this->status = 'envelope'; 185 | } elseif ($name == 'Header' && $this->status == 'envelope') { 186 | $this->root_header = $pos; 187 | $this->status = 'header'; 188 | } elseif ($name == 'Body' && $this->status == 'envelope'){ 189 | $this->status = 'body'; 190 | $this->body_position = $pos; 191 | // set method 192 | } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { 193 | $this->status = 'method'; 194 | $this->root_struct_name = $name; 195 | $this->root_struct = $pos; 196 | $this->message[$pos]['type'] = 'struct'; 197 | $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); 198 | } 199 | // set my status 200 | $this->message[$pos]['status'] = $this->status; 201 | // set name 202 | $this->message[$pos]['name'] = htmlspecialchars($name); 203 | // set attrs 204 | $this->message[$pos]['attrs'] = $attrs; 205 | 206 | // loop through atts, logging ns and type declarations 207 | $attstr = ''; 208 | foreach($attrs as $key => $value){ 209 | $key_prefix = $this->getPrefix($key); 210 | $key_localpart = $this->getLocalPart($key); 211 | // if ns declarations, add to class level array of valid namespaces 212 | if($key_prefix == 'xmlns'){ 213 | if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ 214 | $this->XMLSchemaVersion = $value; 215 | $this->namespaces['xsd'] = $this->XMLSchemaVersion; 216 | $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; 217 | } 218 | $this->namespaces[$key_localpart] = $value; 219 | // set method namespace 220 | if($name == $this->root_struct_name){ 221 | $this->methodNamespace = $value; 222 | } 223 | // if it's a type declaration, set type 224 | } elseif($key_localpart == 'type'){ 225 | if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { 226 | // do nothing: already processed arrayType 227 | } else { 228 | $value_prefix = $this->getPrefix($value); 229 | $value_localpart = $this->getLocalPart($value); 230 | $this->message[$pos]['type'] = $value_localpart; 231 | $this->message[$pos]['typePrefix'] = $value_prefix; 232 | if(isset($this->namespaces[$value_prefix])){ 233 | $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; 234 | } else if(isset($attrs['xmlns:'.$value_prefix])) { 235 | $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; 236 | } 237 | // should do something here with the namespace of specified type? 238 | } 239 | } elseif($key_localpart == 'arrayType'){ 240 | $this->message[$pos]['type'] = 'array'; 241 | /* do arrayType ereg here 242 | [1] arrayTypeValue ::= atype asize 243 | [2] atype ::= QName rank* 244 | [3] rank ::= '[' (',')* ']' 245 | [4] asize ::= '[' length~ ']' 246 | [5] length ::= nextDimension* Digit+ 247 | [6] nextDimension ::= Digit+ ',' 248 | */ 249 | $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; 250 | if(preg_match($expr,$value,$regs)){ 251 | $this->message[$pos]['typePrefix'] = $regs[1]; 252 | $this->message[$pos]['arrayTypePrefix'] = $regs[1]; 253 | if (isset($this->namespaces[$regs[1]])) { 254 | $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; 255 | } else if (isset($attrs['xmlns:'.$regs[1]])) { 256 | $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; 257 | } 258 | $this->message[$pos]['arrayType'] = $regs[2]; 259 | $this->message[$pos]['arraySize'] = $regs[3]; 260 | $this->message[$pos]['arrayCols'] = $regs[4]; 261 | } 262 | // specifies nil value (or not) 263 | } elseif ($key_localpart == 'nil'){ 264 | $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); 265 | // some other attribute 266 | } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { 267 | $this->message[$pos]['xattrs']['!' . $key] = $value; 268 | } 269 | 270 | if ($key == 'xmlns') { 271 | $this->default_namespace = $value; 272 | } 273 | // log id 274 | if($key == 'id'){ 275 | $this->ids[$value] = $pos; 276 | } 277 | // root 278 | if($key_localpart == 'root' && $value == 1){ 279 | $this->status = 'method'; 280 | $this->root_struct_name = $name; 281 | $this->root_struct = $pos; 282 | $this->debug("found root struct $this->root_struct_name, pos $pos"); 283 | } 284 | // for doclit 285 | $attstr .= " $key=\"$value\""; 286 | } 287 | // get namespace - must be done after namespace atts are processed 288 | if(isset($prefix)){ 289 | $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; 290 | $this->default_namespace = $this->namespaces[$prefix]; 291 | } else { 292 | $this->message[$pos]['namespace'] = $this->default_namespace; 293 | } 294 | if($this->status == 'header'){ 295 | if ($this->root_header != $pos) { 296 | $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; 297 | } 298 | } elseif($this->root_struct_name != ''){ 299 | $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; 300 | } 301 | } 302 | 303 | /** 304 | * end-element handler 305 | * 306 | * @param resource $parser XML parser object 307 | * @param string $name element name 308 | * @access private 309 | */ 310 | function end_element($parser, $name) { 311 | // position of current element is equal to the last value left in depth_array for my depth 312 | $pos = $this->depth_array[$this->depth--]; 313 | 314 | // get element prefix 315 | if(strpos($name,':')){ 316 | // get ns prefix 317 | $prefix = substr($name,0,strpos($name,':')); 318 | // get unqualified name 319 | $name = substr(strstr($name,':'),1); 320 | } 321 | 322 | // build to native type 323 | if(isset($this->body_position) && $pos > $this->body_position){ 324 | // deal w/ multirefs 325 | if(isset($this->message[$pos]['attrs']['href'])){ 326 | // get id 327 | $id = substr($this->message[$pos]['attrs']['href'],1); 328 | // add placeholder to href array 329 | $this->multirefs[$id][$pos] = 'placeholder'; 330 | // add set a reference to it as the result value 331 | $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; 332 | // build complexType values 333 | } elseif($this->message[$pos]['children'] != ''){ 334 | // if result has already been generated (struct/array) 335 | if(!isset($this->message[$pos]['result'])){ 336 | $this->message[$pos]['result'] = $this->buildVal($pos); 337 | } 338 | // build complexType values of attributes and possibly simpleContent 339 | } elseif (isset($this->message[$pos]['xattrs'])) { 340 | if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { 341 | $this->message[$pos]['xattrs']['!'] = null; 342 | } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { 343 | if (isset($this->message[$pos]['type'])) { 344 | $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); 345 | } else { 346 | $parent = $this->message[$pos]['parent']; 347 | if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { 348 | $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); 349 | } else { 350 | $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; 351 | } 352 | } 353 | } 354 | $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; 355 | // set value of simpleType (or nil complexType) 356 | } else { 357 | //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); 358 | if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { 359 | $this->message[$pos]['xattrs']['!'] = null; 360 | } elseif (isset($this->message[$pos]['type'])) { 361 | $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); 362 | } else { 363 | $parent = $this->message[$pos]['parent']; 364 | if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { 365 | $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); 366 | } else { 367 | $this->message[$pos]['result'] = $this->message[$pos]['cdata']; 368 | } 369 | } 370 | 371 | /* add value to parent's result, if parent is struct/array 372 | $parent = $this->message[$pos]['parent']; 373 | if($this->message[$parent]['type'] != 'map'){ 374 | if(strtolower($this->message[$parent]['type']) == 'array'){ 375 | $this->message[$parent]['result'][] = $this->message[$pos]['result']; 376 | } else { 377 | $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result']; 378 | } 379 | } 380 | */ 381 | } 382 | } 383 | 384 | // for doclit 385 | if($this->status == 'header'){ 386 | if ($this->root_header != $pos) { 387 | $this->responseHeaders .= ""; 388 | } 389 | } elseif($pos >= $this->root_struct){ 390 | $this->document .= ""; 391 | } 392 | // switch status 393 | if ($pos == $this->root_struct){ 394 | $this->status = 'body'; 395 | $this->root_struct_namespace = $this->message[$pos]['namespace']; 396 | } elseif ($pos == $this->root_header) { 397 | $this->status = 'envelope'; 398 | } elseif ($name == 'Body' && $this->status == 'body') { 399 | $this->status = 'envelope'; 400 | } elseif ($name == 'Header' && $this->status == 'header') { // will never happen 401 | $this->status = 'envelope'; 402 | } elseif ($name == 'Envelope' && $this->status == 'envelope') { 403 | $this->status = ''; 404 | } 405 | // set parent back to my parent 406 | $this->parent = $this->message[$pos]['parent']; 407 | } 408 | 409 | /** 410 | * element content handler 411 | * 412 | * @param resource $parser XML parser object 413 | * @param string $data element content 414 | * @access private 415 | */ 416 | function character_data($parser, $data){ 417 | $pos = $this->depth_array[$this->depth]; 418 | if ($this->xml_encoding=='UTF-8'){ 419 | // TODO: add an option to disable this for folks who want 420 | // raw UTF-8 that, e.g., might not map to iso-8859-1 421 | // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); 422 | if($this->decode_utf8){ 423 | $data = utf8_decode($data); 424 | } 425 | } 426 | $this->message[$pos]['cdata'] .= $data; 427 | // for doclit 428 | if($this->status == 'header'){ 429 | $this->responseHeaders .= $data; 430 | } else { 431 | $this->document .= $data; 432 | } 433 | } 434 | 435 | /** 436 | * get the parsed message (SOAP Body) 437 | * 438 | * @return mixed 439 | * @access public 440 | * @deprecated use get_soapbody instead 441 | */ 442 | function get_response(){ 443 | return $this->soapresponse; 444 | } 445 | 446 | /** 447 | * get the parsed SOAP Body (NULL if there was none) 448 | * 449 | * @return mixed 450 | * @access public 451 | */ 452 | function get_soapbody(){ 453 | return $this->soapresponse; 454 | } 455 | 456 | /** 457 | * get the parsed SOAP Header (NULL if there was none) 458 | * 459 | * @return mixed 460 | * @access public 461 | */ 462 | function get_soapheader(){ 463 | return $this->soapheader; 464 | } 465 | 466 | /** 467 | * get the unparsed SOAP Header 468 | * 469 | * @return string XML or empty if no Header 470 | * @access public 471 | */ 472 | function getHeaders(){ 473 | return $this->responseHeaders; 474 | } 475 | 476 | /** 477 | * decodes simple types into PHP variables 478 | * 479 | * @param string $value value to decode 480 | * @param string $type XML type to decode 481 | * @param string $typens XML type namespace to decode 482 | * @return mixed PHP value 483 | * @access private 484 | */ 485 | function decodeSimple($value, $type, $typens) { 486 | // TODO: use the namespace! 487 | if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { 488 | return (string) $value; 489 | } 490 | if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { 491 | return (int) $value; 492 | } 493 | if ($type == 'float' || $type == 'double' || $type == 'decimal') { 494 | return (double) $value; 495 | } 496 | if ($type == 'boolean') { 497 | if (strtolower($value) == 'false' || strtolower($value) == 'f') { 498 | return false; 499 | } 500 | return (boolean) $value; 501 | } 502 | if ($type == 'base64' || $type == 'base64Binary') { 503 | $this->debug('Decode base64 value'); 504 | return base64_decode($value); 505 | } 506 | // obscure numeric types 507 | if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' 508 | || $type == 'nonNegativeInteger' || $type == 'positiveInteger' 509 | || $type == 'unsignedInt' 510 | || $type == 'unsignedShort' || $type == 'unsignedByte') { 511 | return (int) $value; 512 | } 513 | // bogus: parser treats array with no elements as a simple type 514 | if ($type == 'array') { 515 | return array(); 516 | } 517 | // everything else 518 | return (string) $value; 519 | } 520 | 521 | /** 522 | * builds response structures for compound values (arrays/structs) 523 | * and scalars 524 | * 525 | * @param integer $pos position in node tree 526 | * @return mixed PHP value 527 | * @access private 528 | */ 529 | function buildVal($pos){ 530 | if(!isset($this->message[$pos]['type'])){ 531 | $this->message[$pos]['type'] = ''; 532 | } 533 | $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); 534 | // if there are children... 535 | if($this->message[$pos]['children'] != ''){ 536 | $this->debug('in buildVal, there are children'); 537 | $children = explode('|',$this->message[$pos]['children']); 538 | array_shift($children); // knock off empty 539 | // md array 540 | if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ 541 | $r=0; // rowcount 542 | $c=0; // colcount 543 | foreach($children as $child_pos){ 544 | $this->debug("in buildVal, got an MD array element: $r, $c"); 545 | $params[$r][] = $this->message[$child_pos]['result']; 546 | $c++; 547 | if($c == $this->message[$pos]['arrayCols']){ 548 | $c = 0; 549 | $r++; 550 | } 551 | } 552 | // array 553 | } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ 554 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); 555 | foreach($children as $child_pos){ 556 | $params[] = &$this->message[$child_pos]['result']; 557 | } 558 | // apache Map type: java hashtable 559 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ 560 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); 561 | foreach($children as $child_pos){ 562 | $kv = explode("|",$this->message[$child_pos]['children']); 563 | $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; 564 | } 565 | // generic compound type 566 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { 567 | } else { 568 | // Apache Vector type: treat as an array 569 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); 570 | if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { 571 | $notstruct = 1; 572 | } else { 573 | $notstruct = 0; 574 | } 575 | // 576 | foreach($children as $child_pos){ 577 | if($notstruct){ 578 | $params[] = &$this->message[$child_pos]['result']; 579 | } else { 580 | if (isset($params[$this->message[$child_pos]['name']])) { 581 | // de-serialize repeated element name into an array 582 | if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { 583 | $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); 584 | } 585 | $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; 586 | } else { 587 | $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; 588 | } 589 | } 590 | } 591 | } 592 | if (isset($this->message[$pos]['xattrs'])) { 593 | $this->debug('in buildVal, handling attributes'); 594 | foreach ($this->message[$pos]['xattrs'] as $n => $v) { 595 | $params[$n] = $v; 596 | } 597 | } 598 | // handle simpleContent 599 | if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { 600 | $this->debug('in buildVal, handling simpleContent'); 601 | if (isset($this->message[$pos]['type'])) { 602 | $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); 603 | } else { 604 | $parent = $this->message[$pos]['parent']; 605 | if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { 606 | $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); 607 | } else { 608 | $params['!'] = $this->message[$pos]['cdata']; 609 | } 610 | } 611 | } 612 | $ret = is_array($params) ? $params : array(); 613 | $this->debug('in buildVal, return:'); 614 | $this->appendDebug($this->varDump($ret)); 615 | return $ret; 616 | } else { 617 | $this->debug('in buildVal, no children, building scalar'); 618 | $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; 619 | if (isset($this->message[$pos]['type'])) { 620 | $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); 621 | $this->debug("in buildVal, return: $ret"); 622 | return $ret; 623 | } 624 | $parent = $this->message[$pos]['parent']; 625 | if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { 626 | $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); 627 | $this->debug("in buildVal, return: $ret"); 628 | return $ret; 629 | } 630 | $ret = $this->message[$pos]['cdata']; 631 | $this->debug("in buildVal, return: $ret"); 632 | return $ret; 633 | } 634 | } 635 | } 636 | 637 | /** 638 | * Backward compatibility 639 | */ 640 | class soap_parser extends nusoap_parser { 641 | } 642 | 643 | 644 | ?> -------------------------------------------------------------------------------- /lib/class.soap_val.php: -------------------------------------------------------------------------------- 1 | 14 | * @version $Id: class.soap_val.php,v 1.11 2007/04/06 13:56:32 snichol Exp $ 15 | * @access public 16 | */ 17 | class soapval extends nusoap_base { 18 | /** 19 | * The XML element name 20 | * 21 | * @var string 22 | * @access private 23 | */ 24 | var $name; 25 | /** 26 | * The XML type name (string or false) 27 | * 28 | * @var mixed 29 | * @access private 30 | */ 31 | var $type; 32 | /** 33 | * The PHP value 34 | * 35 | * @var mixed 36 | * @access private 37 | */ 38 | var $value; 39 | /** 40 | * The XML element namespace (string or false) 41 | * 42 | * @var mixed 43 | * @access private 44 | */ 45 | var $element_ns; 46 | /** 47 | * The XML type namespace (string or false) 48 | * 49 | * @var mixed 50 | * @access private 51 | */ 52 | var $type_ns; 53 | /** 54 | * The XML element attributes (array or false) 55 | * 56 | * @var mixed 57 | * @access private 58 | */ 59 | var $attributes; 60 | 61 | /** 62 | * constructor 63 | * 64 | * @param string $name optional name 65 | * @param mixed $type optional type name 66 | * @param mixed $value optional value 67 | * @param mixed $element_ns optional namespace of value 68 | * @param mixed $type_ns optional namespace of type 69 | * @param mixed $attributes associative array of attributes to add to element serialization 70 | * @access public 71 | */ 72 | function __construct($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) { 73 | parent::__construct(); 74 | $this->name = $name; 75 | $this->type = $type; 76 | $this->value = $value; 77 | $this->element_ns = $element_ns; 78 | $this->type_ns = $type_ns; 79 | $this->attributes = $attributes; 80 | } 81 | 82 | /** 83 | * return serialized value 84 | * 85 | * @param string $use The WSDL use value (encoded|literal) 86 | * @return string XML data 87 | * @access public 88 | */ 89 | function serialize($use='encoded') { 90 | return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); 91 | } 92 | 93 | /** 94 | * decodes a soapval object into a PHP native type 95 | * 96 | * @return mixed 97 | * @access public 98 | */ 99 | function decode(){ 100 | return $this->value; 101 | } 102 | } 103 | 104 | 105 | 106 | 107 | ?> -------------------------------------------------------------------------------- /lib/class.soapclient.php: -------------------------------------------------------------------------------- 1 | call( string methodname [ ,array parameters] ); 17 | * 18 | * // bye bye client 19 | * unset($soapclient); 20 | * 21 | * @author Dietrich Ayala 22 | * @author Scott Nichol 23 | * @version $Id: class.soapclient.php,v 1.69 2010/04/26 20:15:08 snichol Exp $ 24 | * @access public 25 | */ 26 | class nusoap_client extends nusoap_base { 27 | 28 | var $username = ''; // Username for HTTP authentication 29 | var $password = ''; // Password for HTTP authentication 30 | var $authtype = ''; // Type of HTTP authentication 31 | var $certRequest = array(); // Certificate for HTTP SSL authentication 32 | var $requestHeaders = false; // SOAP headers in request (text) 33 | var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) 34 | var $responseHeader = NULL; // SOAP Header from response (parsed) 35 | var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) 36 | var $endpoint; 37 | var $forceEndpoint = ''; // overrides WSDL endpoint 38 | var $proxyhost = ''; 39 | var $proxyport = ''; 40 | var $proxyusername = ''; 41 | var $proxypassword = ''; 42 | var $portName = ''; // port name to use in WSDL 43 | var $xml_encoding = ''; // character set encoding of incoming (response) messages 44 | var $http_encoding = false; 45 | var $timeout = 0; // HTTP connection timeout 46 | var $response_timeout = 30; // HTTP response timeout 47 | var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error 48 | var $persistentConnection = false; 49 | var $defaultRpcParams = false; // This is no longer used 50 | var $request = ''; // HTTP request 51 | var $response = ''; // HTTP response 52 | var $responseData = ''; // SOAP payload of response 53 | var $cookies = array(); // Cookies from response or for request 54 | var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() 55 | var $operations = array(); // WSDL operations, empty for WSDL initialization error 56 | var $curl_options = array(); // User-specified cURL options 57 | var $bindingType = ''; // WSDL operation binding type 58 | var $use_curl = false; // whether to always try to use cURL 59 | 60 | /* 61 | * fault related variables 62 | */ 63 | /** 64 | * @var fault 65 | * @access public 66 | */ 67 | var $fault; 68 | /** 69 | * @var faultcode 70 | * @access public 71 | */ 72 | var $faultcode; 73 | /** 74 | * @var faultstring 75 | * @access public 76 | */ 77 | var $faultstring; 78 | /** 79 | * @var faultdetail 80 | * @access public 81 | */ 82 | var $faultdetail; 83 | 84 | /** 85 | * constructor 86 | * 87 | * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) 88 | * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL 89 | * @param string $proxyhost optional 90 | * @param string $proxyport optional 91 | * @param string $proxyusername optional 92 | * @param string $proxypassword optional 93 | * @param integer $timeout set the connection timeout 94 | * @param integer $response_timeout set the response timeout 95 | * @param string $portName optional portName in WSDL document 96 | * @access public 97 | */ 98 | function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){ 99 | parent::__construct(); 100 | $this->endpoint = $endpoint; 101 | $this->proxyhost = $proxyhost; 102 | $this->proxyport = $proxyport; 103 | $this->proxyusername = $proxyusername; 104 | $this->proxypassword = $proxypassword; 105 | $this->timeout = $timeout; 106 | $this->response_timeout = $response_timeout; 107 | $this->portName = $portName; 108 | 109 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); 110 | $this->appendDebug('endpoint=' . $this->varDump($endpoint)); 111 | 112 | // make values 113 | if($wsdl){ 114 | if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) { 115 | $this->wsdl = $endpoint; 116 | $this->endpoint = $this->wsdl->wsdl; 117 | $this->wsdlFile = $this->endpoint; 118 | $this->debug('existing wsdl instance created from ' . $this->endpoint); 119 | $this->checkWSDL(); 120 | } else { 121 | $this->wsdlFile = $this->endpoint; 122 | $this->wsdl = null; 123 | $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint); 124 | } 125 | $this->endpointType = 'wsdl'; 126 | } else { 127 | $this->debug("instantiate SOAP with endpoint at $endpoint"); 128 | $this->endpointType = 'soap'; 129 | } 130 | } 131 | 132 | /** 133 | * calls method, returns PHP native type 134 | * 135 | * @param string $operation SOAP server URL or path 136 | * @param mixed $params An array, associative or simple, of the parameters 137 | * for the method call, or a string that is the XML 138 | * for the call. For rpc style, this call will 139 | * wrap the XML in a tag named after the method, as 140 | * well as the SOAP Envelope and Body. For document 141 | * style, this will only wrap with the Envelope and Body. 142 | * IMPORTANT: when using an array with document style, 143 | * in which case there 144 | * is really one parameter, the root of the fragment 145 | * used in the call, which encloses what programmers 146 | * normally think of parameters. A parameter array 147 | * *must* include the wrapper. 148 | * @param string $namespace optional method namespace (WSDL can override) 149 | * @param string $soapAction optional SOAPAction value (WSDL can override) 150 | * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array 151 | * @param boolean $rpcParams optional (no longer used) 152 | * @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override) 153 | * @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override) 154 | * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors 155 | * @access public 156 | */ 157 | function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){ 158 | $this->operation = $operation; 159 | $this->fault = false; 160 | $this->setError(''); 161 | $this->request = ''; 162 | $this->response = ''; 163 | $this->responseData = ''; 164 | $this->faultstring = ''; 165 | $this->faultcode = ''; 166 | $this->opData = array(); 167 | 168 | $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType"); 169 | $this->appendDebug('params=' . $this->varDump($params)); 170 | $this->appendDebug('headers=' . $this->varDump($headers)); 171 | if ($headers) { 172 | $this->requestHeaders = $headers; 173 | } 174 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 175 | $this->loadWSDL(); 176 | if ($this->getError()) 177 | return false; 178 | } 179 | // serialize parameters 180 | if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){ 181 | // use WSDL for operation 182 | $this->opData = $opData; 183 | $this->debug("found operation"); 184 | $this->appendDebug('opData=' . $this->varDump($opData)); 185 | if (isset($opData['soapAction'])) { 186 | $soapAction = $opData['soapAction']; 187 | } 188 | if (! $this->forceEndpoint) { 189 | $this->endpoint = $opData['endpoint']; 190 | } else { 191 | $this->endpoint = $this->forceEndpoint; 192 | } 193 | $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; 194 | $style = $opData['style']; 195 | $use = $opData['input']['use']; 196 | // add ns to ns array 197 | if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){ 198 | $nsPrefix = 'ns' . rand(1000, 9999); 199 | $this->wsdl->namespaces[$nsPrefix] = $namespace; 200 | } 201 | $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); 202 | // serialize payload 203 | if (is_string($params)) { 204 | $this->debug("serializing param string for WSDL operation $operation"); 205 | $payload = $params; 206 | } elseif (is_array($params)) { 207 | $this->debug("serializing param array for WSDL operation $operation"); 208 | $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); 209 | } else { 210 | $this->debug('params must be array or string'); 211 | $this->setError('params must be array or string'); 212 | return false; 213 | } 214 | $usedNamespaces = $this->wsdl->usedNamespaces; 215 | if (isset($opData['input']['encodingStyle'])) { 216 | $encodingStyle = $opData['input']['encodingStyle']; 217 | } else { 218 | $encodingStyle = ''; 219 | } 220 | $this->appendDebug($this->wsdl->getDebug()); 221 | $this->wsdl->clearDebug(); 222 | if ($errstr = $this->wsdl->getError()) { 223 | $this->debug('got wsdl error: '.$errstr); 224 | $this->setError('wsdl error: '.$errstr); 225 | return false; 226 | } 227 | } elseif($this->endpointType == 'wsdl') { 228 | // operation not in WSDL 229 | $this->appendDebug($this->wsdl->getDebug()); 230 | $this->wsdl->clearDebug(); 231 | $this->setError('operation '.$operation.' not present in WSDL.'); 232 | $this->debug("operation '$operation' not present in WSDL."); 233 | return false; 234 | } else { 235 | // no WSDL 236 | //$this->namespaces['ns1'] = $namespace; 237 | $nsPrefix = 'ns' . rand(1000, 9999); 238 | // serialize 239 | $payload = ''; 240 | if (is_string($params)) { 241 | $this->debug("serializing param string for operation $operation"); 242 | $payload = $params; 243 | } elseif (is_array($params)) { 244 | $this->debug("serializing param array for operation $operation"); 245 | foreach($params as $k => $v){ 246 | $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); 247 | } 248 | } else { 249 | $this->debug('params must be array or string'); 250 | $this->setError('params must be array or string'); 251 | return false; 252 | } 253 | $usedNamespaces = array(); 254 | if ($use == 'encoded') { 255 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; 256 | } else { 257 | $encodingStyle = ''; 258 | } 259 | } 260 | // wrap RPC calls with method element 261 | if ($style == 'rpc') { 262 | if ($use == 'literal') { 263 | $this->debug("wrapping RPC request with literal method element"); 264 | if ($namespace) { 265 | // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace 266 | $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 267 | $payload . 268 | ""; 269 | } else { 270 | $payload = "<$operation>" . $payload . ""; 271 | } 272 | } else { 273 | $this->debug("wrapping RPC request with encoded method element"); 274 | if ($namespace) { 275 | $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 276 | $payload . 277 | ""; 278 | } else { 279 | $payload = "<$operation>" . 280 | $payload . 281 | ""; 282 | } 283 | } 284 | } 285 | // serialize envelope 286 | $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); 287 | $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle"); 288 | $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000)); 289 | // send 290 | $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); 291 | if($errstr = $this->getError()){ 292 | $this->debug('Error: '.$errstr); 293 | return false; 294 | } else { 295 | $this->return = $return; 296 | $this->debug('sent message successfully and got a(n) '.gettype($return)); 297 | $this->appendDebug('return=' . $this->varDump($return)); 298 | 299 | // fault? 300 | if(is_array($return) && isset($return['faultcode'])){ 301 | $this->debug('got fault'); 302 | $this->setError($return['faultcode'].': '.$return['faultstring']); 303 | $this->fault = true; 304 | foreach($return as $k => $v){ 305 | $this->$k = $v; 306 | $this->debug("$k = $v
"); 307 | } 308 | return $return; 309 | } elseif ($style == 'document') { 310 | // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), 311 | // we are only going to return the first part here...sorry about that 312 | return $return; 313 | } else { 314 | // array of return values 315 | if(is_array($return)){ 316 | // multiple 'out' parameters, which we return wrapped up 317 | // in the array 318 | if(sizeof($return) > 1){ 319 | return $return; 320 | } 321 | // single 'out' parameter (normally the return value) 322 | $return = array_shift($return); 323 | $this->debug('return shifted value: '); 324 | $this->appendDebug($this->varDump($return)); 325 | return $return; 326 | // nothing returned (ie, echoVoid) 327 | } else { 328 | return ""; 329 | } 330 | } 331 | } 332 | } 333 | 334 | /** 335 | * check WSDL passed as an instance or pulled from an endpoint 336 | * 337 | * @access private 338 | */ 339 | function checkWSDL() { 340 | $this->appendDebug($this->wsdl->getDebug()); 341 | $this->wsdl->clearDebug(); 342 | $this->debug('checkWSDL'); 343 | // catch errors 344 | if ($errstr = $this->wsdl->getError()) { 345 | $this->appendDebug($this->wsdl->getDebug()); 346 | $this->wsdl->clearDebug(); 347 | $this->debug('got wsdl error: '.$errstr); 348 | $this->setError('wsdl error: '.$errstr); 349 | } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) { 350 | $this->appendDebug($this->wsdl->getDebug()); 351 | $this->wsdl->clearDebug(); 352 | $this->bindingType = 'soap'; 353 | $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType); 354 | } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) { 355 | $this->appendDebug($this->wsdl->getDebug()); 356 | $this->wsdl->clearDebug(); 357 | $this->bindingType = 'soap12'; 358 | $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType); 359 | $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************'); 360 | } else { 361 | $this->appendDebug($this->wsdl->getDebug()); 362 | $this->wsdl->clearDebug(); 363 | $this->debug('getOperations returned false'); 364 | $this->setError('no operations defined in the WSDL document!'); 365 | } 366 | } 367 | 368 | /** 369 | * instantiate wsdl object and parse wsdl file 370 | * 371 | * @access public 372 | */ 373 | function loadWSDL() { 374 | $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile); 375 | $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl); 376 | $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); 377 | $this->wsdl->fetchWSDL($this->wsdlFile); 378 | $this->checkWSDL(); 379 | } 380 | 381 | /** 382 | * get available data pertaining to an operation 383 | * 384 | * @param string $operation operation name 385 | * @return array array of data pertaining to the operation 386 | * @access public 387 | */ 388 | function getOperationData($operation){ 389 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 390 | $this->loadWSDL(); 391 | if ($this->getError()) 392 | return false; 393 | } 394 | if(isset($this->operations[$operation])){ 395 | return $this->operations[$operation]; 396 | } 397 | $this->debug("No data for operation: $operation"); 398 | } 399 | 400 | /** 401 | * send the SOAP message 402 | * 403 | * Note: if the operation has multiple return values 404 | * the return value of this method will be an array 405 | * of those values. 406 | * 407 | * @param string $msg a SOAPx4 soapmsg object 408 | * @param string $soapaction SOAPAction value 409 | * @param integer $timeout set connection timeout in seconds 410 | * @param integer $response_timeout set response timeout in seconds 411 | * @return mixed native PHP types. 412 | * @access private 413 | */ 414 | function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) { 415 | $this->checkCookies(); 416 | // detect transport 417 | switch(true){ 418 | // http(s) 419 | case preg_match('/^http/',$this->endpoint): 420 | $this->debug('transporting via HTTP'); 421 | if($this->persistentConnection == true && is_object($this->persistentConnection)){ 422 | $http =& $this->persistentConnection; 423 | } else { 424 | $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); 425 | if ($this->persistentConnection) { 426 | $http->usePersistentConnection(); 427 | } 428 | } 429 | $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); 430 | $http->setSOAPAction($soapaction); 431 | if($this->proxyhost && $this->proxyport){ 432 | $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); 433 | } 434 | if($this->authtype != '') { 435 | $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); 436 | } 437 | if($this->http_encoding != ''){ 438 | $http->setEncoding($this->http_encoding); 439 | } 440 | $this->debug('sending message, length='.strlen($msg)); 441 | if(preg_match('/^http:/',$this->endpoint)){ 442 | //if(strpos($this->endpoint,'http:')){ 443 | $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); 444 | } elseif(preg_match('/^https/',$this->endpoint)){ 445 | //} elseif(strpos($this->endpoint,'https:')){ 446 | //if(phpversion() == '4.3.0-dev'){ 447 | //$response = $http->send($msg,$timeout,$response_timeout); 448 | //$this->request = $http->outgoing_payload; 449 | //$this->response = $http->incoming_payload; 450 | //} else 451 | $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); 452 | } else { 453 | $this->setError('no http/s in endpoint url'); 454 | } 455 | $this->request = $http->outgoing_payload; 456 | $this->response = $http->incoming_payload; 457 | $this->appendDebug($http->getDebug()); 458 | $this->UpdateCookies($http->incoming_cookies); 459 | 460 | // save transport object if using persistent connections 461 | if ($this->persistentConnection) { 462 | $http->clearDebug(); 463 | if (!is_object($this->persistentConnection)) { 464 | $this->persistentConnection = $http; 465 | } 466 | } 467 | 468 | if($err = $http->getError()){ 469 | $this->setError('HTTP Error: '.$err); 470 | return false; 471 | } elseif($this->getError()){ 472 | return false; 473 | } else { 474 | $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']); 475 | return $this->parseResponse($http->incoming_headers, $this->responseData); 476 | } 477 | break; 478 | default: 479 | $this->setError('no transport found, or selected transport is not yet supported!'); 480 | return false; 481 | break; 482 | } 483 | } 484 | 485 | /** 486 | * processes SOAP message returned from server 487 | * 488 | * @param array $headers The HTTP headers 489 | * @param string $data unprocessed response data from server 490 | * @return mixed value of the message, decoded into a PHP type 491 | * @access private 492 | */ 493 | function parseResponse($headers, $data) { 494 | $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:'); 495 | $this->appendDebug($this->varDump($headers)); 496 | if (!isset($headers['content-type'])) { 497 | $this->setError('Response not of type text/xml (no content-type header)'); 498 | return false; 499 | } 500 | if (!strstr($headers['content-type'], 'text/xml')) { 501 | $this->setError('Response not of type text/xml: ' . $headers['content-type']); 502 | return false; 503 | } 504 | if (strpos($headers['content-type'], '=')) { 505 | $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); 506 | $this->debug('Got response encoding: ' . $enc); 507 | if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ 508 | $this->xml_encoding = strtoupper($enc); 509 | } else { 510 | $this->xml_encoding = 'US-ASCII'; 511 | } 512 | } else { 513 | // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 514 | $this->xml_encoding = 'ISO-8859-1'; 515 | } 516 | $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser'); 517 | $parser = new nusoap_parser($data,$this->xml_encoding,property_exists($this, 'operation') ? $this->operation : '',$this->decode_utf8); 518 | // add parser debug data to our debug 519 | $this->appendDebug($parser->getDebug()); 520 | // if parse errors 521 | if($errstr = $parser->getError()){ 522 | $this->setError( $errstr); 523 | // destroy the parser object 524 | unset($parser); 525 | return false; 526 | } else { 527 | // get SOAP headers 528 | $this->responseHeaders = $parser->getHeaders(); 529 | // get SOAP headers 530 | $this->responseHeader = $parser->get_soapheader(); 531 | // get decoded message 532 | $return = $parser->get_soapbody(); 533 | // add document for doclit support 534 | $this->document = $parser->document; 535 | // destroy the parser object 536 | unset($parser); 537 | // return decode message 538 | return $return; 539 | } 540 | } 541 | 542 | /** 543 | * sets user-specified cURL options 544 | * 545 | * @param mixed $option The cURL option (always integer?) 546 | * @param mixed $value The cURL option value 547 | * @access public 548 | */ 549 | function setCurlOption($option, $value) { 550 | $this->debug("setCurlOption option=$option, value="); 551 | $this->appendDebug($this->varDump($value)); 552 | $this->curl_options[$option] = $value; 553 | } 554 | 555 | /** 556 | * sets the SOAP endpoint, which can override WSDL 557 | * 558 | * @param string $endpoint The endpoint URL to use, or empty string or false to prevent override 559 | * @access public 560 | */ 561 | function setEndpoint($endpoint) { 562 | $this->debug("setEndpoint(\"$endpoint\")"); 563 | $this->forceEndpoint = $endpoint; 564 | } 565 | 566 | /** 567 | * set the SOAP headers 568 | * 569 | * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers 570 | * @access public 571 | */ 572 | function setHeaders($headers){ 573 | $this->debug("setHeaders headers="); 574 | $this->appendDebug($this->varDump($headers)); 575 | $this->requestHeaders = $headers; 576 | } 577 | 578 | /** 579 | * get the SOAP response headers (namespace resolution incomplete) 580 | * 581 | * @return string 582 | * @access public 583 | */ 584 | function getHeaders(){ 585 | return $this->responseHeaders; 586 | } 587 | 588 | /** 589 | * get the SOAP response Header (parsed) 590 | * 591 | * @return mixed 592 | * @access public 593 | */ 594 | function getHeader(){ 595 | return $this->responseHeader; 596 | } 597 | 598 | /** 599 | * set proxy info here 600 | * 601 | * @param string $proxyhost 602 | * @param string $proxyport 603 | * @param string $proxyusername 604 | * @param string $proxypassword 605 | * @access public 606 | */ 607 | function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') { 608 | $this->proxyhost = $proxyhost; 609 | $this->proxyport = $proxyport; 610 | $this->proxyusername = $proxyusername; 611 | $this->proxypassword = $proxypassword; 612 | } 613 | 614 | /** 615 | * if authenticating, set user credentials here 616 | * 617 | * @param string $username 618 | * @param string $password 619 | * @param string $authtype (basic|digest|certificate|ntlm) 620 | * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) 621 | * @access public 622 | */ 623 | function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { 624 | $this->debug("setCredentials username=$username authtype=$authtype certRequest="); 625 | $this->appendDebug($this->varDump($certRequest)); 626 | $this->username = $username; 627 | $this->password = $password; 628 | $this->authtype = $authtype; 629 | $this->certRequest = $certRequest; 630 | } 631 | 632 | /** 633 | * use HTTP encoding 634 | * 635 | * @param string $enc HTTP encoding 636 | * @access public 637 | */ 638 | function setHTTPEncoding($enc='gzip, deflate'){ 639 | $this->debug("setHTTPEncoding(\"$enc\")"); 640 | $this->http_encoding = $enc; 641 | } 642 | 643 | /** 644 | * Set whether to try to use cURL connections if possible 645 | * 646 | * @param boolean $use Whether to try to use cURL 647 | * @access public 648 | */ 649 | function setUseCURL($use) { 650 | $this->debug("setUseCURL($use)"); 651 | $this->use_curl = $use; 652 | } 653 | 654 | /** 655 | * use HTTP persistent connections if possible 656 | * 657 | * @access public 658 | */ 659 | function useHTTPPersistentConnection(){ 660 | $this->debug("useHTTPPersistentConnection"); 661 | $this->persistentConnection = true; 662 | } 663 | 664 | /** 665 | * gets the default RPC parameter setting. 666 | * If true, default is that call params are like RPC even for document style. 667 | * Each call() can override this value. 668 | * 669 | * This is no longer used. 670 | * 671 | * @return boolean 672 | * @access public 673 | * @deprecated 674 | */ 675 | function getDefaultRpcParams() { 676 | return $this->defaultRpcParams; 677 | } 678 | 679 | /** 680 | * sets the default RPC parameter setting. 681 | * If true, default is that call params are like RPC even for document style 682 | * Each call() can override this value. 683 | * 684 | * This is no longer used. 685 | * 686 | * @param boolean $rpcParams 687 | * @access public 688 | * @deprecated 689 | */ 690 | function setDefaultRpcParams($rpcParams) { 691 | $this->defaultRpcParams = $rpcParams; 692 | } 693 | 694 | /** 695 | * dynamically creates an instance of a proxy class, 696 | * allowing user to directly call methods from wsdl 697 | * 698 | * @return object soap_proxy object 699 | * @access public 700 | */ 701 | function getProxy() { 702 | $r = rand(); 703 | $evalStr = $this->_getProxyClassCode($r); 704 | //$this->debug("proxy class: $evalStr"); 705 | if ($this->getError()) { 706 | $this->debug("Error from _getProxyClassCode, so return NULL"); 707 | return null; 708 | } 709 | // eval the class 710 | eval($evalStr); 711 | // instantiate proxy object 712 | eval("\$proxy = new nusoap_proxy_$r('');"); 713 | // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice 714 | $proxy->endpointType = 'wsdl'; 715 | $proxy->wsdlFile = $this->wsdlFile; 716 | $proxy->wsdl = $this->wsdl; 717 | $proxy->operations = $this->operations; 718 | $proxy->defaultRpcParams = $this->defaultRpcParams; 719 | // transfer other state 720 | $proxy->soap_defencoding = $this->soap_defencoding; 721 | $proxy->username = $this->username; 722 | $proxy->password = $this->password; 723 | $proxy->authtype = $this->authtype; 724 | $proxy->certRequest = $this->certRequest; 725 | $proxy->requestHeaders = $this->requestHeaders; 726 | $proxy->endpoint = $this->endpoint; 727 | $proxy->forceEndpoint = $this->forceEndpoint; 728 | $proxy->proxyhost = $this->proxyhost; 729 | $proxy->proxyport = $this->proxyport; 730 | $proxy->proxyusername = $this->proxyusername; 731 | $proxy->proxypassword = $this->proxypassword; 732 | $proxy->http_encoding = $this->http_encoding; 733 | $proxy->timeout = $this->timeout; 734 | $proxy->response_timeout = $this->response_timeout; 735 | $proxy->persistentConnection = &$this->persistentConnection; 736 | $proxy->decode_utf8 = $this->decode_utf8; 737 | $proxy->curl_options = $this->curl_options; 738 | $proxy->bindingType = $this->bindingType; 739 | $proxy->use_curl = $this->use_curl; 740 | return $proxy; 741 | } 742 | 743 | /** 744 | * dynamically creates proxy class code 745 | * 746 | * @return string PHP/NuSOAP code for the proxy class 747 | * @access private 748 | */ 749 | function _getProxyClassCode($r) { 750 | $this->debug("in getProxy endpointType=$this->endpointType"); 751 | $this->appendDebug("wsdl=" . $this->varDump($this->wsdl)); 752 | if ($this->endpointType != 'wsdl') { 753 | $evalStr = 'A proxy can only be created for a WSDL client'; 754 | $this->setError($evalStr); 755 | $evalStr = "echo \"$evalStr\";"; 756 | return $evalStr; 757 | } 758 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { 759 | $this->loadWSDL(); 760 | if ($this->getError()) { 761 | return "echo \"" . $this->getError() . "\";"; 762 | } 763 | } 764 | $evalStr = ''; 765 | foreach ($this->operations as $operation => $opData) { 766 | if ($operation != '') { 767 | // create param string and param comment string 768 | if (sizeof($opData['input']['parts']) > 0) { 769 | $paramStr = ''; 770 | $paramArrayStr = ''; 771 | $paramCommentStr = ''; 772 | foreach ($opData['input']['parts'] as $name => $type) { 773 | $paramStr .= "\$$name, "; 774 | $paramArrayStr .= "'$name' => \$$name, "; 775 | $paramCommentStr .= "$type \$$name, "; 776 | } 777 | $paramStr = substr($paramStr, 0, strlen($paramStr)-2); 778 | $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); 779 | $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); 780 | } else { 781 | $paramStr = ''; 782 | $paramArrayStr = ''; 783 | $paramCommentStr = 'void'; 784 | } 785 | $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; 786 | $evalStr .= "// $paramCommentStr 787 | function " . str_replace('.', '__', $operation) . "($paramStr) { 788 | \$params = array($paramArrayStr); 789 | return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."'); 790 | } 791 | "; 792 | unset($paramStr); 793 | unset($paramCommentStr); 794 | } 795 | } 796 | $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client { 797 | '.$evalStr.' 798 | }'; 799 | return $evalStr; 800 | } 801 | 802 | /** 803 | * dynamically creates proxy class code 804 | * 805 | * @return string PHP/NuSOAP code for the proxy class 806 | * @access public 807 | */ 808 | function getProxyClassCode() { 809 | $r = rand(); 810 | return $this->_getProxyClassCode($r); 811 | } 812 | 813 | /** 814 | * gets the HTTP body for the current request. 815 | * 816 | * @param string $soapmsg The SOAP payload 817 | * @return string The HTTP body, which includes the SOAP payload 818 | * @access private 819 | */ 820 | function getHTTPBody($soapmsg) { 821 | return $soapmsg; 822 | } 823 | 824 | /** 825 | * gets the HTTP content type for the current request. 826 | * 827 | * Note: getHTTPBody must be called before this. 828 | * 829 | * @return string the HTTP content type for the current request. 830 | * @access private 831 | */ 832 | function getHTTPContentType() { 833 | return 'text/xml'; 834 | } 835 | 836 | /** 837 | * gets the HTTP content type charset for the current request. 838 | * returns false for non-text content types. 839 | * 840 | * Note: getHTTPBody must be called before this. 841 | * 842 | * @return string the HTTP content type charset for the current request. 843 | * @access private 844 | */ 845 | function getHTTPContentTypeCharset() { 846 | return $this->soap_defencoding; 847 | } 848 | 849 | /* 850 | * whether or not parser should decode utf8 element content 851 | * 852 | * @return always returns true 853 | * @access public 854 | */ 855 | function decodeUTF8($bool){ 856 | $this->decode_utf8 = $bool; 857 | return true; 858 | } 859 | 860 | /** 861 | * adds a new Cookie into $this->cookies array 862 | * 863 | * @param string $name Cookie Name 864 | * @param string $value Cookie Value 865 | * @return boolean if cookie-set was successful returns true, else false 866 | * @access public 867 | */ 868 | function setCookie($name, $value) { 869 | if (strlen($name) == 0) { 870 | return false; 871 | } 872 | $this->cookies[] = array('name' => $name, 'value' => $value); 873 | return true; 874 | } 875 | 876 | /** 877 | * gets all Cookies 878 | * 879 | * @return array with all internal cookies 880 | * @access public 881 | */ 882 | function getCookies() { 883 | return $this->cookies; 884 | } 885 | 886 | /** 887 | * checks all Cookies and delete those which are expired 888 | * 889 | * @return boolean always return true 890 | * @access private 891 | */ 892 | function checkCookies() { 893 | if (sizeof($this->cookies) == 0) { 894 | return true; 895 | } 896 | $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies'); 897 | $curr_cookies = $this->cookies; 898 | $this->cookies = array(); 899 | foreach ($curr_cookies as $cookie) { 900 | if (! is_array($cookie)) { 901 | $this->debug('Remove cookie that is not an array'); 902 | continue; 903 | } 904 | if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) { 905 | if (strtotime($cookie['expires']) > time()) { 906 | $this->cookies[] = $cookie; 907 | } else { 908 | $this->debug('Remove expired cookie ' . $cookie['name']); 909 | } 910 | } else { 911 | $this->cookies[] = $cookie; 912 | } 913 | } 914 | $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array'); 915 | return true; 916 | } 917 | 918 | /** 919 | * updates the current cookies with a new set 920 | * 921 | * @param array $cookies new cookies with which to update current ones 922 | * @return boolean always return true 923 | * @access private 924 | */ 925 | function UpdateCookies($cookies) { 926 | if (sizeof($this->cookies) == 0) { 927 | // no existing cookies: take whatever is new 928 | if (sizeof($cookies) > 0) { 929 | $this->debug('Setting new cookie(s)'); 930 | $this->cookies = $cookies; 931 | } 932 | return true; 933 | } 934 | if (sizeof($cookies) == 0) { 935 | // no new cookies: keep what we've got 936 | return true; 937 | } 938 | // merge 939 | foreach ($cookies as $newCookie) { 940 | if (!is_array($newCookie)) { 941 | continue; 942 | } 943 | if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) { 944 | continue; 945 | } 946 | $newName = $newCookie['name']; 947 | 948 | $found = false; 949 | for ($i = 0; $i < count($this->cookies); $i++) { 950 | $cookie = $this->cookies[$i]; 951 | if (!is_array($cookie)) { 952 | continue; 953 | } 954 | if (!isset($cookie['name'])) { 955 | continue; 956 | } 957 | if ($newName != $cookie['name']) { 958 | continue; 959 | } 960 | $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; 961 | $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; 962 | if ($newDomain != $domain) { 963 | continue; 964 | } 965 | $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; 966 | $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; 967 | if ($newPath != $path) { 968 | continue; 969 | } 970 | $this->cookies[$i] = $newCookie; 971 | $found = true; 972 | $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']); 973 | break; 974 | } 975 | if (! $found) { 976 | $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']); 977 | $this->cookies[] = $newCookie; 978 | } 979 | } 980 | return true; 981 | } 982 | } 983 | 984 | if (!extension_loaded('soap')) { 985 | /** 986 | * For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded. 987 | */ 988 | class soapclient extends nusoap_client { 989 | } 990 | } 991 | ?> 992 | -------------------------------------------------------------------------------- /lib/class.wsdlcache.php: -------------------------------------------------------------------------------- 1 | 14 | * @author Ingo Fischer 15 | * @version $Id: class.wsdlcache.php,v 1.7 2007/04/17 16:34:03 snichol Exp $ 16 | * @access public 17 | */ 18 | class nusoap_wsdlcache { 19 | /** 20 | * @var resource 21 | * @access private 22 | */ 23 | var $fplock; 24 | /** 25 | * @var integer 26 | * @access private 27 | */ 28 | var $cache_lifetime; 29 | /** 30 | * @var string 31 | * @access private 32 | */ 33 | var $cache_dir; 34 | /** 35 | * @var string 36 | * @access public 37 | */ 38 | var $debug_str = ''; 39 | 40 | /** 41 | * constructor 42 | * 43 | * @param string $cache_dir directory for cache-files 44 | * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited 45 | * @access public 46 | */ 47 | function __construct($cache_dir='.', $cache_lifetime=0) { 48 | $this->fplock = array(); 49 | $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; 50 | $this->cache_lifetime = $cache_lifetime; 51 | } 52 | 53 | /** 54 | * creates the filename used to cache a wsdl instance 55 | * 56 | * @param string $wsdl The URL of the wsdl instance 57 | * @return string The filename used to cache the instance 58 | * @access private 59 | */ 60 | function createFilename($wsdl) { 61 | return $this->cache_dir.'/wsdlcache-' . md5($wsdl); 62 | } 63 | 64 | /** 65 | * adds debug data to the class level debug string 66 | * 67 | * @param string $string debug data 68 | * @access private 69 | */ 70 | function debug($string){ 71 | $this->debug_str .= get_class($this).": $string\n"; 72 | } 73 | 74 | /** 75 | * gets a wsdl instance from the cache 76 | * 77 | * @param string $wsdl The URL of the wsdl instance 78 | * @return object wsdl The cached wsdl instance, null if the instance is not in the cache 79 | * @access public 80 | */ 81 | function get($wsdl) { 82 | $filename = $this->createFilename($wsdl); 83 | if ($this->obtainMutex($filename, "r")) { 84 | // check for expired WSDL that must be removed from the cache 85 | if ($this->cache_lifetime > 0) { 86 | if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { 87 | unlink($filename); 88 | $this->debug("Expired $wsdl ($filename) from cache"); 89 | $this->releaseMutex($filename); 90 | return null; 91 | } 92 | } 93 | // see what there is to return 94 | if (!file_exists($filename)) { 95 | $this->debug("$wsdl ($filename) not in cache (1)"); 96 | $this->releaseMutex($filename); 97 | return null; 98 | } 99 | $fp = @fopen($filename, "r"); 100 | if ($fp) { 101 | $s = implode("", @file($filename)); 102 | fclose($fp); 103 | $this->debug("Got $wsdl ($filename) from cache"); 104 | } else { 105 | $s = null; 106 | $this->debug("$wsdl ($filename) not in cache (2)"); 107 | } 108 | $this->releaseMutex($filename); 109 | return (!is_null($s)) ? unserialize($s) : null; 110 | } else { 111 | $this->debug("Unable to obtain mutex for $filename in get"); 112 | } 113 | return null; 114 | } 115 | 116 | /** 117 | * obtains the local mutex 118 | * 119 | * @param string $filename The Filename of the Cache to lock 120 | * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode 121 | * @return boolean Lock successfully obtained ?! 122 | * @access private 123 | */ 124 | function obtainMutex($filename, $mode) { 125 | if (isset($this->fplock[md5($filename)])) { 126 | $this->debug("Lock for $filename already exists"); 127 | return false; 128 | } 129 | $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); 130 | if ($mode == "r") { 131 | return flock($this->fplock[md5($filename)], LOCK_SH); 132 | } else { 133 | return flock($this->fplock[md5($filename)], LOCK_EX); 134 | } 135 | } 136 | 137 | /** 138 | * adds a wsdl instance to the cache 139 | * 140 | * @param object wsdl $wsdl_instance The wsdl instance to add 141 | * @return boolean WSDL successfully cached 142 | * @access public 143 | */ 144 | function put($wsdl_instance) { 145 | $filename = $this->createFilename($wsdl_instance->wsdl); 146 | $s = serialize($wsdl_instance); 147 | if ($this->obtainMutex($filename, "w")) { 148 | $fp = fopen($filename, "w"); 149 | if (! $fp) { 150 | $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); 151 | $this->releaseMutex($filename); 152 | return false; 153 | } 154 | fputs($fp, $s); 155 | fclose($fp); 156 | $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); 157 | $this->releaseMutex($filename); 158 | return true; 159 | } else { 160 | $this->debug("Unable to obtain mutex for $filename in put"); 161 | } 162 | return false; 163 | } 164 | 165 | /** 166 | * releases the local mutex 167 | * 168 | * @param string $filename The Filename of the Cache to lock 169 | * @return boolean Lock successfully released 170 | * @access private 171 | */ 172 | function releaseMutex($filename) { 173 | $ret = flock($this->fplock[md5($filename)], LOCK_UN); 174 | fclose($this->fplock[md5($filename)]); 175 | unset($this->fplock[md5($filename)]); 176 | if (! $ret) { 177 | $this->debug("Not able to release lock for $filename"); 178 | } 179 | return $ret; 180 | } 181 | 182 | /** 183 | * removes a wsdl instance from the cache 184 | * 185 | * @param string $wsdl The URL of the wsdl instance 186 | * @return boolean Whether there was an instance to remove 187 | * @access public 188 | */ 189 | function remove($wsdl) { 190 | $filename = $this->createFilename($wsdl); 191 | if (!file_exists($filename)) { 192 | $this->debug("$wsdl ($filename) not in cache to be removed"); 193 | return false; 194 | } 195 | // ignore errors obtaining mutex 196 | $this->obtainMutex($filename, "w"); 197 | $ret = unlink($filename); 198 | $this->debug("Removed ($ret) $wsdl ($filename) from cache"); 199 | $this->releaseMutex($filename); 200 | return $ret; 201 | } 202 | } 203 | 204 | /** 205 | * For backward compatibility 206 | */ 207 | class wsdlcache extends nusoap_wsdlcache { 208 | } 209 | ?> 210 | -------------------------------------------------------------------------------- /lib/nusoapmime.php: -------------------------------------------------------------------------------- 1 | 50 | * @author Thanks to Guillaume and Henning Reich for posting great attachment code to the mail list 51 | * @version $Id: nusoapmime.php,v 1.13 2010/04/26 20:15:08 snichol Exp $ 52 | * @access public 53 | */ 54 | class nusoap_client_mime extends nusoap_client { 55 | /** 56 | * @var array Each array element in the return is an associative array with keys 57 | * data, filename, contenttype, cid 58 | * @access private 59 | */ 60 | var $requestAttachments = array(); 61 | /** 62 | * @var array Each array element in the return is an associative array with keys 63 | * data, filename, contenttype, cid 64 | * @access private 65 | */ 66 | var $responseAttachments; 67 | /** 68 | * @var string 69 | * @access private 70 | */ 71 | var $mimeContentType; 72 | 73 | /** 74 | * adds a MIME attachment to the current request. 75 | * 76 | * If the $data parameter contains an empty string, this method will read 77 | * the contents of the file named by the $filename parameter. 78 | * 79 | * If the $cid parameter is false, this method will generate the cid. 80 | * 81 | * @param string $data The data of the attachment 82 | * @param string $filename The filename of the attachment (default is empty string) 83 | * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) 84 | * @param string $cid The content-id (cid) of the attachment (default is false) 85 | * @return string The content-id (cid) of the attachment 86 | * @access public 87 | */ 88 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { 89 | if (! $cid) { 90 | $cid = md5(uniqid(time())); 91 | } 92 | 93 | $info['data'] = $data; 94 | $info['filename'] = $filename; 95 | $info['contenttype'] = $contenttype; 96 | $info['cid'] = $cid; 97 | 98 | $this->requestAttachments[] = $info; 99 | 100 | return $cid; 101 | } 102 | 103 | /** 104 | * clears the MIME attachments for the current request. 105 | * 106 | * @access public 107 | */ 108 | function clearAttachments() { 109 | $this->requestAttachments = array(); 110 | } 111 | 112 | /** 113 | * gets the MIME attachments from the current response. 114 | * 115 | * Each array element in the return is an associative array with keys 116 | * data, filename, contenttype, cid. These keys correspond to the parameters 117 | * for addAttachment. 118 | * 119 | * @return array The attachments. 120 | * @access public 121 | */ 122 | function getAttachments() { 123 | return $this->responseAttachments; 124 | } 125 | 126 | /** 127 | * gets the HTTP body for the current request. 128 | * 129 | * @param string $soapmsg The SOAP payload 130 | * @return string The HTTP body, which includes the SOAP payload 131 | * @access private 132 | */ 133 | function getHTTPBody($soapmsg) { 134 | if (count($this->requestAttachments) > 0) { 135 | $params['content_type'] = 'multipart/related; type="text/xml"'; 136 | $mimeMessage = new Mail_mimePart('', $params); 137 | unset($params); 138 | 139 | $params['content_type'] = 'text/xml'; 140 | $params['encoding'] = '8bit'; 141 | $params['charset'] = $this->soap_defencoding; 142 | $mimeMessage->addSubpart($soapmsg, $params); 143 | 144 | foreach ($this->requestAttachments as $att) { 145 | unset($params); 146 | 147 | $params['content_type'] = $att['contenttype']; 148 | $params['encoding'] = 'base64'; 149 | $params['disposition'] = 'attachment'; 150 | $params['dfilename'] = $att['filename']; 151 | $params['cid'] = $att['cid']; 152 | 153 | if ($att['data'] == '' && $att['filename'] <> '') { 154 | if ($fd = fopen($att['filename'], 'rb')) { 155 | $data = fread($fd, filesize($att['filename'])); 156 | fclose($fd); 157 | } else { 158 | $data = ''; 159 | } 160 | $mimeMessage->addSubpart($data, $params); 161 | } else { 162 | $mimeMessage->addSubpart($att['data'], $params); 163 | } 164 | } 165 | 166 | $output = $mimeMessage->encode(); 167 | $mimeHeaders = $output['headers']; 168 | 169 | foreach ($mimeHeaders as $k => $v) { 170 | $this->debug("MIME header $k: $v"); 171 | if (strtolower($k) == 'content-type') { 172 | // PHP header() seems to strip leading whitespace starting 173 | // the second line, so force everything to one line 174 | $this->mimeContentType = str_replace("\r\n", " ", $v); 175 | } 176 | } 177 | 178 | return $output['body']; 179 | } 180 | 181 | return parent::getHTTPBody($soapmsg); 182 | } 183 | 184 | /** 185 | * gets the HTTP content type for the current request. 186 | * 187 | * Note: getHTTPBody must be called before this. 188 | * 189 | * @return string the HTTP content type for the current request. 190 | * @access private 191 | */ 192 | function getHTTPContentType() { 193 | if (count($this->requestAttachments) > 0) { 194 | return $this->mimeContentType; 195 | } 196 | return parent::getHTTPContentType(); 197 | } 198 | 199 | /** 200 | * gets the HTTP content type charset for the current request. 201 | * returns false for non-text content types. 202 | * 203 | * Note: getHTTPBody must be called before this. 204 | * 205 | * @return string the HTTP content type charset for the current request. 206 | * @access private 207 | */ 208 | function getHTTPContentTypeCharset() { 209 | if (count($this->requestAttachments) > 0) { 210 | return false; 211 | } 212 | return parent::getHTTPContentTypeCharset(); 213 | } 214 | 215 | /** 216 | * processes SOAP message returned from server 217 | * 218 | * @param array $headers The HTTP headers 219 | * @param string $data unprocessed response data from server 220 | * @return mixed value of the message, decoded into a PHP type 221 | * @access private 222 | */ 223 | function parseResponse($headers, $data) { 224 | $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); 225 | $this->responseAttachments = array(); 226 | if (strstr($headers['content-type'], 'multipart/related')) { 227 | $this->debug('Decode multipart/related'); 228 | $input = ''; 229 | foreach ($headers as $k => $v) { 230 | $input .= "$k: $v\r\n"; 231 | } 232 | $params['input'] = $input . "\r\n" . $data; 233 | $params['include_bodies'] = true; 234 | $params['decode_bodies'] = true; 235 | $params['decode_headers'] = true; 236 | 237 | $structure = Mail_mimeDecode::decode($params); 238 | 239 | foreach ($structure->parts as $part) { 240 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) { 241 | $this->debug('Have root part of type ' . $part->headers['content-type']); 242 | $root = $part->body; 243 | $return = parent::parseResponse($part->headers, $part->body); 244 | } else { 245 | $this->debug('Have an attachment of type ' . $part->headers['content-type']); 246 | $info['data'] = $part->body; 247 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; 248 | $info['contenttype'] = $part->headers['content-type']; 249 | $info['cid'] = $part->headers['content-id']; 250 | $this->responseAttachments[] = $info; 251 | } 252 | } 253 | 254 | if (isset($return)) { 255 | $this->responseData = $root; 256 | return $return; 257 | } 258 | 259 | $this->setError('No root part found in multipart/related content'); 260 | return ''; 261 | } 262 | $this->debug('Not multipart/related'); 263 | return parent::parseResponse($headers, $data); 264 | } 265 | } 266 | 267 | /* 268 | * For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded. 269 | */ 270 | if (!extension_loaded('soap')) { 271 | class soapclientmime extends nusoap_client_mime { 272 | } 273 | } 274 | 275 | /** 276 | * nusoap_server_mime server supporting MIME attachments defined at 277 | * http://www.w3.org/TR/SOAP-attachments. It depends on the PEAR Mail_MIME library. 278 | * 279 | * @author Scott Nichol 280 | * @author Thanks to Guillaume and Henning Reich for posting great attachment code to the mail list 281 | * @version $Id: nusoapmime.php,v 1.13 2010/04/26 20:15:08 snichol Exp $ 282 | * @access public 283 | */ 284 | class nusoap_server_mime extends nusoap_server { 285 | /** 286 | * @var array Each array element in the return is an associative array with keys 287 | * data, filename, contenttype, cid 288 | * @access private 289 | */ 290 | var $requestAttachments = array(); 291 | /** 292 | * @var array Each array element in the return is an associative array with keys 293 | * data, filename, contenttype, cid 294 | * @access private 295 | */ 296 | var $responseAttachments; 297 | /** 298 | * @var string 299 | * @access private 300 | */ 301 | var $mimeContentType; 302 | 303 | /** 304 | * adds a MIME attachment to the current response. 305 | * 306 | * If the $data parameter contains an empty string, this method will read 307 | * the contents of the file named by the $filename parameter. 308 | * 309 | * If the $cid parameter is false, this method will generate the cid. 310 | * 311 | * @param string $data The data of the attachment 312 | * @param string $filename The filename of the attachment (default is empty string) 313 | * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) 314 | * @param string $cid The content-id (cid) of the attachment (default is false) 315 | * @return string The content-id (cid) of the attachment 316 | * @access public 317 | */ 318 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { 319 | if (! $cid) { 320 | $cid = md5(uniqid(time())); 321 | } 322 | 323 | $info['data'] = $data; 324 | $info['filename'] = $filename; 325 | $info['contenttype'] = $contenttype; 326 | $info['cid'] = $cid; 327 | 328 | $this->responseAttachments[] = $info; 329 | 330 | return $cid; 331 | } 332 | 333 | /** 334 | * clears the MIME attachments for the current response. 335 | * 336 | * @access public 337 | */ 338 | function clearAttachments() { 339 | $this->responseAttachments = array(); 340 | } 341 | 342 | /** 343 | * gets the MIME attachments from the current request. 344 | * 345 | * Each array element in the return is an associative array with keys 346 | * data, filename, contenttype, cid. These keys correspond to the parameters 347 | * for addAttachment. 348 | * 349 | * @return array The attachments. 350 | * @access public 351 | */ 352 | function getAttachments() { 353 | return $this->requestAttachments; 354 | } 355 | 356 | /** 357 | * gets the HTTP body for the current response. 358 | * 359 | * @param string $soapmsg The SOAP payload 360 | * @return string The HTTP body, which includes the SOAP payload 361 | * @access private 362 | */ 363 | function getHTTPBody($soapmsg) { 364 | if (count($this->responseAttachments) > 0) { 365 | $params['content_type'] = 'multipart/related; type="text/xml"'; 366 | $mimeMessage = new Mail_mimePart('', $params); 367 | unset($params); 368 | 369 | $params['content_type'] = 'text/xml'; 370 | $params['encoding'] = '8bit'; 371 | $params['charset'] = $this->soap_defencoding; 372 | $mimeMessage->addSubpart($soapmsg, $params); 373 | 374 | foreach ($this->responseAttachments as $att) { 375 | unset($params); 376 | 377 | $params['content_type'] = $att['contenttype']; 378 | $params['encoding'] = 'base64'; 379 | $params['disposition'] = 'attachment'; 380 | $params['dfilename'] = $att['filename']; 381 | $params['cid'] = $att['cid']; 382 | 383 | if ($att['data'] == '' && $att['filename'] <> '') { 384 | if ($fd = fopen($att['filename'], 'rb')) { 385 | $data = fread($fd, filesize($att['filename'])); 386 | fclose($fd); 387 | } else { 388 | $data = ''; 389 | } 390 | $mimeMessage->addSubpart($data, $params); 391 | } else { 392 | $mimeMessage->addSubpart($att['data'], $params); 393 | } 394 | } 395 | 396 | $output = $mimeMessage->encode(); 397 | $mimeHeaders = $output['headers']; 398 | 399 | foreach ($mimeHeaders as $k => $v) { 400 | $this->debug("MIME header $k: $v"); 401 | if (strtolower($k) == 'content-type') { 402 | // PHP header() seems to strip leading whitespace starting 403 | // the second line, so force everything to one line 404 | $this->mimeContentType = str_replace("\r\n", " ", $v); 405 | } 406 | } 407 | 408 | return $output['body']; 409 | } 410 | 411 | return parent::getHTTPBody($soapmsg); 412 | } 413 | 414 | /** 415 | * gets the HTTP content type for the current response. 416 | * 417 | * Note: getHTTPBody must be called before this. 418 | * 419 | * @return string the HTTP content type for the current response. 420 | * @access private 421 | */ 422 | function getHTTPContentType() { 423 | if (count($this->responseAttachments) > 0) { 424 | return $this->mimeContentType; 425 | } 426 | return parent::getHTTPContentType(); 427 | } 428 | 429 | /** 430 | * gets the HTTP content type charset for the current response. 431 | * returns false for non-text content types. 432 | * 433 | * Note: getHTTPBody must be called before this. 434 | * 435 | * @return string the HTTP content type charset for the current response. 436 | * @access private 437 | */ 438 | function getHTTPContentTypeCharset() { 439 | if (count($this->responseAttachments) > 0) { 440 | return false; 441 | } 442 | return parent::getHTTPContentTypeCharset(); 443 | } 444 | 445 | /** 446 | * processes SOAP message received from client 447 | * 448 | * @param array $headers The HTTP headers 449 | * @param string $data unprocessed request data from client 450 | * @return mixed value of the message, decoded into a PHP type 451 | * @access private 452 | */ 453 | function parseRequest($headers, $data) { 454 | $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); 455 | $this->requestAttachments = array(); 456 | if (strstr($headers['content-type'], 'multipart/related')) { 457 | $this->debug('Decode multipart/related'); 458 | $input = ''; 459 | foreach ($headers as $k => $v) { 460 | $input .= "$k: $v\r\n"; 461 | } 462 | $params['input'] = $input . "\r\n" . $data; 463 | $params['include_bodies'] = true; 464 | $params['decode_bodies'] = true; 465 | $params['decode_headers'] = true; 466 | 467 | $structure = Mail_mimeDecode::decode($params); 468 | 469 | foreach ($structure->parts as $part) { 470 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) { 471 | $this->debug('Have root part of type ' . $part->headers['content-type']); 472 | $return = parent::parseRequest($part->headers, $part->body); 473 | } else { 474 | $this->debug('Have an attachment of type ' . $part->headers['content-type']); 475 | $info['data'] = $part->body; 476 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; 477 | $info['contenttype'] = $part->headers['content-type']; 478 | $info['cid'] = $part->headers['content-id']; 479 | $this->requestAttachments[] = $info; 480 | } 481 | } 482 | 483 | if (isset($return)) { 484 | return $return; 485 | } 486 | 487 | $this->setError('No root part found in multipart/related content'); 488 | return; 489 | } 490 | $this->debug('Not multipart/related'); 491 | return parent::parseRequest($headers, $data); 492 | } 493 | } 494 | 495 | /* 496 | * For backwards compatiblity 497 | */ 498 | class nusoapservermime extends nusoap_server_mime { 499 | } 500 | 501 | ?> 502 | -------------------------------------------------------------------------------- /samples/client1.php: -------------------------------------------------------------------------------- 1 | getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 24 | exit(); 25 | } 26 | $client->setUseCurl($useCURL); 27 | // This is an archaic parameter list 28 | $params = array( 29 | 'manufacturer' => "O'Reilly", 30 | 'page' => '1', 31 | 'mode' => 'books', 32 | 'tag' => 'trachtenberg-20', 33 | 'type' => 'lite', 34 | 'devtag' => 'Your tag here', 35 | 'sort' => '+title' 36 | ); 37 | $result = $client->call('ManufacturerSearchRequest', $params, 'http://soap.amazon.com', 'http://soap.amazon.com'); 38 | if ($client->fault) { 39 | echo '

Fault (Expect - The request contains an invalid SOAP body)

'; print_r($result); echo '
'; 40 | } else { 41 | $err = $client->getError(); 42 | if ($err) { 43 | echo '

Error

' . $err . '
'; 44 | } else { 45 | echo '

Result

'; print_r($result); echo '
'; 46 | } 47 | } 48 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 49 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 50 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 51 | ?> 52 | -------------------------------------------------------------------------------- /samples/client2.php: -------------------------------------------------------------------------------- 1 | getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 24 | exit(); 25 | } 26 | $client->setUseCurl($useCURL); 27 | $client->useHTTPPersistentConnection(); 28 | $param = array( 29 | 'manufacturer' => "O'Reilly", 30 | 'page' => '1', 31 | 'mode' => 'books', 32 | 'tag' => 'trachtenberg-20', 33 | 'type' => 'lite', 34 | 'devtag' => 'Your tag here' 35 | ); 36 | $params = array('ManufacturerSearchRequest' => 37 | new soapval('ManufacturerSearchRequest', 38 | 'ManufacturerRequest', 39 | $param, 40 | false, 41 | 'http://soap.amazon.com') 42 | ); 43 | $result = $client->call('ManufacturerSearchRequest', $params, 'http://soap.amazon.com', 'http://soap.amazon.com'); 44 | if ($client->fault) { 45 | echo '

Fault

'; print_r($result); echo '
'; 46 | } else { 47 | $err = $client->getError(); 48 | if ($err) { 49 | echo '

Error

' . $err . '
'; 50 | } else { 51 | echo '

Result

'; print_r($result); echo '
'; 52 | } 53 | } 54 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 55 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 56 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 57 | ?> 58 | -------------------------------------------------------------------------------- /samples/client3.php: -------------------------------------------------------------------------------- 1 | getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 24 | exit(); 25 | } 26 | $client->setUseCurl($useCURL); 27 | $client->soap_defencoding = 'UTF-8'; 28 | 29 | //echo 'You must set your own Google key in the source code to run this client!'; exit(); 30 | $params = array( 31 | 'Googlekey'=>'Your Google key', 32 | 'queryStr'=>'robotics', 33 | 'startFrom'=>0, 34 | 'maxResults'=>10, 35 | 'filter'=>true, 36 | 'restrict'=>'', 37 | 'adultContent'=>true, 38 | 'language'=>'', 39 | 'iencoding'=>'', 40 | 'oendcoding'=>'' 41 | ); 42 | $result = $client->call("doGoogleSearch", $params, "urn:GoogleSearch", "urn:GoogleSearch"); 43 | if ($client->fault) { 44 | echo '

Fault

'; print_r($result); echo '
'; 45 | } else { 46 | $err = $client->getError(); 47 | if ($err) { 48 | echo '

Error

' . $err . '
'; 49 | } else { 50 | echo '

Result

'; print_r($result); echo '
'; 51 | } 52 | } 53 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 54 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 55 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 56 | ?> 57 | -------------------------------------------------------------------------------- /samples/getfile1client.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | $result = $client->call('getFile', array('filename' => 'getfile1.php')); 24 | if ($client->fault) { 25 | echo '

Fault

'; print_r($result); echo '
'; 26 | } else { 27 | $err = $client->getError(); 28 | if ($err) { 29 | echo '

Error

' . $err . '
'; 30 | } else { 31 | echo '

Result

' . htmlspecialchars($result, ENT_QUOTES) . '
'; 32 | } 33 | } 34 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 35 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 36 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 37 | ?> 38 | -------------------------------------------------------------------------------- /samples/getfile2client.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | $result = $client->call('getFile', array('filename' => 'getfile2.php')); 24 | if ($client->fault) { 25 | echo '

Fault

'; print_r($result); echo '
'; 26 | } else { 27 | $err = $client->getError(); 28 | if ($err) { 29 | echo '

Error

' . $err . '
'; 30 | } else { 31 | echo '

Result

' . htmlspecialchars($result, ENT_QUOTES) . '
'; 32 | } 33 | } 34 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 35 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 36 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 37 | ?> 38 | -------------------------------------------------------------------------------- /samples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | NuSOAP Samples 7 | 13 | 14 | 15 |

NuSOAP Samples

16 |

17 | These links allow you to launch sample clients. As of 26 April 2010, most of the links to commercial services no longer work. 18 |

19 |
20 | Amazon endpoint (Fault expected)
21 | Amazon endpoint
22 | Google endpoint (you must have a key)
23 | MIME Attachment
24 | SSL endpoint
25 | Stock quote WSDL
26 | Amazon WSDL
27 | Hello WSDL (PHP function)
28 | Hello WSDL (PHP instance method)
29 | Hello WSDL (PHP class method)
30 | Hello WSDL with pre-formed parameter XML
31 | Hello WSDL (rpc/literal version)
32 | Interop WSDL
33 | Price quote WSDL (uses wsdlcache)
34 | Google WSDL (you must have WSDL file local)
35 | MapPoint WSDL #1 (you must have a username/password)
36 | MapPoint WSDL #2 (you must have a username/password)
37 | MapPoint WSDL #3 (you must have a username/password)
38 | Country list WSDL
39 | Hello WSDL (document/literal version)
40 | Amazon E-Commerce Service (ItemLookup by node)
41 | Amazon E-Commerce Service (ItemSearch by node)
42 | Amazon E-Commerce Service (ItemSearch by keyword)
43 | Amazon E-Commerce Service (ListLookup)
44 | Amazon E-Commerce Service (ListSearch)
45 | Amazon E-Commerce Service (CartCreate)
46 | Maintain a Session
47 | Via Michelin
48 | UTF-8 Character Encoding
49 | Get a file #1 (uses base64Binary)
50 | Get a file #2 (uses base64Binary; service uses external WSDL file)
51 |
52 | 53 | 54 |
Use cURL?
55 |

56 | If you access the Internet through a proxy, provide the proxy 57 | information below. 58 |

59 | 60 | 61 | 62 | 63 | 64 |
Proxy Host:
Proxy Port:
Proxy Username:
Proxy Password:
65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /samples/mimeclient.php: -------------------------------------------------------------------------------- 1 | getError(); 22 | if ($err) { 23 | echo '

Constructor error

' . $err . '
'; 24 | } 25 | $client->setUseCurl($useCURL); 26 | $client->setHTTPEncoding('deflate, gzip'); 27 | $cid = $client->addAttachment('', 'mimeclient.php'); 28 | $result = $client->call('hello', array('name' => 'Scott')); 29 | if ($client->fault) { 30 | echo '

Fault

'; print_r($result); echo '
'; 31 | } else { 32 | $err = $client->getError(); 33 | if ($err) { 34 | echo '

Error

' . $err . '
'; 35 | } else { 36 | echo '

Result

'; print_r($result); echo '
'; 37 | echo '

Attachments

';
38 | 		$attachments = $client->getAttachments();
39 | 		foreach ($attachments as $a) {
40 | 			echo 'Filename: ' . $a['filename'] . "\r\n";
41 | 			echo 'Content-Type: ' . $a['contenttype'] . "\r\n";
42 | 			echo 'cid: ' . htmlspecialchars($a['cid'], ENT_QUOTES) . "\r\n";
43 | 			echo htmlspecialchars($a['data'], ENT_QUOTES);
44 | 			echo "\r\n";
45 | 		}
46 | 		echo '
'; 47 | } 48 | } 49 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 50 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 51 | echo '

ResponseData

' . htmlspecialchars($client->responseData, ENT_QUOTES) . '
'; 52 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 53 | ?> 54 | -------------------------------------------------------------------------------- /samples/sslclient.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | $result = $client->call('getVersion', array(), 'http://arcweb.esri.com/v2', 'getVersion'); 24 | if ($client->fault) { 25 | echo '

Fault

'; print_r($result); echo '
'; 26 | } else { 27 | $err = $client->getError(); 28 | if ($err) { 29 | echo '

Error

' . $err . '
'; 30 | } else { 31 | echo '

Result

'; print_r($result); echo '
'; 32 | } 33 | } 34 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 35 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 36 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 37 | ?> 38 | -------------------------------------------------------------------------------- /samples/wsdlclient1.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | // Doc/lit parameters get wrapped 24 | $param = array('Symbol' => 'IBM'); 25 | $result = $client->call('GetQuickQuotes', array('parameters' => $param), '', '', false, true); 26 | // Check for a fault 27 | if ($client->fault) { 28 | echo '

Fault

';
29 | 	print_r($result);
30 | 	echo '
'; 31 | } else { 32 | // Check for errors 33 | $err = $client->getError(); 34 | if ($err) { 35 | // Display the error 36 | echo '

Error

' . $err . '
'; 37 | } else { 38 | // Display the result 39 | echo '

Result

';
40 | 		print_r($result);
41 | 		echo '
'; 42 | } 43 | } 44 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 45 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 46 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 47 | ?> 48 | -------------------------------------------------------------------------------- /samples/wsdlclient10.php: -------------------------------------------------------------------------------- 1 | getError(); 22 | if ($err) { 23 | echo '

Constructor error

' . $err . '
'; 24 | } 25 | $client->setUseCurl($useCURL); 26 | $result = $client->call('getCountries', array(), '', '', false, true); 27 | if ($client->fault) { 28 | echo '

Fault

';
29 | 	print_r($result);
30 | 	echo '
'; 31 | } else { 32 | $err = $client->getError(); 33 | if ($err) { 34 | echo '

Error

' . $err . '
'; 35 | } else { 36 | echo '

Result

';
37 | 		print_r($result);
38 | 		echo '
'; 39 | } 40 | } 41 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 42 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 43 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 44 | ?> 45 | -------------------------------------------------------------------------------- /samples/wsdlclient11.php: -------------------------------------------------------------------------------- 1 | getError(); 23 | if ($err) { 24 | echo '

Constructor error

' . $err . '
'; 25 | } 26 | $client->setUseCurl($useCURL); 27 | $person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male'); 28 | $name = array('name' => $person); 29 | $result = $client->call('hello', $name); 30 | if ($client->fault) { 31 | echo '

Fault

';
32 | 	print_r($result);
33 | 	echo '
'; 34 | } else { 35 | $err = $client->getError(); 36 | if ($err) { 37 | echo '

Error

' . $err . '
'; 38 | } else { 39 | echo '

Result

';
40 | 		print_r($result);
41 | 	echo '
'; 42 | } 43 | } 44 | echo '

Request

'; 45 | echo '
' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 46 | echo '

Response

'; 47 | echo '
' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 48 | echo '

Debug

'; 49 | echo '
' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 50 | ?> 51 | -------------------------------------------------------------------------------- /samples/wsdlclient12.php: -------------------------------------------------------------------------------- 1 | get($wsdlurl); 26 | if (is_null($wsdl)) { 27 | $wsdl = new wsdl($wsdlurl, 28 | $proxyhost, $proxyport, $proxyusername, $proxypassword); 29 | $cache->put($wsdl); 30 | } else { 31 | $wsdl->debug_str = ''; 32 | $wsdl->debug('Retrieved from cache'); 33 | } 34 | $client = new nusoap_client($wsdl, true, 35 | $proxyhost, $proxyport, $proxyusername, $proxypassword); 36 | $err = $client->getError(); 37 | if ($err) { 38 | echo '

Constructor error

' . $err . '
'; 39 | } 40 | 41 | $client->soap_defencoding = 'UTF-8'; 42 | 43 | function GetCartCreateParams() { 44 | global $SubscriptionId; 45 | 46 | // create items to be added to the cart 47 | $item = array (); 48 | $item[0] = array( "ASIN" => "0596004206", 49 | "Quantity" => "1" 50 | ); 51 | $item[1] = array( "ASIN" => "0596003277", 52 | "Quantity" => "2" 53 | ); 54 | 55 | // pack it to array 56 | $items = array("Item" => $item); 57 | // Construct request parameters 58 | $request = array("Items" => $items, "ResponseGroup" => "CartSimilarities"); 59 | 60 | // Construct all parameters 61 | $cartCreate = array( "SubscriptionId" => $SubscriptionId, 62 | "Request" => $request 63 | ); 64 | 65 | return $cartCreate; 66 | } 67 | 68 | function GetItemLookupParams() { 69 | global $SubscriptionId; 70 | 71 | $itemLookupRequest[] = array( 72 | 'ItemId' => 'B0002IQML6', 73 | 'IdType' => 'ASIN', 74 | 'Condition' => 'All', 75 | 'ResponseGroup' => 'Large' 76 | ); 77 | 78 | $itemLookupRequest[] = array( 79 | 'ItemId' => '0486411214', 80 | 'IdType' => 'ASIN', 81 | 'Condition' => 'New', 82 | 'ResponseGroup' => 'Small' 83 | ); 84 | 85 | $itemLookup = array( 86 | 'SubscriptionId' => $SubscriptionId, 87 | // 'AssociateTag' => '', 88 | 'Request' => $itemLookupRequest, 89 | ); 90 | 91 | return $itemLookup; 92 | } 93 | 94 | function GetItemSearchParams() { 95 | global $SubscriptionId; 96 | 97 | $itemSearchRequest = array( 98 | 'BrowseNode' => '53', 99 | 'ItemPage' => 1, 100 | // 'ResponseGroup' => array('Request', 'Small'), 101 | 'SearchIndex' => 'Books', 102 | 'Sort' => 'salesrank' 103 | ); 104 | 105 | $itemSearch = array( 106 | 'SubscriptionId' => $SubscriptionId, 107 | // 'AssociateTag' => '', 108 | // 'Validate' => '', 109 | // 'XMLEscaping' => '', 110 | // 'Shared' => $itemSearchRequest, 111 | 'Request' => array($itemSearchRequest) 112 | ); 113 | 114 | return $itemSearch; 115 | } 116 | 117 | function GetItemSearchParams2() { 118 | global $SubscriptionId; 119 | 120 | $request = array( 121 | "Keywords" => "postal stamps", 122 | "SearchIndex" => "Books" 123 | ); 124 | 125 | $itemSearch = array( 126 | 'SubscriptionId' => $SubscriptionId, 127 | 'Request' => $request 128 | ); 129 | 130 | return $itemSearch; 131 | } 132 | 133 | function GetListLookupParams() { 134 | global $SubscriptionId; 135 | 136 | $listLookupRequest[] = array( 137 | 'ListId' => '1L0ZL7Y9FL4U0', 138 | 'ListType' => 'WishList', 139 | 'ProductPage' => 1, 140 | 'ResponseGroup' => 'ListFull', 141 | 'Sort' => 'LastUpdated' 142 | ); 143 | 144 | $listLookupRequest[] = array( 145 | 'ListId' => '1L0ZL7Y9FL4U0', 146 | 'ListType' => 'WishList', 147 | 'ProductPage' => 2, 148 | 'ResponseGroup' => 'ListFull', 149 | 'Sort' => 'LastUpdated' 150 | ); 151 | /* 152 | // two lookup maximum 153 | $listLookupRequest[] = array( 154 | 'ListId' => '1L0ZL7Y9FL4U0', 155 | 'ListType' => 'WishList', 156 | 'ProductPage' => 3, 157 | 'ResponseGroup' => 'ListFull', 158 | 'Sort' => 'LastUpdated' 159 | ); 160 | */ 161 | $listLookup = array( 162 | 'SubscriptionId' => $SubscriptionId, 163 | // 'AssociateTag' => '', 164 | 'Request' => $listLookupRequest, 165 | ); 166 | 167 | return $listLookup; 168 | } 169 | 170 | function GetListSearchParams() { 171 | global $SubscriptionId; 172 | 173 | $listSearchRequest[] = array( 174 | 'FirstName' => 'Scott', 175 | 'LastName' => 'Nichol', 176 | 'ListType' => 'WishList' 177 | ); 178 | 179 | $listSearch = array( 180 | 'SubscriptionId' => $SubscriptionId, 181 | // 'AssociateTag' => '', 182 | 'Request' => $listSearchRequest, 183 | ); 184 | 185 | return $listSearch; 186 | } 187 | 188 | if ($method == 'ItemLookup') { 189 | $result = $client->call('ItemLookup', array('body' => GetItemLookupParams())); 190 | } elseif ($method == 'ItemSearch') { 191 | $result = $client->call('ItemSearch', array('body' => GetItemSearchParams())); 192 | } elseif ($method == 'ItemSearch2') { 193 | $result = $client->call('ItemSearch', array('body' => GetItemSearchParams2())); 194 | } elseif ($method == 'ListLookup') { 195 | $result = $client->call('ListLookup', array('body' => GetListLookupParams())); 196 | } elseif ($method == 'ListSearch') { 197 | $result = $client->call('ListSearch', array('body' => GetListSearchParams())); 198 | } elseif ($method == 'CartCreate') { 199 | $result = $client->call('CartCreate', array('body' => GetCartCreateParams())); 200 | } else { 201 | echo "Unsupported method $method"; 202 | exit; 203 | } 204 | // Check for a fault 205 | if ($client->fault) { 206 | echo '

Fault

';
207 | 	print_r($result);
208 | 	echo '
'; 209 | } else { 210 | // Check for errors 211 | $err = $client->getError(); 212 | if ($err) { 213 | // Display the error 214 | echo '

Error

' . $err . '
'; 215 | } else { 216 | // Display the result 217 | echo '

Result

';
218 | 		print_r($result);
219 | 		echo '
'; 220 | } 221 | } 222 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 223 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 224 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 225 | ?> 226 | -------------------------------------------------------------------------------- /samples/wsdlclient13.php: -------------------------------------------------------------------------------- 1 | Constructor'; 18 | $client = new nusoap_client('http://www.scottnichol.com/samples/session.php?wsdl', true, 19 | $proxyhost, $proxyport, $proxyusername, $proxypassword); 20 | $err = $client->getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | } 24 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 25 | $client->clearDebug(); 26 | // A persistent connection is *optional*, *not* necessary 27 | $client->useHTTPPersistentConnection(); 28 | echo '

GetSessionID

'; 29 | $result = $client->call('GetSessionID', array()); 30 | // Check for a fault 31 | if ($client->fault) { 32 | echo '

Fault

';
 33 | 	print_r($result);
 34 | 	echo '
'; 35 | } else { 36 | // Check for errors 37 | $err = $client->getError(); 38 | if ($err) { 39 | // Display the error 40 | echo '

Error

' . $err . '
'; 41 | } else { 42 | // Display the result 43 | echo '

Result

';
 44 | 		print_r($result);
 45 | 		echo '
'; 46 | } 47 | } 48 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 49 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 50 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 51 | $client->clearDebug(); 52 | echo '

SetSession

'; 53 | $result = $client->call('SetSession', array('name' => 'testvalue', 'value' => 'it works')); 54 | // Check for a fault 55 | if ($client->fault) { 56 | echo '

Fault

';
 57 | 	print_r($result);
 58 | 	echo '
'; 59 | } else { 60 | // Check for errors 61 | $err = $client->getError(); 62 | if ($err) { 63 | // Display the error 64 | echo '

Error

' . $err . '
'; 65 | } else { 66 | // Display the result 67 | echo '

Result

';
 68 | 		print_r($result);
 69 | 		echo '
'; 70 | } 71 | } 72 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 73 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 74 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 75 | $client->clearDebug(); 76 | echo '

GetSession

'; 77 | $result = $client->call('GetSession', array('name' => 'testvalue')); 78 | // Check for a fault 79 | if ($client->fault) { 80 | echo '

Fault

';
 81 | 	print_r($result);
 82 | 	echo '
'; 83 | } else { 84 | // Check for errors 85 | $err = $client->getError(); 86 | if ($err) { 87 | // Display the error 88 | echo '

Error

' . $err . '
'; 89 | } else { 90 | // Display the result 91 | echo '

Result

';
 92 | 		print_r($result);
 93 | 		echo '
'; 94 | } 95 | } 96 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 97 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 98 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 99 | ?> 100 | -------------------------------------------------------------------------------- /samples/wsdlclient14.php: -------------------------------------------------------------------------------- 1 | get($wsdlurl); 27 | if (is_null($wsdl)) { 28 | $wsdl = new wsdl($wsdlurl, 29 | $proxyhost, $proxyport, $proxyusername, $proxypassword, 30 | 0, 30, null, $useCURL); 31 | $err = $wsdl->getError(); 32 | if ($err) { 33 | echo '

WSDL Constructor error

' . $err . '
'; 34 | echo '

Debug

' . htmlspecialchars($wsdl->getDebug(), ENT_QUOTES) . '
'; 35 | exit(); 36 | } 37 | $cache->put($wsdl); 38 | } else { 39 | $wsdl->debug_str = ''; 40 | $wsdl->debug('Retrieved from cache'); 41 | } 42 | $client = new nusoap_client($wsdl, 'wsdl', 43 | $proxyhost, $proxyport, $proxyusername, $proxypassword); 44 | $err = $client->getError(); 45 | if ($err) { 46 | echo '

Constructor error

' . $err . '
'; 47 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 48 | exit(); 49 | } 50 | 51 | $inputAddresses[] = array( 52 | 'address' => '45 Liberty Blvd.', 53 | 'cityName' => 'Malvern', 54 | 'countryCode' => 'USA', 55 | 'postalCode' => '19355', 56 | 'stateName' => 'PA' 57 | ); 58 | $geocodingrequest = array('addressesList' => $inputAddresses); 59 | $params = array('request' => $geocodingrequest, 'check' => "$login|$password"); 60 | $result = $client->call('getLocationsList', $params); 61 | 62 | // Check for a fault 63 | if ($client->fault) { 64 | echo '

Fault (Expect - AUTHENTIFICATION)

';
65 | 	print_r($result);
66 | 	echo '
'; 67 | } else { 68 | // Check for errors 69 | $err = $client->getError(); 70 | if ($err) { 71 | // Display the error 72 | echo '

Error

' . $err . '
'; 73 | } else { 74 | // Display the result 75 | echo '

Result

';
76 | 		print_r($result);
77 | 		echo '
'; 78 | } 79 | } 80 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 81 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 82 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 83 | ?> 84 | -------------------------------------------------------------------------------- /samples/wsdlclient15.php: -------------------------------------------------------------------------------- 1 | getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | echo '

Debug

'; 24 | echo '
' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 25 | exit(); 26 | } 27 | $client->setUseCurl($useCURL); 28 | $client->soap_defencoding = 'UTF-8'; 29 | $client->decode_utf8 = false; 30 | $utf8string = array('stuff' => "\xc2\xa9\xc2\xae\xc2\xbc\xc2\xbd\xc2\xbe"); 31 | $result = $client->call('echoback', $utf8string); 32 | if ($client->fault) { 33 | echo '

Fault

';
34 | 	print_r($result);
35 | 	echo '
'; 36 | } else { 37 | $err = $client->getError(); 38 | if ($err) { 39 | echo '

Error

' . $err . '
'; 40 | } else { 41 | echo '

Result

';
42 | 		// Decode the result: it so happens we sent Latin-1 characters
43 | 		if (isset($result['return'])) {
44 | 			$result1 = utf8_decode($result['return']);
45 | 		} elseif (!is_array($result)) {
46 | 			$result1 = utf8_decode($result);
47 | 		} else {
48 | 			$result1 = $result;
49 | 		}
50 | 		print_r($result1);
51 | 		echo '
'; 52 | } 53 | } 54 | echo '

Request

'; 55 | echo '
' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 56 | echo '

Response

'; 57 | echo '
' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 58 | echo '

Debug

'; 59 | echo '
' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 60 | ?> 61 | -------------------------------------------------------------------------------- /samples/wsdlclient2.php: -------------------------------------------------------------------------------- 1 | getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | exit(); 24 | } 25 | $client->setUseCurl($useCURL); 26 | $proxy = $client->getProxy(); 27 | $param = array( 28 | 'browse_node' => 18, 29 | 'page' => 1, 30 | 'mode' => 'books', 31 | 'tag' =>'melonfire-20', 32 | 'type' => 'lite', 33 | 'devtag' => 'Your dev tag' 34 | ); 35 | $result = $proxy->BrowseNodeSearchRequest($param); 36 | // Check for a fault 37 | if ($proxy->fault) { 38 | echo '

Fault

';
39 | 	print_r($result);
40 | 	echo '
'; 41 | } else { 42 | // Check for errors 43 | $err = $proxy->getError(); 44 | if ($err) { 45 | // Display the error 46 | echo '

Error

' . $err . '
'; 47 | } else { 48 | // Display the result 49 | echo '

Result

';
50 | 		print_r($result);
51 | 		echo '
'; 52 | } 53 | } 54 | echo '

Request

' . htmlspecialchars($proxy->request, ENT_QUOTES) . '
'; 55 | echo '

Response

' . htmlspecialchars($proxy->response, ENT_QUOTES) . '
'; 56 | echo '

Client Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 57 | echo '

Proxy Debug

' . htmlspecialchars($proxy->debug_str, ENT_QUOTES) . '
'; 58 | ?> 59 | -------------------------------------------------------------------------------- /samples/wsdlclient3.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | $person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male'); 24 | $method = isset($_GET['method']) ? $_GET['method'] : 'function'; 25 | if ($method == 'function') { 26 | $call = 'hello'; 27 | } elseif ($method == 'instance') { 28 | $call = 'hellowsdl2.hello'; 29 | } elseif ($method == 'class') { 30 | $call = 'hellowsdl2..hello'; 31 | } else { 32 | $call = 'hello'; 33 | } 34 | $result = $client->call($call, array('person' => $person)); 35 | // Check for a fault 36 | if ($client->fault) { 37 | echo '

Fault

';
38 | 	print_r($result);
39 | 	echo '
'; 40 | } else { 41 | // Check for errors 42 | $err = $client->getError(); 43 | if ($err) { 44 | // Display the error 45 | echo '

Error

' . $err . '
'; 46 | } else { 47 | // Display the result 48 | echo '

Result

';
49 | 		print_r($result);
50 | 		echo '
'; 51 | } 52 | } 53 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 54 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 55 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 56 | ?> 57 | -------------------------------------------------------------------------------- /samples/wsdlclient3b.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | $params = 'Willi22male'; 24 | $result = $client->call('hello', $params); 25 | // Check for a fault 26 | if ($client->fault) { 27 | echo '

Fault

';
28 | 	print_r($result);
29 | 	echo '
'; 30 | } else { 31 | // Check for errors 32 | $err = $client->getError(); 33 | if ($err) { 34 | // Display the error 35 | echo '

Error

' . $err . '
'; 36 | } else { 37 | // Display the result 38 | echo '

Result

';
39 | 		print_r($result);
40 | 		echo '
'; 41 | } 42 | } 43 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 44 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 45 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 46 | ?> 47 | -------------------------------------------------------------------------------- /samples/wsdlclient3c.php: -------------------------------------------------------------------------------- 1 | getError(); 20 | if ($err) { 21 | echo '

Constructor error

' . $err . '
'; 22 | } 23 | $person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male'); 24 | $result = $client->call('hello', array('person' => $person)); 25 | // Check for a fault 26 | if ($client->fault) { 27 | echo '

Fault

';
28 | 	print_r($result);
29 | 	echo '
'; 30 | } else { 31 | // Check for errors 32 | $err = $client->getError(); 33 | if ($err) { 34 | // Display the error 35 | echo '

Error

' . $err . '
'; 36 | } else { 37 | // Display the result 38 | echo '

Result

';
39 | 		print_r($result);
40 | 		echo '
'; 41 | } 42 | } 43 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 44 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 45 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 46 | ?> 47 | -------------------------------------------------------------------------------- /samples/wsdlclient4.php: -------------------------------------------------------------------------------- 1 | '; 28 | echo ''; 29 | echo ''; 30 | echo ''; 31 | echo ''; 32 | echo 'Method:

'; 45 | echo 'Null parameter?
'; 46 | echo 'Empty array?

'; 47 | echo ''; 48 | echo ''; 49 | exit(); 50 | } 51 | /* 52 | * Execute the specified method 53 | */ 54 | if ($method == 'echoString') { 55 | if ($null != '1') { 56 | $params = array('inputString' => 'If you cannot echo a string, you probably cannot do much'); 57 | } else { 58 | $params = array('inputString' => null); 59 | } 60 | } elseif ($method == 'echoStringArray') { 61 | if ($null != '1') { 62 | if ($empty != '1') { 63 | $params = array('inputStringArray' => array('String 1', 'String 2', 'String Three')); 64 | } else { 65 | $params = array('inputStringArray' => array()); 66 | } 67 | } else { 68 | $params = array('inputStringArray' => null); 69 | } 70 | } elseif ($method == 'echoInteger') { 71 | if ($null != '1') { 72 | $params = array('inputInteger' => 329); 73 | } else { 74 | $params = array('inputInteger' => null); 75 | } 76 | } elseif ($method == 'echoIntegerArray') { 77 | if ($null != '1') { 78 | if ($empty != '1') { 79 | $params = array('inputIntegerArray' => array(451, 43, -392220011, 1, 1, 2, 3, 5, 8, 13, 21)); 80 | } else { 81 | $params = array('inputIntegerArray' => array()); 82 | } 83 | } else { 84 | $params = array('inputIntegerArray' => null); 85 | } 86 | } elseif ($method == 'echoFloat') { 87 | if ($null != '1') { 88 | $params = array('inputFloat' => 3.14159265); 89 | } else { 90 | $params = array('inputFloat' => null); 91 | } 92 | } elseif ($method == 'echoFloatArray') { 93 | if ($null != '1') { 94 | if ($empty != '1') { 95 | $params = array('inputFloatArray' => array(1.1, 2.2, 3.3, 1/4, -1/9)); 96 | } else { 97 | $params = array('inputFloatArray' => array()); 98 | } 99 | } else { 100 | $params = array('inputFloatArray' => null); 101 | } 102 | } elseif ($method == 'echoStruct') { 103 | if ($null != '1') { 104 | $struct = array('varString' => 'who', 'varInt' => 2, 'varFloat' => 3.14159); 105 | $params = array('inputStruct' => $struct); 106 | } else { 107 | $params = array('inputStruct' => null); 108 | } 109 | } elseif ($method == 'echoStructArray') { 110 | if ($null != '1') { 111 | if ($empty != '1') { 112 | $structs[] = array('varString' => 'who', 'varInt' => 2, 'varFloat' => 3.14159); 113 | $structs[] = array('varString' => 'when', 'varInt' => 4, 'varFloat' => 99.9876); 114 | $params = array('inputStructArray' => $structs); 115 | } else { 116 | $params = array('inputStructArray' => array()); 117 | } 118 | } else { 119 | $params = array('inputStructArray' => null); 120 | } 121 | } elseif ($method == 'echoVoid') { 122 | $params = array(); 123 | } elseif ($method == 'echoBoolean') { 124 | if ($null != '1') { 125 | $params = array('inputBoolean' => false); 126 | } else { 127 | $params = array('inputBoolean' => null); 128 | } 129 | } elseif ($method == 'echoBase64') { 130 | if ($null != '1') { 131 | $params = array('inputBase64' => base64_encode('You must encode the data you send; NuSOAP will automatically decode the data it receives')); 132 | } else { 133 | $params = array('inputBase64' => null); 134 | } 135 | } else { 136 | echo 'Sorry, I do not know about method ' . $method; 137 | exit(); 138 | } 139 | $client = new soapclient('http://www.scottnichol.com/samples/round2_base_server.php?wsdl&debug=1', true, 140 | $proxyhost, $proxyport, $proxyusername, $proxypassword); 141 | $err = $client->getError(); 142 | if ($err) { 143 | echo '

Constructor error

' . $err . '
'; 144 | } 145 | $client->useHTTPPersistentConnection(); 146 | echo '

Execute ' . $method . '

'; 147 | $result = $client->call($method, $params); 148 | // Check for a fault 149 | if ($client->fault) { 150 | echo '

Fault

';
151 | 	print_r($result);
152 | 	echo '
'; 153 | } else { 154 | // Check for errors 155 | $err = $client->getError(); 156 | if ($err) { 157 | // Display the error 158 | echo '

Error

' . $err . '
'; 159 | } else { 160 | // Display the result 161 | echo '

Result

';
162 | 		print_r((!is_bool($result)) ? $result : ($result ? 'true' : 'false'));
163 | 		echo '
'; 164 | // And execute again to test persistent connection 165 | echo '

Execute ' . $method . ' again to test persistent connection (see debug)

'; 166 | $client->debug("*** execute again to test persistent connection ***"); 167 | $result = $client->call($method, $params); 168 | // And again... 169 | $client->debug("*** execute again ... ***"); 170 | $result = $client->call($method, $params); 171 | } 172 | } 173 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 174 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 175 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 176 | ?> 177 | -------------------------------------------------------------------------------- /samples/wsdlclient5.php: -------------------------------------------------------------------------------- 1 | get('http://www.xmethods.net/sd/2001/BNQuoteService.wsdl'); 22 | if (is_null($wsdl)) { 23 | $wsdl = new wsdl('http://www.xmethods.net/sd/2001/BNQuoteService.wsdl', 24 | $proxyhost, $proxyport, $proxyusername, $proxypassword, 25 | 0, 30, null, $useCURL); 26 | $err = $wsdl->getError(); 27 | if ($err) { 28 | echo '

WSDL Constructor error (Expect - 404 Not Found)

' . $err . '
'; 29 | echo '

Debug

' . htmlspecialchars($wsdl->getDebug(), ENT_QUOTES) . '
'; 30 | exit(); 31 | } 32 | $cache->put($wsdl); 33 | } else { 34 | $wsdl->clearDebug(); 35 | $wsdl->debug('Retrieved from cache'); 36 | } 37 | $client = new nusoap_client($wsdl, 'wsdl', 38 | $proxyhost, $proxyport, $proxyusername, $proxypassword); 39 | $err = $client->getError(); 40 | if ($err) { 41 | echo '

Constructor error

' . $err . '
'; 42 | exit(); 43 | } 44 | $client->setUseCurl($useCURL); 45 | $params = array('isbn' => '0060188782'); 46 | $result = $client->call('getPrice', $params); 47 | // Check for a fault 48 | if ($client->fault) { 49 | echo '

Fault

';
50 | 	print_r($result);
51 | 	echo '
'; 52 | } else { 53 | // Check for errors 54 | $err = $client->getError(); 55 | if ($err) { 56 | // Display the error 57 | echo '

Error

' . $err . '
'; 58 | } else { 59 | // Display the result 60 | echo '

Result

';
61 | 		print_r($result);
62 | 		echo '
'; 63 | } 64 | } 65 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 66 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 67 | echo '

Cache Debug

' . htmlspecialchars($cache->getDebug(), ENT_QUOTES) . '
'; 68 | echo '

Debug

' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '
'; 69 | ?> 70 | -------------------------------------------------------------------------------- /samples/wsdlclient6.php: -------------------------------------------------------------------------------- 1 | getError(); 21 | if ($err) { 22 | echo '

Constructor error

' . $err . '
'; 23 | } 24 | $client->soap_defencoding = 'UTF-8'; 25 | 26 | echo 'You must set your own Google key in the source code to run this client!'; exit(); 27 | $key = 'set your own Google key'; 28 | $q = '"Lies and the Lying"'; 29 | $start = 1; 30 | $maxResults = 10; 31 | $filter = false; 32 | $restrict = ''; 33 | $safeSearch = false; 34 | $lr = ''; 35 | $ie = ''; 36 | $oe = ''; 37 | 38 | $params = array( 39 | 'key' => $key, 'q' => $q, 'start' => $start, 'maxResults' => $maxResults, 40 | 'filter' => $filter, 'restrict' => $restrict, 'safeSearch' => $safeSearch, 'lr' => $lr, 41 | 'ie' => $ie, 'oe' => $oe 42 | ); 43 | 44 | $result = $client->call('doGoogleSearch', $params); 45 | // Check for a fault 46 | if ($client->fault) { 47 | echo '

Fault

';
48 | 	print_r($result);
49 | 	echo '
'; 50 | } else { 51 | // Check for errors 52 | $err = $client->getError(); 53 | if ($err) { 54 | // Display the error 55 | echo '

Error

' . $err . '
'; 56 | } else { 57 | // Display the result 58 | echo '

Result

';
59 | 		print_r($result);
60 | 		echo '
'; 61 | } 62 | } 63 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 64 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 65 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 66 | ?> 67 | -------------------------------------------------------------------------------- /samples/wsdlclient7.php: -------------------------------------------------------------------------------- 1 | getError(); 23 | if ($err) { 24 | echo '

Constructor error

' . $err . '
'; 25 | } 26 | $client->setUseCurl($useCURL); 27 | $client->loadWSDL(); 28 | $client->setCredentials($username, $password, 'digest'); 29 | $result = $client->call('GetVersionInfo', array()); 30 | // Check for a fault 31 | if ($client->fault) { 32 | echo '

Fault

';
33 | 	print_r($result);
34 | 	echo '
'; 35 | } else { 36 | // Check for errors 37 | $err = $client->getError(); 38 | if ($err) { 39 | // Display the error 40 | echo '

Error

' . $err . '
'; 41 | } else { 42 | // Display the result 43 | echo '

Result

';
44 | 		print_r($result);
45 | 		echo '
'; 46 | } 47 | } 48 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 49 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 50 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 51 | ?> 52 | -------------------------------------------------------------------------------- /samples/wsdlclient8.php: -------------------------------------------------------------------------------- 1 | getError(); 22 | if ($err) { 23 | echo '

Constructor error

' . $err . '
'; 24 | } 25 | $client->setCredentials($username, $password, 'digest'); 26 | $address = array( 27 | 'AddressLine' => '563 Park Avenue', 28 | 'PrimaryCity' => 'New York', 29 | 'SecondaryCity' => 'Brooklyn', 30 | 'Subdivision' => '', 31 | 'PostalCode' => '', 32 | 'CountryRegion' => 'US', 33 | 'FormattedAddress' => '' 34 | ); 35 | $findRange = array( 36 | 'StartIndex' => 0, 37 | 'Count' => 10 38 | ); 39 | $findResultMask = 'AddressFlag'; 40 | $findOptions = array( 41 | 'Range' => $findRange, 42 | 'SearchContext' => 1, 43 | 'ResultMask' => $findResultMask, 44 | 'ThresholdScore' => 0.85 45 | ); 46 | $findAddressSpecification = array( 47 | 'DataSourceName' => 'MapPoint.NA', 48 | 'InputAddress' => $address, 49 | 'Options' => $findOptions 50 | ); 51 | $findAddress = array('specification' => $findAddressSpecification); 52 | $result = $client->call('FindAddress', array('parameters' => $findAddress)); 53 | // Check for a fault 54 | if ($client->fault) { 55 | echo '

Fault

';
56 | 	print_r($result);
57 | 	echo '
'; 58 | } else { 59 | // Check for errors 60 | $err = $client->getError(); 61 | if ($err) { 62 | // Display the error 63 | echo '

Error

' . $err . '
'; 64 | } else { 65 | // Display the result 66 | echo '

Result

';
67 | 		print_r($result);
68 | 		echo '
'; 69 | } 70 | } 71 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 72 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 73 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 74 | ?> 75 | -------------------------------------------------------------------------------- /samples/wsdlclient9.php: -------------------------------------------------------------------------------- 1 | getError(); 22 | if ($err) { 23 | echo '

Constructor error

' . $err . '
'; 24 | } 25 | $client->setCredentials($username, $password, 'digest'); 26 | $client->useHTTPPersistentConnection(); 27 | $view = array( 28 | 'Height' => 200, 29 | 'Width' => 300, 30 | 'CenterPoint' => array( 31 | 'Latitude' => 40, 32 | 'Longitude' => -120 33 | ) 34 | ); 35 | $myViews[] = new soapval('MapView', 'ViewByHeightWidth', $view, false, 'http://s.mappoint.net/mappoint-30/'); 36 | $mapSpec = array( 37 | 'DataSourceName' => "MapPoint.NA", 38 | 'Views' => array('MapView' => $myViews) 39 | ); 40 | $map = array('specification' => $mapSpec); 41 | $result = $client->call('GetMap', array('parameters' => $map)); 42 | // Check for a fault 43 | if ($client->fault) { 44 | echo '

Fault

';
45 | 	print_r($result);
46 | 	echo '
'; 47 | } else { 48 | // Check for errors 49 | $err = $client->getError(); 50 | if ($err) { 51 | // Display the error 52 | echo '

Error

' . $err . '
'; 53 | } else { 54 | // Display the result 55 | echo '

Result

';
56 | 		print_r($result);
57 | 		echo '
'; 58 | } 59 | } 60 | echo '

Request

' . htmlspecialchars($client->request, ENT_QUOTES) . '
'; 61 | echo '

Response

' . htmlspecialchars($client->response, ENT_QUOTES) . '
'; 62 | echo '

Debug

' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
'; 63 | ?> 64 | --------------------------------------------------------------------------------