【问题标题】:Cause .net WCF client to use RPC/encoded instead of Document/Literal/Wrapped with Delphi service导致 .net WCF 客户端使用 RPC/encoded 而不是 Document/Literal/Wrapped with Delphi 服务
【发布时间】:2011-07-14 19:58:03
【问题描述】:

我有一个基于 Delphi 服务构建的 .Net WCF 客户端/代理。 Delphi 服务以我的客户端无法处理的格式提供 SOAP 消息。

根据此处的指导:Delphi SOAP Envelope and WCF 我了解到 WCF 期望“文档/文字/包装”样式是消息序列化的方式。事实证明,Delphi 服务使用“rpc”作为样式。

我无法让 delphi 服务更改其样式。

有没有办法让 WCF 客户端改用“rpc”。

作为参考,这是我正在构建的 Delphi 服务:http://www.tntschools.com/AkiTimeTableService/wsdl/ICourses

【问题讨论】:

  • 您是如何创建客户端/代理的?通过Add Service Reference 还是您手动构建的?
  • 我使用“添加服务参考”来构建它。
  • 请看下面的答案。请发布您在 WCF 客户端中遇到的异常消息。

标签: .net wcf delphi interop rpc


【解决方案1】:

以这种方式添加服务引用时,每个生成的消息契约都以类似的方式装饰:

[DebuggerStepThrough]
[GeneratedCode( "System.ServiceModel", "4.0.0.0" )]
[MessageContract( WrapperName = "GetCourseList", WrapperNamespace = "urn:CoursesIntf-ICourses",
    IsWrapped = true )]
public partial class GetCourseListRequest
{
    [MessageBodyMember( Namespace = "", Order = 0 )]
    public string licence;

    public GetCourseListRequest()
    {
    }

    public GetCourseListRequest( string licence )
    {
        this.licence = licence;
    }
}

每个生成的操作合约都以类似的方式装饰:

[GeneratedCode( "System.ServiceModel", "4.0.0.0" )]
[ServiceContract( ConfigurationName = "ServiceReferences.ICourses" )]
public interface ICourses
{
    [OperationContract( Action = "urn:CoursesIntf-ICourses#GetCourseList", ReplyAction = "*" )]
    [XmlSerializerFormat( Style = OperationFormatStyle.Rpc, SupportFaults = true,
        Use = OperationFormatUse.Encoded )]
    [ServiceKnownType( typeof( TCourse ) )]
    GetCourseListResponse GetCourseList( GetCourseListRequest request );

    // Remaining operation contracts omitted
}

检查Reference.cs 以确定您的消息和操作合同是否以相同的方式装饰。如果是,问题就出在其他地方。异常消息有助于追踪问题(例如,它可能是返回的 SOAP 消息中元素的顺序)。

【讨论】:

  • 我接受这个是因为我问错了问题,但这是该问题的答案。
  • 好吧,事实证明 Delphi 服务虽然配置为 rpc 样式,但发送元素的顺序是我的 WCF 组件无法理解的。 (哎呀,我仍在试图了解发回的内容)。随着我越来越清楚,我将更新此评论线程。
  • @Irwin:请参阅IClientMessageInspector,了解如何实现IClientMessageInspectorIEndpointBehavior。 Delphi 服务的回复消息可以在AfterReceiveReply 方法中查看。在那里,您也可以重新格式化您的消息,以便您的 WCF 组件能够反序列化回复消息。
  • @RestWing 这很有帮助
猜你喜欢
  • 2023-03-29
  • 2012-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多