Title: SOAP XML ns1
Last modified: March 20, 2018

---

# SOAP XML ns1

 *  [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/)
 * Hello,
 * I’m developing a WordPress plugin to access an ASP.Net SOAP service.
 * For some reason the ASP server does not like the ns1
    `<ns1:User_Credentials>`
 * even though it’s bound properly:
 * `xmlns:ns1="https://www...`
 * but prefers
 * `<User_Credentials xmlns="https://www...`
 * I don’t see any option to control this.
 * Just wondering if there are any other plugin developers that have experience 
   with using SOAP to talk to an ASP.NET server in a WordPress plugin.
 * From the headers received it’s a :
 *     ```
       Server: Microsoft-IIS/8.5
       X-AspNet-Version: 4.0.30319
       X-Powered-By: ASP.NET
       ```
   

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096566)
 * PHP has an easy way to communicate with a SOAP server:
 * [https://secure.php.net/manual/en/book.soap.php](https://secure.php.net/manual/en/book.soap.php)
 * The SOAP extension must be installed for this to work; you can check the PHP 
   info page or type `php -m` at the command line to verify.
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096584)
 * Hi DionDesigns,
 * Yes I’m using
 *     ```
       $client = new SoapClient($wsdl,
                                       array(
                                               'trace' => 1,
                                               'cache_wsdl' => WSDL_CACHE_NONE,
                                               'soap_version' => SOAP_1_2
                                       ));
       ```
   
 * …
 *     ```
         $authvalues = new SoapVar($User_Credentials, SOAP_ENC_OBJECT);
       ```
   
 * …
 *     ```
        $header = new SoapHeader($tns, 'User_Credentials', $authvalues, false);
       ```
   
 * …
 *     ```
        $client->__setSoapHeaders(array($header));
       ```
   
 * …
 *     ```
       $soapResponse = $client->Is_Alive();
       $lastRespHeaders = $client->__getLastResponseHeaders();
       $lastResquest = $client->__getLastRequest();
       $lastResponse = $client->__getLastResponse();
       ```
   
 * but microsoft is not accepting ns1
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096593)
 * If I use the online [https://wsdlbrowser.com/](https://wsdlbrowser.com/)
    and
   enter the WSDL is also creates XML with the ns1 bound to the xmlns
 * So I would think the ASP server should accept it but it doesn’t.
    -  This reply was modified 8 years, 1 month ago by [Ken Stone](https://wordpress.org/support/users/wpstoneblue/).
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096691)
 * Got it working:
 * I removed the soapvar from the header and just use the PHP class straight away.
 * The difference is that now
 *     ```
       <env:Header>
       <ns1:User_Credentials>
       <ns1:str_Username>jklsafdljk</ns1:str_Username>
       <ns1:str_Password>jkasdjl</ns1:str_Password>
       </ns1:User_Credentials>
       </env:Header>
       ```
   
 * ns1 is also on the username and password
    where previously it was not:
 *     ```
       <SOAP-ENV:Header>
       <ns1:User_Credentials>
       <str_Username>asdasdasd</str_Username>
       <str_Password>asdasdads</str_Password>
       </ns1:User_Credentials>
       </SOAP-ENV:Header>
       ```
   
 * I got a clue from a google search result. I didn’t even click through but I saw‘
   you don’t have to use a soapvar in the header you can use a regular php class’.
   At this point I was willing to try anything…
 * So I immediately did
 *     ```
       //$header = new SoapHeader($tns, 'User_Credentials', $authvalues, false);
       $header = new SoapHeader($tns, 'User_Credentials', $User_Credentials, false);
       ```
   
    -  This reply was modified 8 years, 1 month ago by [Ken Stone](https://wordpress.org/support/users/wpstoneblue/).
 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096704)
 * I haven’t needed to access a SOAP server in a couple years, but I remember having
   all sorts of problems until I added the following line to php.ini and restarting
   php-fpm:
 *     ```
       soap.wsdl_cache_enabled=0
       ```
   
 * Maybe that will be of some help to you.
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096718)
 * At this point though I’m wondering since the online SOAP client at wsdlbrowser.
   com created the same XML as the PHP code based on the WSDL file if there is some
   issue with the WSDL file?
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10096726)
 * Hi Dion,
 * I have:
 *     ```
       'cache_wsdl' => WSDL_CACHE_NONE,
       ```
   
 * in the instantiation of the soap client.
 * Working now. but THANKS
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10103973)
 * I have a similar issue now when calling a method that has parameters in the body.
 * PHP SOAP is using xsi:type=”ns1… instead of adding ns1 to each value in the parameter
   object. Does anyone know if there is a way to modify this behavior?
 *     ```
       <SOAP-ENV:Body>
       <ns1:Process_Credit_Application xsi:type="ns1:obj_Credit_Application">
       <ApplicantIP>192.168.1.1</ApplicantIP>
       ```
   
 * I think what is needed is:
 *     ```
       <SOAP-ENV:Body>
       <ns1:Process_Credit_Application>
       <ns1:obj_Credit_Application>
       <ns1:ApplicantIP>192.168.1.1</ns1:ApplicantIP>
       ```
   
    -  This reply was modified 8 years, 1 month ago by [Ken Stone](https://wordpress.org/support/users/wpstoneblue/).
 *  Thread Starter [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * (@wpstoneblue)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10106159)
 * I still have no idea how to do it within the PHP SOAP library so I went ahead
   and just rolled my own XML for now.
 *     ```
       public function get_xml($method, $type, $data_assoc_array){
   
               $my_xml = '<ns1:' . $method . '><ns1:'. $type . '>';
   
               foreach($data_assoc_array as $key => $val){
                   $my_xml .= '<ns1:' . $key . '>' . $val . '</ns1:' . $key . '>';
               }
   
               $my_xml .= '</ns1:' . $type . '></ns1:' . $method . '>';
   
               return $my_xml;
           }
       ```
   

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘SOAP XML ns1’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [soap](https://wordpress.org/support/topic-tag/soap/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 9 replies
 * 2 participants
 * Last reply from: [Ken Stone](https://wordpress.org/support/users/wpstoneblue/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/soap-xml-ns1/#post-10106159)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
