使用 SimpleXML 对 XML 进行 SOAP 响应

发布于 2024-08-31 13:08:46 字数 612 浏览 2 评论 0原文

我正在尝试将 SOAP 响应转换为 XML。

SOAP 有一个信封和一个主体

<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>

当我尝试转换时

$responseXML = simplexml_load_string($string);

,我得到

object(SimpleXMLElement)#20 (0) { } 

If I edit the $string as soap:Envelope and soap:Body I可以获取XML。

: 有什么问题吗?无法获取 XML。

我希望一切都清楚。有人吗?

I am trying to convert a SOAP response to XML.

SOAP has an envelop and a body

<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>

When I try to convert

$responseXML = simplexml_load_string($string);

I get

object(SimpleXMLElement)#20 (0) { } 

If I edit the $string as soap:Envelope and soap:Body I can get the XML.

What's wrong with :? Can not get XML.

I hope it's clear. Anyone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浪荡不羁 2024-09-07 13:08:46

SOAP 消息已经是 XML。问题是它有命名空间,所以你必须以不同的方式访问它。 (冒号之前的部分是命名空间的标识符。)

此处(Google 缓存副本) 是通过 SimpleXML 使用命名空间的示例。
这里是读取 SOAP 消息的具体示例。

A SOAP message is already XML. The problem is that it has namespaces so you have to access it differently. (The part before the colon is the identifier for the namespace.)

Here (google cached copy) is an example of using namespaces with SimpleXML.
Here is a specific example for reading SOAP messages.

荭秂 2024-09-07 13:08:46

SimpleXML 需要对命名空间 XML 进行特殊处理(ref.)

SimpleXML requires special treatment for namespaced XML (ref.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文