Table of Contents

User Contributed Notes 44 notes

To debug a SOAP service using SoapServer(), a WSDL file and Zend Studio Client/Server, you have to append ?start_debug=1&amp;debug_port=10000 to the service location:--- snip ---... method / service definition ....

For those working from a wsdl full of complex types that just want a class structure to hang your code on and not worry about typing in long parameter lists (or creating a script to do so): wsdl2php is a wonderful time-saver. Gets a structure going so you can go in and add what validation and special data munging you need: http://www.urdalen.no/wsdl2php/

Having trouble passing complex types over SOAP using a PHP SoapServer in WSDL mode? Not getting decoded properly? This may be the solution you're looking for!

When using ComplexType in the schema portion of the WSDL file, You need use an additional step to tell PHP SOAP how to encode the objects. The first method would be to explicitely encapsulate the object in a SoapVar object - telling PHP to use generalized SOAP encoding rules (which encodes all ComplexTypes as Structs). This won't work, though, if the client is expecting the objects to be encoded according to the WSDL's schema. So, The actual way to do this is:

* First, define a specific PHP class which is actually just a data structure holding the various properties, and the appropriate ComplexType in the WSDL.

Note that if you should need to set the timeout for your soap request, you can use ini_set to change the value for the default_socket_timeout. I previously used NuSOAP, whose soap client class has a timeout option, and it took me a while to figure out that PHP's soap uses the same socket options as everything else.

Here are 73 test cases that detail the kinds of schemas that PHP5 currently supports and the structures you are expected to plug into them for the return value from your services. Much better than trying to guess!

PROBLEM (with SOAP extension under PHP5) of transferring object, that contains objects or array of objects. Nested object would not transfer.

SOLUTION:This class was developed by trial and error by me. So this 23 lines of code for most developers writing under PHP5 solves fate of using SOAP extension.

<?php/*According to specific of organization process of SOAP class in PHP5, we must wrap up complex objects in SoapVar class. Otherwise objects would not be encoded properly and could not be loaded on remote SOAP handler.

So every class, which will transfer via SOAP, must be extends from class SOAPable. As you can see, in code above, function prepareSOAPrecursive search another nested objects in parent object or in arrays, and if does it, tries call function getAsSOAP() for preparation of nested objects, after that simply wrap up via SoapVar class.

wow, actually a cool program and soap is new for me.I found out some interessting things i can not debug because the scripts exit without any error messages or notes. :-(

you may have problems with the memory and/or especially on "shared servers" when server load is high. sometimes the script does the job, sometimes it just stopping at any unknown point.these are the steps my script does:* get data from remote server ( ~ 4.5 MB)* parsing requested object and store the data in a database.

so, and if now someone on the server takes the rest of RAM the walk thought the data breaks :-(

so, i need to store the xml tree ($client->client->__last_response) and parsing it by the classical way. (if you would request more RAM, you may get in trouble with the admin if you run a script like this more often! (on shared servers)

[faultstring] => Function ("yourMethod") is not a valid method for this service

although it is present in the WSDL etc., be aware that PHP caches the wsdl locally for better performance. You can disable the caching via php.ini/.htaccess completely or remove the cache file (/tmp/wsdl-.. if you are on Linux) to force regeneration of it.

Warning: SoapClient::__construct(): Unable to set local cert chain file `./mycert.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in productinfo.php on line 27

then the certFile is probably in the "wrong format" (the wrong format for php maybe). It worked for me, when i appended the content of the private key file and the certificate file to a single file "mycert.pem":

It's not good security practice to pass the username and password in the URI when the point of SSL is to prevent that information from being intercepted. Putting that information in the URI makes it interceptable. HTTPS-Posted values are safe because values passed in the headers are sent after the SSL handshake has been completed.

Working with a third party service I got: "SOAP-ERROR: Parsing Schema: unexpected <text> in restriction"

Thought it would be worth it to share. What it is saying is that there is some text in an invalid place. C# seems to ignore it, and if you are using nusoap it doesn't notice it either. But what was causing my problem was something like:<types> <schema ...

this might be helpful, as it took quite some time for me to find this out:

if you're using some .wsdl and there's a sequence that can be there more than once (ie: maxOccurs > 1), you can specify an non-associative array for it if you have more than 1 items OR you could just specify the one item if there is only one:

In case your soap response containts an ampersand, in certain cases you might get an "unterminated entity reference" warning and data might appear truncated (related to bug #36795?). Maybe there is a more formal fix or setting, but since I couldn't find anything I came with the following:

If you want to use soap over https, you *must* compile php with the configure option with-openssl or you will have the error "[HTTP] SSL support not available in this build" while trying to use the web services over SSL

One good tutorial on using this extension is on IBM web site:"Using the PHP 5 SOAP extension to consume a WebSphere Web service"http://www.ibm.com /developerworks/library/os-phpws/?ca=dgr-lnxw06PHP5soap