如何阻止 PHP SoapClient 将请求中的 s1:char 参数转换为 0 或 1
PHP 的 Soap 客户端在构建请求时似乎错误地处理了 s1:char 类型的参数。 Soap API 需要“Y”或“N”,但在请求 XML 中我得到“0”。 (传递 Bool true 会导致“1”,但不接受 API 来代替“Y”)。
我正在使用 PHP 版本 5.3.8 和本机 Soap 客户端
这是我的 PHP
$this->soapClient = new SoapClient( $client->wsdl,
array(
'soap_version' => SOAP_1_2,
'trace' => true
)
);
$result = $this->soapClient->SomeSoapMethod(array(
'sSessionKey' => $sessionKey,
// other string and int args that work fine here
'cReturnNonSeats' => 'Y' // API wants 'Y' or 'N'
));
请求 XML 中的相关 XML 节点:
<ns1:cReturnNonSeats>0</ns1:cReturnNonSeats>
以及来自 WSDL:
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="cReturnNonSeats" type="s1:char" />
</s:sequence>
</s:complexType>
无需手动构建 XML,有没有一种方法可以控制这些参数是类型转换的吗?
PHP's Soap client appears to be handling arguments with type s1:char incorrectly when building the request. The Soap API requires either 'Y' or 'N' but in the request XML I get '0'. (Passing Bool true results in '1' but that isn't accepted as API in place of 'Y').
I'm using PHP Version 5.3.8 with the native Soap Client
Here's my PHP
$this->soapClient = new SoapClient( $client->wsdl,
array(
'soap_version' => SOAP_1_2,
'trace' => true
)
);
$result = $this->soapClient->SomeSoapMethod(array(
'sSessionKey' => $sessionKey,
// other string and int args that work fine here
'cReturnNonSeats' => 'Y' // API wants 'Y' or 'N'
));
The relevant XML node in the request XML:
<ns1:cReturnNonSeats>0</ns1:cReturnNonSeats>
And from the WSDL:
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="cReturnNonSeats" type="s1:char" />
</s:sequence>
</s:complexType>
Without getting into building XML manually, is there a way I can have some control over how these arguments are typecast?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我解决这个问题的方法,尽管我现在想知道为什么 SoapClient 将该字符串转换为 int。
我使用的不是参数数组中的“Y”:
This is how I got around it though I'd like to now why SoapClient is converting that string to int.
Instead of 'Y' in my array of parameters, I used: