【发布时间】:2010-03-18 20:12:13
【问题描述】:
我正在开发一个提供肥皂接口的系统。将使用该接口的系统之一是在 Delphi 7 中编写的。Web 服务是使用 WCF、基本 http 绑定、SOAP 1.1 开发的。
如果我使用 SOAP UI (JAVA),服务可以正常工作。但是Delphi似乎在这里做了一些特别的事情;)
这是消息在 SOAP UI 中的样子:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.xxx.de/xxx">
<soapenv:Header/>
<soapenv:Body>
<ser:GetCustomer>
<!--Optional:-->
<ser:GetCustomerRequest> <!-- this is a data contract -->
<ser:Id>?</ser:Id>
</ser:GetCustomerRequest>
</ser:GetCustomer>
</soapenv:Body>
</soapenv:Envelope>
我不是 delphi 开发人员,但我开发了一个简单的测试客户端来看看出了什么问题。这就是 Delphi 作为 SOAP 信封发送的内容。
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="http://services.xxx.de/xxx">
<NS1:GetCustomer xmlns:NS1="http://services.xxx.de/xxx">
<GetCustomerRequest href="#1"/>
</NS1:GetCustomer>
<NS2:GetCustomerRequest id="1" xsi:type="NS2:GetCustomerRequest">
<Id xsi:type="xsd:int">253</Id>
</NS2:GetCustomerRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WCF 抛出德语错误... ;)
Es wurde das Endelement "Body" aus Namespace "http://schemas.xmlsoap.org/soap/envelope/" erwartet。 Gefunden wurde "元素 "NS2:GetCustomerRequest" aus 命名空间 "http://services.xxx.de/xxx""。 Zeile 1,位置 599。
意思类似
身体是预期的。但是找到了元素“NS2:GetCustomerReques”。
现在我的问题是:我能以某种方式改变 Delphi 创建信封的方式吗?或者是使 WCF 使用这种消息格式的方法吗?非常感谢任何帮助!
【问题讨论】:
-
问题不在于 NS1 NS2 部分。问题是 Delphi 正在制作结构不正确的 XML。 Web 服务似乎期望 GetCustomerRequest 嵌套在 GetCustomer 中,但 Delphi 客户端没有嵌套 GetCustomerRequest 元素。我不知道如何解决它。您是否使用 WCF 服务中的 WSDL 生成了 Delphi 客户端?