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

发布于 2024-07-26 11:07:19 字数 731 浏览 9 评论 0原文

我正在尝试创建一个 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 字符串类型相同?)。 当我尝试调用此服务时,出现异常:

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

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

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

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.

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:

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 don't see any way to configure the Delphi Win32 client to changing the binding or security parameters. How can I fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

客…行舟 2024-08-02 11:07:19

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

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.

Here's an example:

[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);
    }
}
迎风吟唱 2024-08-02 11:07:19

您需要查看客户端和服务之间的网络流量以了解发生了什么情况。 或者,打开服务上的 WCF 跟踪,可能包括消息跟踪。 您应该能够非常详细地看到正在发生的事情。

You need to look at the network traffic between the client and service to see what's going on. Alternatively, turn on WCF tracing on the service, possibly including message tracing. You should be able to see what's going on, in great detail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文