Ich habe in den letzten 16 Stunden meinen Kopf auf den Tisch geschlagen, um herauszufinden, warum ich meine XML-SOAP-Antwort von dieser Anfrage nicht analysieren kann. Ich bin über den Stack hinaus gelaufen und habe versucht, eine Lösung zu finden, und ich kann nicht die richtige Antwort finden.PHP CURL SOAP XML-Parsing-Namespace Warnung
Ich realisiere, dass ich wahrscheinlich einen Schlüsselpunkt vermisse, aber ich kann nicht scheinen, es zu finden.
//Response From Server
$r = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><RegisterMarketResponse xmlns="http://tempuri.org/"><RegisterMarketResult xmlns:a="http://schemas.datacontract.org/2004/07/Synectic.TheMarket.Domain.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:Cabinets xmlns:b="http://schemas.datacontract.org/2004/07/Synectic.TheMarket.Domain"><b:Cabinet><b:AssetId>1</b:AssetId><b:AssetNumber>001</b:AssetNumber><b:Model>*****</b:Model><b:ModelCategory>Snack</b:ModelCategory><b:Products>2</b:Products></b:Cabinet></a:Cabinets><a:CompanyId>{*****}</a:CompanyId><a:CompanyName>****</a:CompanyName><a:DateCreated>2016-07-16T07:55:15.84</a:DateCreated><a:Id>1</a:Id><a:MarketNumber>****</a:MarketNumber></RegisterMarketResult></RegisterMarketResponse></s:Body></s:Envelope>';
// converting
$response1 = str_replace("<s:Body>","",$r);
$response2 = str_replace("</s:Body>","",$response1);
// convertingc to XML
$parser = simplexml_load_string($response2);
print_r($parser);
, die mir eine Antwort von
jedochSimpleXMLElement Object ([RegisterMarketResponse] => SimpleXMLElement Object ([RegisterMarketResult] => SimpleXMLElement Object ()))
gibt, wenn ich
// converting
$response1 = str_replace("<s:Body>","",$r);
$response2 = str_replace("</s:Body>","",$response1);
zu
// converting
$response1 = str_replace('<RegisterMarketResult xmlns:a="http://schemas.datacontract.org/2004/07/Synectic.TheMarket.Domain.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">',"",$r);
$response2 = str_replace("</RegisterMarketResult>","",$response1);
I
erhalten ändernWarning: simplexml_load_string(): namespace error : Namespace prefix a on Cabinets is not defined in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): nets xmlns:b="http://schemas.datacontract.org/2004/07/Synectic.TheMarket.Domain" in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string():^in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): namespace error : Namespace prefix a on CompanyId is not defined in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): /b:ModelCategory><b:Products>2</b:Products></b:Cabinet></a:Cabinets><a:CompanyId in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string():^in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): namespace error : Namespace prefix a on CompanyName is not defined in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): ><a:CompanyId>{*****}</a:CompanyId><a:CompanyName in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string():^in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): namespace error : Namespace prefix a on DateCreated is not defined in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): ****}</a:CompanyId><a:CompanyName>**</a:CompanyName><a:DateCreated in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string():^in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): namespace error : Namespace prefix a on Id is not defined in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): e>**</a:CompanyName><a:DateCreated>2016-07-16T07:55:15.84</a:DateCreated><a:Id in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string():^in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): namespace error : Namespace prefix a on MarketNumber is not defined in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string(): :DateCreated>2016-07-16T07:55:15.84</a:DateCreated><a:Id>1</a:Id><a:MarketNumber in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
Warning: simplexml_load_string():^in /Applications/XAMPP/xamppfiles/htdocs/untitled/index.php on line 66
object(SimpleXMLElement)#1 (0) { }
Was scheint mehr der richtigen Richtung, aber immer noch gebrochen.
Kann jemand helfen, diese Sache zu parsen?