如何使用 PHP Soap 服务器返回自定义类型?
我使用 PHP SoapServer 在非 wsdl 模式下工作。我将服务器设置为处理数据并使用 setClass() 返回响应。我尝试返回一个关联数组,但这会转换为包含项目、键和值的 SOAP 映射。我想回应以下内容:
<soap:Body>
<AsyncResponseOperationResponse xmlns="http://www.sample.com/">
<AsyncResponseOperationResult>
<Succeeded>true</Succeeded>
<Comments>
The operation was a success
</Comments>
</AsyncResponseOperationResult>
</AsyncResponseOperationResponse>
</soap:Body>
变量是成功是真是假,以及评论。
我一直在尝试阅读有关“typemap”选项的信息,但它没有很好的记录,到目前为止我所发现的内容只会让我更加困惑。到目前为止我找到的资源是 php 单元测试,例如 这个 和 这个 ,以及 这个 stackoverflow 问题
任何人都可以给我提供一个例子吗做我想做的事吗?我想我可以切换到带有自动发现功能的 wsdl 模式(使用 Zend 的 Soap Server),如果这能作为解决方案的话。
编辑:在我弄清楚如何以正确的方式完成之前,我只是手动写出所有 XML。
header("Content-type: text/xml");
echo "<?xml version="1.0" encoding="utf-8"?><soap:Envelope ...
I'm in with PHP SoapServer working in non-wsdl mode. I have the server set up to handle the data and return a response using setClass(). I tried returning an associative array, but that translates into SOAP maps with items, keys and values. I'd like to respond with the following:
<soap:Body>
<AsyncResponseOperationResponse xmlns="http://www.sample.com/">
<AsyncResponseOperationResult>
<Succeeded>true</Succeeded>
<Comments>
The operation was a success
</Comments>
</AsyncResponseOperationResult>
</AsyncResponseOperationResponse>
</soap:Body>
The variables would be whether success is true or false, and the comments.
I've been trying to read about the 'typemap' option, but it is not very well documented, and what I've found so far has only confused me further. The resources I've found so far are the php unit tests, like this one and this one, as well as this stackoverflow question
Can anyone provide me an example that does what I'm trying to do? I think I would be alright switching to wsdl mode with autodiscover (using Zend's Soap Server), if that comes up as a solution.
Edit:Until I figure out how to do it the right way, I'm just writing out all the XML manually.
header("Content-type: text/xml");
echo "<?xml version="1.0" encoding="utf-8"?><soap:Envelope ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论