当地址经常更改时,如何从WSDL(如Pro)生成Web服务客户端?

发布于 2025-01-28 11:31:07 字数 1289 浏览 5 评论 0原文

我必须在具有地址的ESB上消费一些服务:

  1. for dev env: http://esbdev.com:11111/ws/ir.channel.aaa.aaa.pub.ws:Consumememev1
  2. 对于测试env: https://esbtest.com:22222/ws/ir.channel.aaaa.aaaa.ws:doamazingcalc:doamazingcalc

功能相同。

我可以以某种方式在WSDL生成的C#中只有一个常见的代码(统治所有代码)并操纵我通过某些配置连接的env与哪个env进行操作? 我可以在测试环境上的http和https上自由切换吗?

现在,我将其称为Dev:

using (ConsumeMeV1_PortTypeClient client = new ConsumeMeV1_PortTypeClient(this.EsbEndpointBinding, this.EsbEndpointAddress))

但是有Dev Name Hardced-我应该如何映射 compliteMev1 在测试中 doamazingcalc

在测试中,我称其为:

using (DoAmazingCalc_PortTypeClient client = new DoAmazingCalc_PortTypeClient(this.EsbEndpointBinding, this.EsbEndpointAddress))

我可以生成常见的拼写物,例如:

using (BestServiceNameClient client = new BestServiceNameClient(this.EsbEndpointBinding, this.EsbEndpointAddress))

对我的最佳选择是从数据库中获取端点/名称配置并注入Clinet类 - 但是如何?

I have to consume some service on ESB which has addresses:

  1. for dev env: http://esbdev.com:11111/ws/ir.channel.aaa.pub.ws:ConsumeMeV1
  2. for test env: https://esbtest.com:22222/ws/ir.channel.aaa.ws:DoAmazingCalc

Functionality is the same.

Can I somehow have only one common code (to rule them all) in c# generated from WSDL and manipulate to which env I’m connecting by some config?
And can i switch freely between http on dev and https on test environment?

Now I’m calling it on dev like:

using (ConsumeMeV1_PortTypeClient client = new ConsumeMeV1_PortTypeClient(this.EsbEndpointBinding, this.EsbEndpointAddress))

But there is dev name hardcoded - how should i map ConsumeMeV1 to DoAmazingCalc on test?

On test I'm calling it like:

using (DoAmazingCalc_PortTypeClient client = new DoAmazingCalc_PortTypeClient(this.EsbEndpointBinding, this.EsbEndpointAddress))

Can I generate common clases like:

using (BestServiceNameClient client = new BestServiceNameClient(this.EsbEndpointBinding, this.EsbEndpointAddress))

The best option for me is to get endpoint/names config from database and inject to clinet class - but how?

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

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

发布评论

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

评论(1

无敌元气妹 2025-02-04 11:31:07

好的,我知道卖出的来源。

只要下面的功能不会改变,地址的一部分就无关紧要。因此,两个生成的类都可以使您与每个给定地址一起使用它们。我注意到,只有当您知道它时,这些明显的事情才是这样,所以很抱歉,没有人甚至写一句话。

但是,当涉及到https时,它取决于basichtpbinding.security.mode设置。您可以为HTTPS设置运输,并为HTTP设置运输。可以将相应的值与用户和密码一起从数据库或其他配置中保存和检索。

我将上述设置使用:
basichttpbinding.security.transport.clientcredentialType = httpClientCredentialType.Basic;

Ok, I know where the minuses come from.

No part of the address matters as long as the functionality underneath it does not change. So both generated classes will allow you to use them with each of the given addresses. I note that these obvious things are like that only when you know about it, so I'm sorry that no one even wrote a word about it.

However, when it comes to https, it depends on the BasicHttpBinding.Security.Mode settings. You can set Transport for https and TransportCredentialOnly for http. The corresponding value can be saved and retrieved from the database or other configuration together with the user and password.

I use the above with the setting:
BasicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

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