尝试遍历返回的地址列表,选择一个并提交到下一个php文件
这个有点麻烦 这是SOAP WSDL API系统的一部分。 我向SOAP API发送一个街道地址,它会查找并返回一个有效地址的WSDL列表。我应该能够单击正确的结果,然后将其提交到我的第二个php文件以进一步处理并发送到SOAP API 我得到了这样的回复(应该有多个地址,但这是一个测试环境,所以只能得到这个地址。在live platform中,我会得到多个地址)尝试遍历返回的地址列表,选择一个并提交到下一个php文件,php,soap,wsdl,Php,Soap,Wsdl,这个有点麻烦 这是SOAP WSDL API系统的一部分。 我向SOAP API发送一个街道地址,它会查找并返回一个有效地址的WSDL列表。我应该能够单击正确的结果,然后将其提交到我的第二个php文件以进一步处理并发送到SOAP API 我得到了这样的回复(应该有多个地址,但这是一个测试环境,所以只能得到这个地址。在live platform中,我会得到多个地址) NBN ; }; //当用户从列表中选择位置ID时,我们将其
NBN
;
};
//当用户从列表中选择位置ID时,我们将其提交到下一个文件->qualify.php
回声“
”;
echo json_编码($locidRes);
然而,我得到了这个错误
请从列表中选择一个位置
致命错误:未捕获错误:无法将stdClass类型的对象用作/var/www/html/getLocationId.php:70堆栈跟踪中的数组:#0{main}在第70行的/var/www/html/getLocationId.php中抛出
提前感谢,
Steve在该响应中没有
locationId
或displayAddress
元素。为什么你希望它们出现在那里?另外,在php中,关联数组和对象是不同的野兽,所以如果你需要访问这些属性,它们将是$l->locationId
和$l->displayAddress
。嗨,Frederico,对不起,上面的正确响应更新了。很好,关于房产类型。好的,你试过我在第二条评论中的建议了吗?还是不行吗?我之前确实试过了,但又出了一个错误。我现在再试一次,然后再报告。
<?xml version="1.0" encoding="ISO-8859-1"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<FindServiceProviderLocationIdResponse xmlns="http://www.aapt.com.au/FrontierLink/xsd">
<serviceProviderLocationList>
<serviceProviderLocationList>
<serviceProvider>NBN</serviceProvider>
<locationList>
<addressInformation>
<serviceProvider>NBN</serviceProvider>
<locationId>LOC000000000002</locationId>
<address>
<streetNumber>6</streetNumber>
<streetName>TEST</streetName>
<streetType>STREET</streetType>
<suburb>GLEBE</suburb>
<state>NSW</state>
<postcode>2037</postcode>
</address>
<displayAddress>6 TEST ST GLEBE NSW 2037</displayAddress>
</addressInformation>
</locationList>
</serviceProviderLocationList>
</serviceProviderLocationList>
</FindServiceProviderLocationIdResponse>
</soapenv:Body>
</soapenv:Envelope>
//Display a list of address options to the user
echo '<h1>Please select a location from the list</h1>';
//Squirt out the address list for the user to pick from
foreach($locidRes as $l){
echo '<a href="qualify.php?locid='.$l['locationId'].'">'.$l['displayAddress'].'</a><br/>';
};
//When the user selects a location ID from the list, we then submit that to the next file -> qualify.php
echo '<hr/>';
echo json_encode($locidRes);