我有一个访问 SOAP 服务器的 PHP 脚本,但在访问 SOAP 调用的结果时遇到了一些问题。
下面的代码片段(我已经删除了一些设置 $client1 和身份验证标头的早期代码,因为我认为它们工作正常):
$output = $client1->GetSingleDiamond(array("DiamondID" => $diamondid));
$xmlDoc = new DOMDocument();
$xmlDoc->preserveWhiteSpace = false;
$xmlDoc->formatOutput = true;
$xmlDoc->loadXML($client1->__getLastResponse());
echo "<pre>" . htmlspecialchars($xmlDoc->saveXML()) . "</pre>";
产生以下结果:
<?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>
<GetSingleDiamondResponse xmlns="http://technet.rapaport.com/">
<GetSingleDiamondResult>
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="DiamondID" type="xs:int" minOccurs="0"/>
<xs:element name="ShapeTitle" type="xs:string" minOccurs="0"/>
<xs:element name="Weight" type="xs:decimal" minOccurs="0"/>
<xs:element name="ColorTitle" type="xs:string" minOccurs="0"/>
<xs:element name="ClarityTitle" type="xs:string" minOccurs="0"/>
<xs:element name="CutLongTitle" type="xs:string" minOccurs="0"/>
<xs:element name="LabID" type="xs:short" minOccurs="0"/>
<xs:element name="labTitle" type="xs:string" minOccurs="0"/>
<xs:element name="RapNetPrice" type="xs:decimal" minOccurs="0"/>
<xs:element name="FinalPrice" type="xs:decimal" minOccurs="0"/>
<xs:element name="CertificateNumber" type="xs:string" minOccurs="0"/>
<xs:element name="Act_No" type="xs:int" minOccurs="0"/>
<xs:element name="Company" type="xs:string" minOccurs="0"/>
<xs:element name="Name" type="xs:string" minOccurs="0"/>
<xs:element name="Email" type="xs:string" minOccurs="0"/>
<xs:element name="Phone" type="xs:string" minOccurs="0"/>
<xs:element name="COUNTRY" type="xs:string" minOccurs="0"/>
<xs:element name="STATE" type="xs:string" minOccurs="0"/>
<xs:element name="CITY" type="xs:string" minOccurs="0"/>
<xs:element name="VendorStockNumber" type="xs:string" minOccurs="0"/>
<xs:element name="SymmetryTitle" type="xs:string" minOccurs="0"/>
<xs:element name="PolishTitle" type="xs:string" minOccurs="0"/>
<xs:element name="DepthPercent" type="xs:decimal" minOccurs="0"/>
<xs:element name="TablePercent" type="xs:decimal" minOccurs="0"/>
<xs:element name="MeasLength" type="xs:decimal" minOccurs="0"/>
<xs:element name="MeasWidth" type="xs:decimal" minOccurs="0"/>
<xs:element name="MeasDepth" type="xs:decimal" minOccurs="0"/>
<xs:element name="GirdleSizeMin" type="xs:string" minOccurs="0"/>
<xs:element name="GirdleSizeMax" type="xs:string" minOccurs="0"/>
<xs:element name="GirdleConditionTitle" type="xs:string" minOccurs="0"/>
<xs:element name="CuletSizeTitle" type="xs:string" minOccurs="0"/>
<xs:element name="CuletConditionTitle" type="xs:string" minOccurs="0"/>
<xs:element name="FluorescenceColorTitle" type="xs:string" minOccurs="0"/>
<xs:element name="FluorescenceIntensityTitle" type="xs:string" minOccurs="0"/>
<xs:element name="HasCertFile" type="xs:boolean" minOccurs="0"/>
<xs:element name="DiamondLocationCountry" type="xs:string" minOccurs="0"/>
<xs:element name="DiamondLocationCity" type="xs:string" minOccurs="0"/>
<xs:element name="FinalPriceCurrency" type="xs:decimal" minOccurs="0"/>
<xs:element name="LastRate" type="xs:decimal" minOccurs="0"/>
<xs:element name="CurrencySymbol" type="xs:string" minOccurs="0"/>
<xs:element name="CurrencyShortTitle" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<DiamondID>46959935</DiamondID>
<ShapeTitle>Pear</ShapeTitle>
<Weight>0.340</Weight>
<ColorTitle>D</ColorTitle>
<ClarityTitle>SI2</ClarityTitle>
<LabID>1</LabID>
<labTitle>GIA</labTitle>
<RapNetPrice>337.2800</RapNetPrice>
<FinalPrice>489.0000</FinalPrice>
<CertificateNumber>1156352315</CertificateNumber>
<Act_No>39321</Act_No>
<Company>CHINA DIAMOND CORP LTD</Company>
<Name>Darshan Bhagat</Name>
<Email>info@chinadiamond.com.hk</Email>
<Phone>852-852-2521 0029</Phone>
<COUNTRY>HONG KONG</COUNTRY>
<STATE/>
<CITY>Hong Kong</CITY>
<VendorStockNumber>1156352315</VendorStockNumber>
<SymmetryTitle>Very Good</SymmetryTitle>
<PolishTitle>Excellent</PolishTitle>
<DepthPercent>62.9</DepthPercent>
<TablePercent>56.00</TablePercent>
<MeasLength>5.96</MeasLength>
<MeasWidth>3.88</MeasWidth>
<MeasDepth>2.44</MeasDepth>
<GirdleSizeMin>Slightly Thick</GirdleSizeMin>
<GirdleSizeMax>Very Thick</GirdleSizeMax>
<CuletSizeTitle>None</CuletSizeTitle>
<FluorescenceIntensityTitle>None</FluorescenceIntensityTitle>
<HasCertFile>true</HasCertFile>
<DiamondLocationCountry>Hong Kong</DiamondLocationCountry>
<DiamondLocationCity>Hong Kong</DiamondLocationCity>
<FinalPriceCurrency>489.0000</FinalPriceCurrency>
<LastRate>1.22995001</LastRate>
<CurrencySymbol>$</CurrencySymbol>
<CurrencyShortTitle>NZD</CurrencyShortTitle>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetSingleDiamondResult>
</GetSingleDiamondResponse>
</soap:Body>
</soap:Envelope>
我需要知道的是如何访问数据部分?例如,我将如何访问值为 489.0000 的 FinalPriceCurrency 数据?
我试过 $output->GetSingleDiamondResult->FinalPriceCurrency 但这不起作用。