wcf - Delphi Win32客户端中使用WCF服务(basicHttpBinding)的问题

标签 wcf delphi soap delphi-2006

我正在尝试创建一个 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 客户端来更改绑定(bind)或安全参数。我该如何解决这个问题?

最佳答案

我也遇到过同样的问题。 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);
    }
}

关于wcf - Delphi Win32客户端中使用WCF服务(basicHttpBinding)的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1090611/

相关文章:

delphi - '23/02/2011 12 :34:56' is not valid date and time

c# - 如何在 WSDL 中定义一组自定义类型?

c# - 从 .NET 调用基于 AXIS 的 Web 服务时,永远不会填充嵌套的复杂类型元素

c# - 保存到 SQL Server 时附加到文件的字节

.net - 避免 Web 服务神类

delphi - 如何在 Firemonkey 中加载自定义光标?

delphi - 连接正常关闭 Indy TCPServer Mobile App Delphi XE8

javascript - 在 Express 中监听 SOAP 请求

c# - WCF 可以使用 https 访问 SOAP 1.1 服务吗?

c# - WCF:提供的 URI 方案 'https' 无效;预计 'http' 。参数名称:通过当我调用 IInternal proxy = factory.CreateChannel();在客户端