【问题标题】:Call Web Service and Return Error in Delphi 7在 Delphi 7 中调用 Web 服务并返回错误
【发布时间】:2015-05-04 12:07:12
【问题描述】:

我在 Delphi 7 中导入了一个 WSDL 并在其上调用一个函数,将显示错误消息:

Project Project1.exe 引发异常类 ERemotableException,并带有消息“服务器无法处理请求。 ---> 一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性。进程停止。使用 Step 或 Run 继续。

当我使用 Fiddler 软件调用 WebService 方法(在 Delphi 7 中)时,我收到了发布的消息内容(XML):

<?xml version="1.0"?>
<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/"><NS1:Save xmlns:NS1="http://tempuri.org/"><from xsi:type="xsd:string">1</from><to xsi:type="xsd:string">2</to><body xsi:type="xsd:string">ServiceTest</body></NS1:Save></SOAP-ENV:Body></SOAP-ENV:Envelope>

然后我在 Delphi XE5 中调用相同的方法和 Web 服务,没有错误,并且这个 XML 内容:

<?xml version="1.0"?>
<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"><SOAP-ENV:Body><Save xmlns="http://tempuri.org/"><from>1</from><to>2</to><body>ServiceTest</body></Save></SOAP-ENV:Body></SOAP-ENV:Envelope>

SOAP 服务器响应:

SOAP Web Service 使用 .NET 框架编写,支持 SOAP 1.1 和 1.2

有什么想法吗?

【问题讨论】:

  • Delphi 7 太旧了,为什么要使用那个版本的向导?
  • @mjn ,我已经安装了更新,但再次显示相同的错误
  • 您能否格式化 XML 请求示例,以便更容易看到其中的细微差别?
  • @whosrdaddy ,这是一个大而老的项目,我别无选择。

标签: web-services delphi wsdl delphi-7 delphi-xe5


【解决方案1】:

我已使用 THTTPRIO.OnBeforeExecute 更改 SOAPResponse。然后删除不必要的属性并输入 XML 源并再次打包并将其分配给 SOAPResponse 并发送。

用这种方法问题解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-27
    • 2013-09-13
    • 2011-01-26
    • 2011-05-05
    • 2015-11-18
    • 2012-01-08
    • 2018-05-29
    相关资源
    最近更新 更多