Surprisingly enough I've actually figured out this API from Directi now, I'm stuck at a simple point which I'm sure someone can help me out with.
I've figured out how to send the SOAP request, now my issue is actually parsing that data with SimpleXML.
Can someone please show me how to parse this data with SimpleXML?
Below is the code I'm currently using which is working up until the SimpleXML part. . .
<?php
$host = "http://www.myorderbox.com/anacreon/servlet/APIv3";
$soapActionXmlNS = "http://tempuri.org/";
// Establish new SOAP client
$soapClient = new SoapClient(NULL,
array(
"location" => $host,
"uri" => "http://schemas.xmlsoap.org/soap/envelope/",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
));
// Build SOAP XML request
$soapXml = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd" xmlns:impl="com.logicboxes.foundation.sfnb.order.DomOrder"><SOAP-ENV:Body><impl:checkAvailabilityMultiple><userName xsi:type="xsd:string">myreselleraccount@mydomain.com</userName><password xsi:type="xsd:string">mypassword</password><role xsi:type="xsd:string">reseller</role><langpref xsi:type="xsd:string">en</langpref><parentid xsi:type="xsd:int">1</parentid><domainNames xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[1]"><item xsi:type="xsd:string">mynewdomain123</item></domainNames><tlds xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[1]"><item xsi:type="xsd:string">com</item></tlds><suggestAlternative xsi:type="xsd:boolean">false</suggestAlternative></impl:checkAvailabilityMultiple></SOAP-ENV:Body></SOAP-ENV:Envelope>';
// Send off SOAP request and get response back
$response = $soapClient->__doRequest($soapXml, $host, $soapActionXmlNS, "1.1");
// SimpleXML seems to have problems with the colon ":" in the <xxx:yyy> response tags, so take them out
$xmlStringnew = preg_replace('|<([/\w]+)(:)|m','<$1',$response);
$xmlString = preg_replace('|(\w+)(:)(\w+=\")|m','$1$3',$xmlStringnew);
[B]// Use SimpleXML to parse response into object (problem starts here)[/B]
$xml = new SimpleXMLElement($xmlString);
// SimpleXML object for tags in the <soap:Body> node
// For directi it would be . . <soapenv:Body>
$result = $xml->soapenvBody;
// You can now use $result to access whatever response tags you need to, just like normal
//var_dump($xml) ##Uncomment for dump
echo $result;
?>
Thanks a million . .