在Delphi Win32 Client中消耗WCF服务(basicHttpBinding)的问题 [英] Problem in consuming WCF service (basicHttpBinding) in Delphi Win32 Client

查看:137
本文介绍了在Delphi Win32 Client中消耗WCF服务(basicHttpBinding)的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使Delphi客户端(Delphi 2006)与使用WCF编写的服务进行通信。服务是简单的只有一个功能。技术上如下:

I am trying to make a Delphi client (Delphi 2006) to communicate with a service written using WCF. Service is damn simple with just one function. Technically like below:

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

我已经在IIS上托管了这项服务,并使用basicHttpBinding和mex终点。我可以在.NET客户端中使用它。

I have hosted this service on IIS and exposed it using basicHttpBinding with mex end point. I am able to use it in .NET clients.

我尝试运行WSDLImp.exe并生成了一个源代码单元(btw,它生成wierd类来封装字符串类型,为什么不能像Delphi的字符串类型一样)当我尝试调用这个服务时,我得到例外:

I tried to run WSDLImp.exe and it generated a source code unit (btw, it generates wierd classes to encapsulate string type. Why cant it be same as Delphi string type?). When I try to call this service, I get the exception:


在接收器上无法处理带有Action'的消息,因为EndpointDispatcher中的ContractFilter不匹配。这可能是因为合同不匹配(发件人和接收方之间的操作不匹配)或发件人和接收方之间的绑定/安全性不匹配。检查发件人和接收方是否具有相同的合同和相同的约束(包括安全性要求,例如邮件,传输,无)。

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).

I没有任何方法配置Delphi Win32客户端来更改绑定或安全参数。如何解决这个问题?

I don't see any way to configure the Delphi Win32 client to changing the binding or security parameters. How can I fix this problem?

推荐答案

我有完全相同的问题。 Delphi刚刚导入了WCF公开的WSDL。一个解决方案是为您的服务添加一个ASMX包装器,并使用Delphi客户端。

I've had the exact same problem. Delphi just has hard time importing the WSDL exposed by WCF. One solution is to add an ASMX wrapper to your service and use that with Delphi clients.

这里有一个例子:

[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);
    }
}

这篇关于在Delphi Win32 Client中消耗WCF服务(basicHttpBinding)的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆