加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在Delphi Win32 Client中使用WCF服务(basicHttpBinding)时出现问

发布时间:2020-12-15 10:11:43 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用Delphi客户端(Delphi 2006)与使用WCF编写的服务进行通信.只需一个功能,服务非常简单.技术上如下: [ServiceContract (Namespace = "http://www.company.com/sample/")]public interface IService{ [OperationContract] string GetNumber (stri
我正在尝试使用Delphi客户端(Delphi 2006)与使用WCF编写的服务进行通信.只需一个功能,服务非常简单.技术上如下:
[ServiceContract (Namespace = "http://www.company.com/sample/")]
public interface IService
{
    [OperationContract]
    string GetNumber (string name);
}

我已在IIS上托管此服务,并使用带有mex端点的basicHttpBinding将其公开.我可以在.NET客户端中使用它.

我试图运行WSDLImp.exe并且它生成了一个源代码单元(顺便说一句,它生成了用于封装字符串类型的奇怪类.为什么它不能与Delphi字符串类型相同?).当我尝试调用此服务时,我得到异常:

The message with Action ” cannot be processed at the receiver,due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements,e.g. Message,Transport,None).

我没有看到任何方法来配置Delphi Win32客户端来更改绑定或安全性参数.我该如何解决这个问题?

解决方法

我有完全相同的问题. Delphi很难导入WCF公开的WSDL.一种解决方案是将ASMX包装器添加到您的服务中,并将其与Delphi客户端一起使用.

这是一个例子:

[ServiceContract (Namespace = "http://www.company.com/sample/")]
public interface IService
{
    [OperationContract]
    string GetNumber (string name);
}

public class Service : IService
{
    public string GetNumber (string name)
    {
        return Repository.GetNumber(name);
    }
}

[WebService(
    Namespace = "http://www.company.com/sample/",Name = "wstest",Description = "description")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AsmxService : WebService
{
    [WebMethod]
    public string GetNumber(string name)
    {
        return Repository.GetNumber(name);
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读