我使用PHP SoapClient並將信用卡號碼作爲值之一傳遞。這個數字被soapCall方法轉換爲指數格式。我通過了4321432143274321,服務器正在變得<ccNumber xsi:type="xsd:double">4.3214321432743E+15</ccNumber>
。我試着把這個值作爲一個雙精度值和一個字符串無效。如何防止PHP SoapClient將雙精度值轉換爲科學計數?
我無法在任何地方發現這個問題的任何提示!我找到的最接近的是:http://www.php.net/manual/en/soapclient.soapcall.php#75078,但「修復」並不是一個真正的修復。
這裏是我的代碼:
private function SetUpClient()
{
try
{
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$auth->username = $this->_username;
$auth->password = $this->_password;
$authValues = new SoapVar($auth, SOAP_ENC_OBJECT);
$header = new SoapHeader("http://v1.webservices", "authentication", $authValues, false);
$this->_soapClient = new SoapClient($this->_wsdlUrl);
$this->_soapClient->__setSoapHeaders(array($header));
}
catch(Exception $ex)
{
var_dump($ex);
return "An error occured: " . $ex->getMessage();
}
}
public function CallWebService($methodName, $arguments)
{
try {
$result = $this->_soapClient->__soapCall($methodName, $arguments);
}
catch (Exception $e) {
echo $e->getMessage();
$result = false;
}
return $result;
}
這裏是正在傳遞的$參數數組:
Array
(
[memberUid] => 123456789
[items] => 1809,1,N,1821,1,N
[shippingOption] => 40
[name1] => Test15, Juan
[name2] =>
[address1] => 123 Test Street
[address2] =>
[address3] =>
[address4] =>
[city] => Anytown
[stateCode] => NY
[countryCode] => USA
[postalCode] => 12345
[subOrderType] => 041
[entryDate] => 08/18/2011
[ccType] => 3
[ccHolder] => Juan Test
[ccNumber] => 4321432143274321
[ccExpDate] => 01/2014
[externalOrderNumber] =>
[orderSource] =>
)
最後肥皂的部分調用服務器是看到:
<ns1:createOrder>
<memberUid xsi:type="xsd:string">123456789</memberUid>
<items xsi:type="xsd:string">1809,1,N,1821,1,N</items>
<shippingOption xsi:type="xsd:double">40</shippingOption>
<name1 xsi:type="xsd:string">Test, Juan</name1>
<name2 xsi:type="xsd:string"/>
<address1 xsi:type="xsd:string">123 Test Street</address1>
<address2 xsi:type="xsd:string"/>
<address3 xsi:type="xsd:string"/>
<address4 xsi:type="xsd:string"/>
<city xsi:type="xsd:string">Anytown</city>
<stateCode xsi:type="xsd:string">NY</stateCode>
<countryCode xsi:type="xsd:string">USA</countryCode>
<postalCode xsi:type="xsd:string">12345</postalCode>
<subOrderType xsi:type="xsd:string">041</subOrderType>
<entryDate xsi:type="xsd:string">08/19/2011</entryDate>
<ccType xsi:type="xsd:double">3</ccType>
<ccHolder xsi:type="xsd:string">Juan Test</ccHolder>
<ccNumber xsi:type="xsd:double">4.3214321432743E+15</ccNumber>
<ccExpDate xsi:type="xsd:string">01/2014</ccExpDate>
<externalOrderNumber xsi:type="xsd:string"/>
<orderSource xsi:type="xsd:string"/>
</ns1:createOrder>
我發現了幾個類似的問題: https://bugs.php.net/bug.php?id=43053(我使用PHP 5.3.4) http://www.jitterbit.com/ PhpBB/viewtopic.php?f = 4&p = 7319#p7317 – Juan