This seems to do the trick. Install it and run it, look over the output and the code+comments and post back here if you have any questions. Best regards, ~Ray
<?php // RAY_temp_soap_thing.php
error_reporting(E_ALL);
echo "<pre>\n";
// TEST DATA FROM THE ORIGINAL POST
// YOU MIGHT WANT TO CONSIDER TESTING FOR AN HTTP 200 RESPONSE IN THE HEADERS
// WE DO NOT TEST FOR THAT HERE
$str = 'HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Length: 928
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Sat, 07 Nov 2009 11:23:31 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><Case_RetrieveResponse xmlns="http://tempuri.org/CatalystDeveloperService/CatalystCRMWebservice"><Case_RetrieveResult><entityId>6635854</entityId><caseId>1506795</caseId><assignedTo>0</assignedTo><caseSubject>Test Form</caseSubject><createDate>2009-11-06T02:00:00</createDate><lastUpdateDate>2009-11-06T02:00:00</lastUpdateDate><crmForms><CrmForms><formId>37714</formId><formName>Test Form</formName><crmFormFields><CrmFormFields><fieldId>98079</fieldId><fieldTypeId>1</fieldTypeId><fieldName>Some Data</fieldName><fieldValue>This is a test form submission. La la la...</fieldValue></CrmFormFields></crmFormFields></CrmForms></crmForms></Case_RetrieveResult></Case_RetrieveResponse></soap:Body></soap:Envelope>';
// DISCARD THE HEADERS (THIS WILL HAPPEN AUTOMATICALLY IN A REST INTERFACE)
// MAN PAGE: http://us2.php.net/manual/en/function.strpos.php
$pos = strpos($str, '<?xml');
if ($pos === FALSE) die('BOGUS DATA');
// MAN PAGE: http://us2.php.net/manual/en/function.substr.php
$str = substr($str, $pos);
// MUNG THE STRING TO GET RID OF THE UNWANTED SOAP WRAPPERS
$xml = str_replace('soap:', 'soap_', $str);
// MAKE AN OBJECT AND VISUALIZE IT
$obj = SimpleXML_Load_String($xml);
var_dump($obj);
// DISCARD THE SOAP AND EXTRACT THE USEFUL INFORMATION
$new = $obj->soap_Body->Case_RetrieveResponse;
var_dump($new);
// SHOW AN ELEMENT
$formId = $new->Case_RetrieveResult->crmForms->CrmForms->formId;
echo "\nFORMID: $formId";
// SHOW THE OBJECT AS XML
echo "\nOBJECT: ";
echo htmlentities($new->asXML());
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50:





by: Ray_PaseurPosted on 2009-11-07 at 06:13:12ID: 25766386
For starters, you might want to ask your data source if they have a RESTful service so you do not need to use the unnecessarily elaborate and mind-numbingly complicated SOAP interface. I just looked at another SOAP string, similar to what you had here and the payload-to-package ratio was 3%. REST will always be a better way to go, believe me.
I'll see if we can parse this thing into an object. Back in a while. ~Ray