Delphi SOAP Envelope and WCF

后端 未结 3 1530
孤街浪徒
孤街浪徒 2020-12-05 01:41

I am working on a system that provides a soap interface. One of the systems that are going to use the interface is coded in Delphi 7. The web service is developed with WCF,

3条回答
  •  被撕碎了的回忆
    2020-12-05 01:47

    Contrary to what some people here seem to be implying, Delphi is not sending invalid SOAP, it is simply sending RPC/Encoded SOAP. It's very easy to recognize from all the xsi:type attributes. RPC/Encoded is not WS-I compliant but it is still valid SOAP.

    WCF, by default, uses the Document/Literal/Wrapped SOAP format, which Delphi 7 can't handle at all on the server side and you have to make some adjustments on the client side.

    The simplest solution is to simply tell Delphi to use the Document/Literal style. You do that by turning on soLiteralParams in the THttpRio.Converter.Options. This tells Delphi not to "unwind" the parameters as you are seeing. The "Document" aspect is something that the Delphi WSDL importer can usually figure out so you shouldn't need to worry about that.

    The other solution is to tell the WCF service to use RPC/Encoded style, which you can do by adding the following attributes to the service:

    [ServiceContract]
    [XmlSerializerFormat(Style = OperationFormatStyle.Rpc,
        Use = OperationFormatUse.Encoded)]
    public interface IMyService
    {
        // etc.
    }
    

    The second is not recommended because, as I mentioned earlier, RPC/Encoded is not WS-I compliant, but nevertheless most SOAP toolkits do recognize it, so I list it here as a possibility.

提交回复
热议问题