NuSOAP PHP Request From XML

Posted by Tegan Snyder on Stack Overflow See other posts from Stack Overflow or by Tegan Snyder
Published on 2010-05-03T16:45:20Z Indexed on 2010/05/03 16:48 UTC
Read the original article Hit count: 576

Filed under:
|
|

I'm trying to take the following XML request and convert it to a NuSOAP request and I'm having a bit of difficulty. Could anybody chime in?

XML Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dto="http://dto.eai.dnbi.com" xmlns:com="http://com.dnbi.eai.service.AccountSEI">
   <soapenv:Header>
      <dto:AuthenticationDTO>
         <dto:LOGIN_ID>[email protected]</dto:LOGIN_ID>
         <dto:LOGIN_PASSWORD>mypassword</dto:LOGIN_PASSWORD>
      </dto:AuthenticationDTO>
   </soapenv:Header>
   <soapenv:Body>
      <com:matchCompany>
         <com:in0>
            <!--Optional:-->
            <dto:bureauName></dto:bureauName>
            <!--Optional:-->
            <dto:businessInformation>
               <dto:address>
         <!--Optional:-->
                  <dto:city>Bloomington</dto:city>
                  <dto:country>US</dto:country>
                  <dto:state>MN</dto:state>
                  <dto:street>555 Plain ST</dto:street>
                  <!--Optional:-->
                  <dto:zipCode></dto:zipCode>
               </dto:address>
               <!--Optional:-->
               <dto:businessName>Some Company</dto:businessName>
            </dto:businessInformation>
            <!--Optional:-->
            <dto:entityNumber></dto:entityNumber>
            <!--Optional:-->
            <dto:entityType></dto:entityType>
            <!--Optional:-->
            <dto:listOfSimilars>true</dto:listOfSimilars>
         </com:in0>
      </com:matchCompany>
   </soapenv:Body>
</soapenv:Envelope>

And my PHP code:

<?php

require_once('nusoap.php');

$params = array(
'LOGIN_ID' => '[email protected]',
'LOGIN_PASSWORD' => 'mypassword',
'bureauName' => '',
'businessInformation' => array('address' => array('city' => 'Some City'), array('country' => 'US'), array('state' => 'MN'), array('street' => '555 Plain St.'), array('zipCode' => '32423')), array('businessName' => 'Some Company'),
'entityType' => '',
'listOfSimilars' => 'true',
);


$wsdl="http://www.domain.com/ws/AccountManagement.wsdl"; 

$client = new nusoap_client($wsdl, true);
$err = $client->getError();
if ($err) {
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    exit();
}

$result = $client->call('matchCompany', $params);

if ($client->fault) {
    echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
} else {
    $err = $client->getError();
    if ($err) {
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
    }
}

echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';


?>

Am I generating the Header information correctly? I think that may be where I'm off.

Thanks,

© Stack Overflow or respective owner

Related posts about nusoap

Related posts about php