title: How to build a correct SOAP request with PHP
body: <p>I need to format/build a request for this SOAP "service":
  <a href="http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl" rel="noreferrer">http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl</a></p>
  
  <p>Ideally I would like to use the native PHP SOAP class, but I'm beginning to wonder if this class is not the cause of my problems.</p>
  
  <p>The manual provides this example:</p>
  
  <pre><code>    &lt;soapenv:Body&gt;
          &lt;api:sendObject&gt;
              &lt;arg0&gt;
                  &lt;content&gt;
                      &lt;entry&gt;
                          &lt;key&gt;1&lt;/key&gt;
                          &lt;value&gt;
                          &lt;![CDATA[
                          &lt;table width="600"&gt;
                          &lt;tr&gt;
                          &lt;td&gt;
                          &lt;font size="2" face="Arial"&gt;Our powerful algorithms already
                          found a matching profile that matches your criteria:
                          &lt;br&gt;Celina72&amp;nbsp;&lt;/font&gt;
                          &lt;img src="http://mypath/to/my/image.gif" width="50"
                          height="50" border="0" /&gt;
                          &lt;/td&gt;]]&gt;&lt;/value&gt;
                      &lt;/entry&gt;
                  &lt;/content&gt;
                  &lt;dyn&gt;
                      &lt;entry&gt;
                          &lt;key&gt;FIRSTNAME&lt;/key&gt;
                          &lt;value&gt;john&lt;/value&gt;
                      &lt;/entry&gt;
                  &lt;/dyn&gt;
                  &lt;email&gt;johnblum@flowerpower.com&lt;/email&gt;
                  &lt;encrypt&gt;BdX7CqkmjSivyBgIcZoN4sPVLkx7FaXGiwsO&lt;/encrypt&gt;
                  &lt;notificationId&gt;6464&lt;/notificationId&gt;
                  &lt;random&gt;985A8B992601985A&lt;/random&gt;
                  &lt;senddate&gt;2008-12-12T00:00:00&lt;/senddate&gt;
                  &lt;synchrotype&gt;NOTHING&lt;/synchrotype&gt;
                  &lt;uidkey&gt;EMAIL&lt;/uidkey&gt;
              &lt;/arg0&gt;
          &lt;/api:sendObject&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Here is the garbage that my PHP request produces (from __getLastRequest())</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="http://api.service.nsapi.emailvision.com/" xmlns:ns2="http://xml.apache.org/xml-soap"&gt;
          &lt;SOAP-ENV:Body&gt;
              &lt;ns1:sendObject/&gt;
              &lt;param1&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/param1&gt;
              &lt;param2&gt;123456789&lt;/param2&gt;
              &lt;param3&gt;BBBBBBBBBBBB&lt;/param3&gt;
              &lt;param4&gt;2013-09-09T00:00:00&lt;/param4&gt;
              &lt;param5&gt;NOTHING&lt;/param5&gt;
              &lt;param6&gt;EMAIL&lt;/param6&gt;
              &lt;param7&gt;
                  &lt;ns2:Map&gt;
                      &lt;item&gt;
                          &lt;key&gt;2&lt;/key&gt;
                          &lt;value&gt;TEST&lt;/value&gt;
                      &lt;/item&gt;
                  &lt;/ns2:Map&gt;
              &lt;/param7&gt;
              &lt;param8&gt;
                  &lt;ns2:Map&gt;
                  &lt;item&gt;
                      &lt;key&gt;FIRSTNAME&lt;/key&gt;
                      &lt;value&gt;John&lt;/value&gt;
                  &lt;/item&gt;
              &lt;/ns2:Map&gt;
              &lt;ns2:Map&gt;
                  &lt;item&gt;
                      &lt;key&gt;LASTNAME&lt;/key&gt;
                      &lt;value&gt;Smith&lt;/value&gt;
                  &lt;/item&gt;
              &lt;/ns2:Map&gt;
          &lt;/param8&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>My call:</p>
  
  <pre><code>$client = new SoapClient('http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl', array( 'trace' =&gt; 1, 'exceptions' =&gt; 0 ) );
  </code></pre>
  
  <p>The params look like this (modified with dummy data):</p>
  
  <pre><code>$email = 'john.smith@example.com';
  $encrypt = 'AAAAAAAAAAAAAAAAAAAAAAAAAAA';
  $notification_id = 123456789;
  $random = 'BBBBBBBBBBBB';
  $senddate = '2013-09-09T00:00:00';
  $synchrotype = 'NOTHING';
  $uidkey = 'EMAIL';
  
  $content = array();
  $content[] = array(
      2 =&gt; 'TEST'
  );
  
  $dyn = array();
  $dyn[] = array(
      'FIRSTNAME' =&gt; 'John'
  );
  $dyn[] = array(
      'LASTNAME' =&gt; 'Smith'
  );
  
  $params = array(
      'email' =&gt; $email,
      'encrypt' =&gt; $encrypt,
      'notificationId' =&gt; $notification_id,
      'random' =&gt; $random,
      'senddate' =&gt; $senddate,
      'synchrotype' =&gt; $synchrotype,
      'uidkey' =&gt; $uidkey,
      'content' =&gt; $content,
      'dyn' =&gt; $dyn
  );
  </code></pre>
  
  <p>I then execute the request like this :</p>
  
  <pre><code>$res = $client-&gt;__soapCall( 'sendObject', array( $email, $encrypt, $notification_id, $random, $senddate, $synchrotype, $uidkey, $content, $dyn ) );
  </code></pre>
  
  <p>Why is PHP unable to format my request correctly? Is there a mor direct approach where I could write the XML "by hand" and then post it using cURL?</p>