我发出了一个PHP SOAP请求,该请求返回一个完整的内容转储,我该如何格式化它?在此之前从未使用过xml或PHP、SOAP?代码:
<?php
$client = new SoapClient('http://www.autobid.co.za/halfway/vehicledetails.php?wsdl');
$result = $client->getVehicleDetails('redacted','redacted');
echo('<p>'.$result.'</p>');
?>返回:
5002386176AHTHA3CD503427515BPSSZN1GD058155439845.00WHITE2019TOYOTAHILUX 2.8 GD-6 RAIDER 4X4 A/T P/U D/C60039521Full Service History with agentsSigns of cosmetic workhttp://www.autobid.co.za/images/image_5002386176.jpghttp://www.autobid.co.za/images/image_5002386176_1.jpghttp://www.autobid.co.za/images/image_5002386176_2.jpghttp://www.autobid.co.za/images/image_5002386176_3.jpghttp://www.autobid.co.za/images/image_5002386176_4.jpg541000.00541000.00Black leatherSpare Key: Yes,Bin Liner: Yes,Leather Seats: Yes,Tonneau Cover: Yes,Rollbar: Yes,Towbar: Yes,Bullbar: Yes,Other Extras/Comments: WHEEL ARCHES SIDE VISORS,5002371142AHTBB0JE400024849NX423391ZRV93623779342.00WHITE2019TOYOTACOROLLA 1.6 PRESTIGE CVT60027544Full Service History with agentsSigns of cosmetic workhttp://www.autobid.co.za/images/image_5002371142.jpghttp://www.autobid.co.za/images/image_5002371142_1.jpghttp://www.autobid.co.za/images/image_5002371142_2.jpghttp://www.autobid.co.za/images/image_5002371142_3.jpghttp://www.autobid.co.za/images/image_5002371142_4.jpg220000.00220000.00BlackSpare Key: Yes,5002366129AAVZZZ6SZBU019983ND606937CLP043956108334.00SILVER2011VOLKSWAGENPOLO VIVO 1.4 TRENDLINE TIP 5DR64020120Full Service History agent & non-agentSigns of cosmetic workhttp://www.autobid.co.za/images/image_5002366129.jpghttp://www.autobid.co.za/images/image_5002366129_1.jpghttp://www.autobid.co.za/images/image_5002366129_2.jpghttp://www.autobid.co.za/images/image_5002366129_3.jpghttp://www.autobid.co.za/images/image_5002366129_4.jpg75000.0075000.00GreySpare Key: Yes,5002364072JTMZ43FV70D511939ND842882M20AV1456899963.00WHITE2020TOYOTARAV4 2.0 GX CVT60077613Not due for service yetSigns of cosmetic workhttp://www.autobid.co.za/images/image_5002364072.jpghttp://www.autobid.co.za/images/image_5002364072_1.jpghttp://www.autobid.co.za/images/image_5002364072_2.jpghttp://www.autobid.co.za/images/image_5002364072_3.jpghttp://www.autobid.co.za/images/image_5002364072_4.jpg416000.00416000.00Black5002357702AHTLB52E003096386ND1467581ZRV044055127338.00WHITE2015TOYOTACOROLLA QUEST 1.660010250Full Service History with agentsSigns of cosmetic
我需要它在一个更好的格式方法,而不是像这样的转储,从来没有使用SOAP或PHP在此之前,所以让它到这一点,但现在想要一个更好的数据表示,请协助,如果你可以,非常感谢!
发布于 2021-06-08 21:07:17
<?php
$client = new SoapClient('http://www.autobid.co.za/halfway/vehicledetails.php?wsdl');
$result = $client->getVehicleDetails('redacted','redacted');
var_dump(simplexml_load_string($result));如果您使用var_dump,您可以看到它返回一个字符串。在这种情况下,字符串包含XML数据,可以通过simplexml解析这些数据以接收对象。您的方法返回字符串的事实也反映在wsdl文件中:
<message name="getVehicleDetailsResponse">
<part name="return" type="xsd:string"/>
</message> https://stackoverflow.com/questions/67887126
复制相似问题