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

查看:12
本文介绍了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 上托管此服务,并使用带有 mex 端点的 basicHttpBinding 公开它.我可以在 .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,它生成了一个源代码单元(顺便说一句,它生成了奇怪的类来封装字符串类型.为什么它不能与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:

由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action '' 的消息.这可能是因为合同不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配.检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无).

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 客户端以更改绑定或安全参数的方法.我该如何解决这个问题?

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天全站免登陆