title: Soap soap-enc:Array example (C#)
body: <p>I need to call a PHP Soap webservice in C#. I do have a WSDL but the main parts of input data are typed as <strong>soap:enc:Array</strong> resulting in <strong>object[]</strong>:</p>
  
  <p>snippets from the WSDL for add_address:</p>
  
  <pre><code>&lt;operation name="add_address"&gt;
    &lt;documentation&gt;
    Add's a new Address with the data provided in an array.
    &lt;/documentation&gt;
    &lt;input message="tns:add_addressIn"/&gt;
    &lt;output message="tns:add_addressOut"/&gt;
  &lt;/operation&gt;
  
  &lt;message name="add_addressIn"&gt;
    &lt;part name="data" type="soap-enc:Array"/&gt;
    &lt;part name="token" type="xsd:string"/&gt;
  &lt;/message&gt;
  
  &lt;message name="add_addressOut"&gt;
    &lt;part name="return" type="soap-enc:Array"/&gt;
  &lt;/message&gt;
  </code></pre>
  
  <p>Importing the WSDL as a reference in Visual Studio results in a the type <strong>object[]</strong> for the <strong>data</strong> parameter in the add_Address function.</p>
  
  <p>From the online docs of the webservice : </p>
  
  <p><a href="https://i.stack.imgur.com/IuHrP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IuHrP.png" alt="dataExample"></a></p>
  
  <p>Invoking from PHP (also as per their docs):</p>
  
  <pre><code>data = Array
  (
      [company_name] =&gt; MDS Collivery
      [building] =&gt; MDS House
      [street] =&gt; 58c Webber St
      [location_type] =&gt; 5
      [suburb_id] =&gt; 1936
      [town_id] =&gt; 147
      [custom_id] =&gt; AF65549
      [full_name] =&gt; Bernhard Breytenbach
      [phone] =&gt; 0123456789
      [cellphone] =&gt; 0834567912
      [email] =&gt; name@domain.co.za
  )
  add_address(data, '4M8wJGBXC6KKpT0')
  </code></pre>
  
  <p>I have tried with a Dictionary in C# but that results in serialization challenges.</p>
  
  <p>Importing the WSDL in SoapUI results in:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="https://www.collivery.co.za/ws/v2"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;v2:add_contact soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
           &lt;data xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;
              &lt;!--You may enter ANY elements at this point--&gt;
           &lt;/data&gt;
           &lt;token xsi:type="xsd:string"&gt;?&lt;/token&gt;
        &lt;/v2:add_contact&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>I have written my own client to build up the Soap envelope. it works for all the strongly typed operation but I don't know how to build up the elements for <strong>soap-enc:Array</strong></p>
  
  <p>Can anyone please assist with providing an example of what to put within the  element:</p>
  
  <pre><code>&lt;data xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;
  &lt;!--You may enter ANY elements at this point--&gt;
  &lt;/data&gt;
  </code></pre>