Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP SoapServer and Complex Types
    primarykey
    data
    text
    <p>I am working on building a web service in PHP using the SoapServer class, but I'm running into an issue with casting of complex types.</p> <p>The WSDL is completely valid, and the PHP SoapClient handles it flawlessly, but there seems to be an issue with the complex types that are returned not being cast properly. This came to light when consuming the service in .Net, as I was getting exceptions that indicated the type was not present in the given namespace.</p> <p>I mangled my function numerous times, changing the namespace on the element, but .Net continues to give me errors, regardless of what namespace I use.</p> <p>Consider the following abbreviation of the script:</p> <pre><code>function getCommands() { $output = array(); // ... foreach($result as $row) { $output[] = new SoapVar($row, SOAP_ENC_OBJECT, 'ns1:command'); } return $output; } </code></pre> <p>The abbreviated response:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:MyWebService" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getCommandsResponse&gt; &lt;return SOAP-ENC:arrayType="ns1:command[12]" xsi:type="ns1:ArrayOfCommand"&gt; &lt;item xsi:type="ns1:command"&gt; &lt;!-- ... --&gt; &lt;/item&gt; &lt;!-- ... --&gt; &lt;/return&gt; &lt;/ns1:getCommandsResponse&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>What I've noticed is that <code>xmlns:ns1</code> is defined by way of the WSDL, and it does match the namespace in the WSDL. However, the .Net SOAP client doesn't seem to understand that the <code>command</code> element is defined there. It does, however, understand that that's where <code>ArrayOfCommand</code> is defined.</p> <p>So my question is multipart:</p> <ol> <li>Is this a known bug with the SoapServer?</li> <li>If not, am I missing something grievous in my WSDL?</li> <li>Am I not encoding my objects properly?</li> <li>Is this an issue with .Net? If so, what's the work-around?</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload