I have soap request in xml format. I want to convert into php SOAP. Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<AddContact xmlns="http://thankqportal.com/eModulesAPI"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<token>efgh5678</token>
<contactXml>
<Contact xmlns="http://thankqportal.com/eModulesAPI/Contact.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<title>Mr</title>
<firstname>Luke</firstname>
<keyname>Hawkins</keyname>
</Contact>
</contactXml>
</AddContact>
</s:Body>
</s:Envelope>
Please help me here. I am stuck with contact xml. It is inner xml of xml. So How can I pass the xml to soap api.
I have written the code as per below:
$xml = "<Contact>
<firstname>$fname</firstname>
<keyname>$keyname</keyname>
</Contact>";
$args = array("token" =>$token, "contactXml" => new SoapVar($xml, XSD_ANYXML));
try {
$result = $soapClient->AddContact($args);
} catch (SoapFault $e) {
echo '<pre>';
echo "Error!: ";
echo $e -> getMessage ();
}
But it gives the error: Error!: Object reference not set to an instance of an object.
So please help me here where I am wrong in my code.