WCF Delphi7 method input parameters

自闭症网瘾萝莉.ら 提交于 2019-12-22 06:37:19

问题


I've got wcf web-service(basicHttpBinding). Our Delphi7 clients couldn't correct consume it. I've already flatten the WSDL with WCF extras. Ok. Delphi7 wsdl importer generate proxy correct.

Now I've got the problems with input parameters. they always have default values (empty for strings, 0 for int).

Output values from methods delphi7 gets ok. for example:

        public string Test(string a)
        {
              return "Test"+a;
        }

This method always return "Test". My logging system fix that I've got empty a at method, so the problem is correct transfer input parameters.

I can't undersand what's wrong

EDIT

proxy:

ISyncer = interface(IInvokable)
  ['{D46862B0-BDD3-8B80-35A8-A2AC69F24713}']
    function  Test(const a: String): String; stdcall;
  end;

call:

Sync:=(dmMain.HTTPRIO1 as ISyncer);
test:=Sync.Test('5555');

dmMain.HTTPRIO1 has soLiteralParams at options:

init:

InvRegistry.RegisterInvokeOptions(TypeInfo(ISyncer), ioLiteral);

After call I get exception with message:

Error deserializtion message body for operation Test. 
Operation formatter detects ivalid message body. Expecting node type "Element"
with name "Test" and namespace "http://tempuri.org". Actually node type "Element"
with name "xsd:String" and namespace "http://w3.org/2001/XMLSchema"

wsdl fragment:

<xsd:element name="Test">
−
<xsd:complexType>
−
<xsd:sequence>
<xsd:element minOccurs="0" name="a" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="TestResponse">
−
<xsd:complexType>
−
<xsd:sequence>
<xsd:element minOccurs="0" name="TestResult" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

EDIT2

I research http requests:

.NET

<Test> xmlns="http://tempuri.org/"><a>5555</a></Test>

works correct;

Delph7

<Test xmlns="http://tempuri.org/"><xsd:a>5555</xsd:a></Test>

null input parameter. The problem is in prefix xsd


回答1:


Delphi uses RPC/Encoded SOAP whereas WCF uses Document/Literal/Wrapped SOAP. So you need to tell Delphi to use the same format. You could do this by specifying soLiteralParams in the THttpRio.Converter.Options.




回答2:


I've done it. I fixed soap envelope at every service sonsume through event handler OnBeforeExecute of THttpRio.

I fix(remove namespace prefixes) and it works. Thanks



来源:https://stackoverflow.com/questions/6173733/wcf-delphi7-method-input-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!