I'm trying to make a soap request and having difficulties.
Here is my php:
<?php
$option=array('trace'=>1);
$soapClient = new SoapClient('http://www.domain.com/ws/AccountManagement.wsdl', $option);
$headers = array('LOGIN_ID' => '[email protected]', 'LOGIN_PASSWORD' => 'mypassword');
$header = new SoapHeader('https://www.domain.com', 'AuthenticationDTO', $headers, false);
$soapClient->__setSoapHeaders($header); //or array($header)
$params = array(
'bureauName' => '',
'businessInformation' => array('address' => array('city' => 'SomeCity'), array('country' => 'US'), array('state' => 'MN'), array('street' => 'Some Address'), array('zipCode' => '33212')), array('businessName' => 'SomeBusinessName'),
'entityType' => '',
'listOfSimilars' => 'true',
);
try {
$result = $soapClient->__call("matchCompany", $params);
print_r($result);
} catch (SoapFault $fault) {
echo $fault->faultcode . "-" . $fault->faultstring;
echo "REQUEST:\n" . htmlentities($soapClient->__getLastRequest()) . "\n";
}
?>
It fails on $soapClient__call.
getLastRequest() produces this XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://com.dnbi.eai.service.AccountSEI" xmlns:ns2="http://dto.eai.dnbi.com">
<SOAP-ENV:Header>
<ns2:AuthenticationDTO>
<ns2:LOGIN_ID>[email protected]</ns2:LOGIN_ID>
<ns2:LOGIN_PASSWORD>mypassword</ns2:LOGIN_PASSWORD>
</ns2:AuthenticationDTO>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:matchCompany/>
<param1><item>
<key>address</key>
<value><item>
<key>city</key>
<value>SomeCity</value>
</item></value>
</item><item>
<key>0</key>
<value><item>
<key>country</key>
<value>US</value>
</item></value>
</item><item>
<key>1</key>
<value><item>
<key>state</key>
<value>MN</value>
</item></value>
</item><item>
<key>2</key>
<value><item>
<key>street</key>
<value>Some Address</value>
</item></value>
</item><item>
<key>3</key>
<value><item>
<key>zipCode</key>
<value>33212</value>
</item></value>
</item></param1>
<param2><item>
<key>businessName</key>
<value>SomeBusinessName</value>
</item></param2>
<param3></param3>
<param4>true</param4>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This is not the correct XML output. I must be doing something wrong. Using soapUI I found that this is the correct XML:
<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>SomeCity</dto:city>
<dto:country>US</dto:country>
<dto:state>MN</dto:state>
<dto:street>Some Address</dto:street>
<!--Optional:-->
<dto:zipCode></dto:zipCode>
</dto:address>
<!--Optional:-->
<dto:businessName>SomeBusinessName</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>
Can anybody help me produce the same XML that soapUI produced for me, but using PHP5's native Soap client?
Thanks