5

使用 savon gem,我得到以下请求 XML:

<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:wsdl="URL" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:ins0="SOME URL">
        <soap:Body>
            <ins0:Test xmlns="SOME URL">
            </ins0:Test>
        </soap:Body>
    </soap:Envelope>

但它需要是这样的:

<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:wsdl="URL" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <Test xmlns="SOME URL">
            </Test>
        </soap:Body>
    </soap:Envelope>

通知ins0被删除。

有什么建议么?

4

1 回答 1

2

这两个 XML 文档是等价的,因此只要文档由符合 XML 的代理解析,就应该没有问题。

Savon 生成的文档只是为“SOME URL”命名空间创建了一个命名空间前缀 ins0。这对于包含来自该名称空间的许多元素的大型 SOAP 文档很方便。在这个例子中,前缀并不是真正需要的。

我能看到的唯一潜在问题是 Savion 生成的文档似乎两次声明了 ins0 命名空间 - 一次在soap:Envelope 中,然后再次在soap:Body 中。似乎是多余的并且可能容易出错。

于 2012-05-06T08:31:43.893 回答