使用 WCF Web 服务的 VB6 软件。 App.config 中的端点。错误 VB6 没有 App.config

发布于 2024-12-07 06:34:45 字数 1008 浏览 3 评论 0原文

我们有一个用 VB6 构建的 EPOS 系统。客户正在使用 Microsoft Dynamics AX 作为 CRM 系统。第三方为我们的客户创建了 AX 实现,并且他们公开了一组 WCF Web 服务,我们需要使用这些服务来同步 EPOS 和 AX CRM 之间的数据。我知道 VB6 在调用 WCF 服务时会出现问题,因此我创建了以下组件来处理 EPOS 和 AX CRM 之间的通信。

VB6 EPOS 调用 -->
1) VB6 DLL 包装器调用... -->
2) .NET(3.5) COM 可调用代理 DLL 包装器,它调用... -->
3) .NET(3.5) Web 服务处理程序(Web 服务实际被调用的地方) -->
微软Dynamics AX CRM。

我在 Vb.NET 中构建了一个测试控制台应用程序来模拟来自 VB6 的调用以帮助调试,以便测试控制台应用程序调用组件 2。

在执行此操作时,我收到以下异常:-

“(找不到引用的默认端点元素servicemodel 客户端配置部分中的合同“X”。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。)”

我搜索了一下,发现我有复制绑定并端点部分从组件 3 的 app.config 到我的测试控制台应用程序的新 app.config。我不了解 WCF,目前也没有时间真正学习它,直到我明白为什么可以修复此错误。

但现在,我尝试从 VB6 EPOS 调用服务,但此错误再次弹出。因此,我向组件 2 添加了一个 app.config,认为组件 2 是链中的第一个 .NET(3.5) 组件,这就是端点声明应该去的地方,但是不行。错误仍然弹出。

有人有什么想法吗?任何编程英雄都可以为一个傻瓜阐明这一点吗???请不要问我们为什么不重写EPOS。我们将。只是还没有。其中有超过 300 万行意大利面条式代码,而我只花了 8 个月的时间!

顺便说一句,这种情况是否违反了 OOP 的黄金法则之一,即封装。为什么我的 VB6 EPOS 需要知道组件 3 使用哪些端点来访问 WCF 服务???

We have an EPOS system that is built in VB6. A client is using Microsoft Dynamics AX as a CRM system. A 3rd party has created the AX implementation for our client and they've exposed a set of WCF web services that we need to consume to synchronise data between the EPOS and the AX CRM. Knowing VB6 would have issues calling WCF services, I created the following components to handle the communication between the EPOS and the AX CRM.

VB6 EPOS which calls -->
1) VB6 DLL wrapper which calls... -->
2) .NET(3.5) COM Callable Proxy DLL wrapper which calls... -->
3) .NET(3.5) Web Service Handler (Where the web servicesw actually get called) -->
Microsoft Dynamics AX CRM.

I built a test console app in Vb.NET to simulate calls from VB6 to help with debugging, so that test console app calls component 2.

Whilst doing this I was getting the following exception:-

"(could not find default endpoint element that references contract 'X' in the servicemodel client configuration section. this might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.)"

I googled around and found that I had to copy the bindings and endpoints section from Component 3's app.config to a new app.config for my Test Console app. I don't know WCF and haven't got the time at the moment, to really learn it to the point where I understand why this fixed this error.

Now though, I'm trying to call the services from the VB6 EPOS and this error is popping up again. So I added an app.config to Component 2, thinking that as Component 2 is the first .NET(3.5) component in the chain, that is where the endpoint declaration should go, but No. The error is still popping up.

Does anyone have any ideas? Any programming heroes out there that can shed some light on this for a simpleton please??? Please don't ask why we don't re-write the EPOS. We will. just not yet. Theres over 3 million lines of spaghetti code in there and I've only been working on it for 8 months!!!

As an aside, Doesn't this scenario break one of the golden rules of OOP, i.e. encapsulation. Why should my VB6 EPOS need to know what endpoints Component 3 uses to access the WCF service???

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

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

发布评论

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

评论(1

月寒剑心 2024-12-14 06:34:45

这是一个很好的问题...

您的问题本质上是来自使用 WCF 服务所需的所有必需配置数据。

处理 .NET Windows 或 Web 应用程序时,WCF 服务的客户端和服务器端的配置数据都驻留在应用程序配置文件中。对于 Windows 应用程序,该文件为 app.config,而对于 Web 应用程序,该文件为 web.config。

在您的情况下,您希望将代理逻辑放入某种形式的 COM 可见的 .dll 中。

这会给你带来一些悲伤......在 .NET 平台中,顶级主机应用程序(Web 或 Windows)的 .config 文件是读取所有配置数据的地方。即使您的应用程序利用数十个 .NET 程序集(每个程序集都有自定义配置需求),运行时也将期望这些配置元素全部驻留在最顶层的应用程序配置文件中。

要解决您的问题,您需要与 VB6 有权访问的服务(例如 ASMX Web 服务)进行通信,并让该服务将您的调用转发到适当的 WCF 服务。

另一种选择是将配置变量直接从 VB6 应用程序传递到 Com 可见程序集,以便您可以使用 WCF 的可扩展性模型通过传入的配置创建代理(覆盖从文件读取配置数据的默认行为) 。

我想说,后一种情况可能会违反 SOA/OOP。根据具体情况,VB6 应用程序可能/可能不适合了解/存储与 (最终)WCF端点

Great question here...

Your problem is essentially coming from all the required configuration data needed to work with a WCF Service.

When dealing with .NET Windows or Web Applications the configuration data on both the client and server sides of WCF Services reside in the application configuration file. For a windows application this file will be app.config, whereas it will be a web.config for a web application.

In your case, you would like to put the proxy logic in some form of a COM-visible .dll.

This is going to cause you some grief...in the .NET platform, the .config file for top-level host application (web or windows) is the place where all configuration data is read. Even if your application leverages dozens of .NET assemblies (each with custom configuration needs), the runtime is going to expect those configuration elements to all reside in the top-most application configuration file.

To resolve your issue, you are going to need to communicate to a service that VB6 does have access to (think ASMX web services) and have that service forward your call along to the appropriate WCF service.

The other alternative is to pass configuration variables directly from your VB6 application to your Com-visible assembly so you can use the extensibility model of WCF to create proxies (overriding the default behavior to read configuration data from a file) with your passed-in configuration.

I would say that the latter scenario could go both ways as far as being a violation of SOA/OOP..depending on the situation it may/may not be appropriate for the VB6 application to know about/store configuration details for communicating with the (eventual) WCF endpoint

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