【发布时间】:2015-03-24 17:38:48
【问题描述】:
我正在运行一个 PHP SoapServer。这是我可以在请求正文中获取的请求示例:
<MyFunctionRequest>
<Item>
<Param Attr="XX">Value</Param>
</Item>
</MyFunctionRequest>
问题是,我似乎无法在我的 SoapServer 函数中读取属性 Attr。如果我打印在 SoapServer 函数中获得的参数,我会得到:
StdClass Object
(
[Item] => stdClass Object
(
[Param] => Value
)
)
我的 SoapServer 是这样构建的:
<?php
class MySoapServer {
public function index() {
$server = new SoapServer($pathToWsdl);
$server->addFunction(array('MyFunction'));
}
}
function MyFunction($params) {
log(print_r($params, true));
// function code, need the attribute Attr somewhere in here
}
那么如何在我的函数代码中获取属性 Attr 呢?谢谢。
【问题讨论】:
-
你解决了吗?我也有同样的问题
-
我最终通过使用
$postdata = file_get_contents("php://input");将原始请求 XML 作为字符串来解决它,然后我从该字符串中提取了属性。 -
是的,我也这样做了。
标签: php xml web-services soap