Note that there are some explanatory texts on larger screens.

plurals
  1. POSoap Call in PHP with Multiple Elements - Need to Pass in As Array?
    text
    copied!<p>I am trying to send multiple repeated elements via a Soap Call. I tried building an array and sending, but it would process only the first element. The following post was helpful as I adapted the code using SoapVar <a href="https://stackoverflow.com/questions/4855677/soapvar-param-and-nested-repeated-elements-in-soap">SoapVar/Param and nested, repeated elements in SOAP</a>. The issue that I am facing now, however, is that when I try to send off my soap request, the soap call needs the request as an array, and the following code gets a failure from the soap server. The WSDL file I am working with is at <a href="https://ecomapi.networksolutions.com/soapservice.asmx?wsdl" rel="nofollow noreferrer">https://ecomapi.networksolutions.com/soapservice.asmx?wsdl</a></p> <p>I have replaced the header elements for security (my name, my cert number, my token) - but other than that, the complete code is below. Any thoughts on what I am doing wrong here? </p> <pre><code>&lt;?php $ns = 'urn:networksolutions:apis'; $header-&gt;Application = 'my name'; $header-&gt;Certificate = 'my cert number'; $header-&gt;UserToken = 'my token'; $credentials = new SOAPHeader($ns, "SecurityCredential", $header); $client = new SoapClient('https://ecomapi.networksolutions.com/soapservice.asmx?wsdl', array('soap_version' =&gt; SOAP_1_1 , 'trace' =&gt; 1)); $array1=array(); $array1[]=new SoapVar("9",XSD_STRING,null,null,'ProductId'); $array1[]=new SoapVar("500",XSD_STRING,null,null,'QtyInStock'); $soap1 = new SoapVar($array1, SOAP_ENC_OBJECT, null, null, "Inventory"); $interim = array($soap1); $test = array(); $test[] = new SoapVar($interim, SOAP_ENC_OBJECT, null, null, "UpdateInventoryRequestList"); $array2=array(); $array2[]=new SoapVar("10",XSD_STRING,null,null,'ProductId'); $array2[]=new SoapVar("500",XSD_STRING,null,null,'QtyInStock'); $soap2 = new SoapVar($array2, SOAP_ENC_OBJECT, null, null, "Inventory"); $interim2 = array($soap2); $test[] = new SoapVar($interim2, SOAP_ENC_OBJECT, null, null, "UpdateInventoryRequestList"); $submit1 = array($test); $submit = new SoapVar($submit1, SOAP_ENC_OBJECT, null, null, "PerformMultipleRequest"); $final_submit = array($submit); $result = $client-&gt;__soapCall("PerformMultiple", $final_submit, NULL, $credentials); echo "REQUEST:\n" . $client-&gt;__getLastRequest() . "\n"; // gets last SOAP request echo "RESPONSE:\n" . $client-&gt;__getLastResponse() . "\n"; // gets last SOAP respone ?&gt; </code></pre>
 

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