Delphi WSDL返回nil

问题描述

我刚接触WSDL服务,并且在从该服务收到的响应中遇到问题,技术细节是:

1-服务是使用C#和.pas文件中的描述构建的:

  // Namespace : http://tempuri.org/
  // soapAction: http://tempuri.org/IService/%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // use       : literal
  // binding   : BasicHttpBinding_IService
  // service   : Service
  // port      : BasicHttpBinding_IService
  // URL       : http://website.com/WCF/ServiceRegistryWCF.Service.svc

IService= interface(IInvokable)

2- .pas文件中的主要对象描述:

  // XML       : InOut,global,<complexType>
  // Namespace : http://schemas.datacontract.org/2004/07/MySDK.Accomodation
  InOut2 = class(IBusinessObject2)

3-我按以下方式致电服务

var
  Form1: TForm1;
  HRIO: THTTPRIO;
procedure MyProcedure();
var
  ioObj: InOut2;
  res: string;
begin
  HRIO := THTTPRIO.Create(nil);
  HRIO.OnAfterExecute := THRIOActions.HTTPRIO1AfterExecute;
  HRIO.OnBeforeExecute := THRIOActions.HTTPRIO1BeforeExecute;
  HRIO.WSDLLocation := 'http://website.com/WCF/ServiceRegistryWCF.Service.svc?wsdl';
  HRIO.Service := 'Service';
  HRIO.Port := 'BasicHttpBinding_IService';
  HRIO.HTTPWebNode.InvokeOptions := [soIgnoreInvalidCerts,soAutoCheckAccessPointViaUDDI];
  HRIO.Converter.Options := HRIO.Converter.Options + [soDocument,soLiteralParams];
  HRIO.Converter.Encoding := 'utf-8';

  ioObj := InOut2.Create;
  ioObj.UserName := '1234567890';
  ioObj.Password := '123456';
  ioObj.InOutID := 123456789;

  res := (HRIO as IService).ProcedureName('password',ioObj,0);
  memo1.lines.add(res);
end;

当我通过两个过程(“ HTTPRIO1AfterExecute”,“ HTTPRIO1BeforeExecute”)跟踪该过程时,我发现结果如下:

请求文本:

<?xml version="1.0" encoding="utf-8"?>
    <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>
        <ProcedureName xmlns="http://tempuri.org/">
            <LocalPassword>password</LocalPassword>
            <io>
                <InOutID xmlns="http://schemas.datacontract.org/2004/07/MySDK.Accomodation">
                    123456789
                </InOutID>
                <Password xmlns="http://schemas.datacontract.org/2004/07/MySDK.Accomodation">
                    123456
                </Password>
                <UserName xmlns="http://schemas.datacontract.org/2004/07/MySDK.Accomodation">
                    1234567890
                </UserName>
            </io>
            <language>0</language>
        </ProcedureName>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

响应文本:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <ProcedureNameResponse xmlns="http://tempuri.org/">
            <ProcedureNameResult i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
        </ProcedureNameResponse>
    </s:Body>
</s:Envelope>

最终结果是:

<ProcedureNameResult xmlns="http://tempuri.org/" i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>

但是如果发生错误,它必须是True或文本消息,并且您可以看到,结果与预期的不同。

我对此表示歉意,但我试图解释所有可能的细节。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...