> We're building the request using the DomDocument object and then,
> usually using a combination of SoapVar and one of it's constant
> (second) arguments .. usually XSD_ANYXML - we're struggling so much
> with pure trial and error!
This is a method that will typically get you tantalizingly close to the
right SOAP payload, but almost never totally correct.
> How did you learn to use SOAP with PHP correctly, and how would you
> advise we learn the same ?
Because I came to NuSOAP with lots of SOAP experience, my learning curve
was mainly mapping my knowledge to NuSOAP's design. It sounds like you
are probably learning SOAP and a PHP implementation at the same time,
which is much harder. Some tutorials would probably help you a lot.
The ones I did for NuSOAP are, unfortunately, old enough that I am not
sure they work any more. That says good things about how much NuSOAP
has evolved, but does not help you much.
> The primary problem arises knowing what 'type' to send a request as -
> using __getTypes() on the client is reporting a variety of complex
> types (we're working on clients for ~6 web services) - conventional
> wisdom says that SOAP is just XML, and XML is just text.. so we can
> send a string - bt we're not getting very far with that approach!
There are a couple of ways to attack this, assuming the services supply
WSDL. One is to get a tool like wsdl2php
(http://www.urdalen.no/wsdl2php/). I have not used it, but it has been
mentioned on this list. I believe it will create a PHP proxy for you to
use that (hopefully) will make types easier. A second way to go is to
learn to read the WSDL well enough (it won't take long) to determine the
right complexTypes to use. In NuSOAP, you then just create an
associative array with keys corresponding to the type elements. An
example complexType would be
<xsd:complexType name="SOAPStruct">
<xsd:all>
<xsd:element name="varString" type="xsd:string" minOccurs="1"
maxOccurs="1"/>
<xsd:element name="varInt" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<xsd:element name="varFloat" type="xsd:float" minOccurs="1"
maxOccurs="1"/>
</xsd:all>
</xsd:complexType>
Your PHP to create a variable of this type would be
$struct = array('varString' => 'who', 'varInt' => 2, 'varFloat' =>
3.14159);
That seems pretty straightforward to me.
Scott Nichol
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
|