在C#中通过soap连接到多个Web服务

问题描述:

我正在构建一个服务,用于聚合来自多个 soap 网络服务的大量数据.Web 服务调用和soap 包应该是什么样子有一个标准.但是当然,每个人的版本在命名空间使用方面都略有不同.在 c# 中为什么要动态获取 wsdl 并在运行时基于它创建soap 包?我不想为每个上线的新服务静态运行 wsdl 实用程序.

I'm building a service that aggregates a bunch of data from multiple soap web services. There's a standard on what the web service call and soap package is supposed to look like. But of course, everybody's version is just a little bit different primarily in namespace usage. Is there any why in c# to dynamically fetch a wsdl and create the soap package based on it at runtime? I don't want to have to run the wsdl utility statically for every new service that comes online.

可以按照您所说的去做,但是会非常昂贵(系统资源)并且速度很慢.考虑创建一个基于提供者的模型,其中您已经引用了所有服务,然后将请求路由到正确的服务.

It is possible to do what you are talking about, but it would be very expensive (system resources) and slow. Look into creating a provider based model where you have all your services already referenced and then route the request to the correct service.

提供者模型将允许您使用反射加载新的提供者,就像您要求的那样.

The provider model will let you load new providers using reflection just like you are asking.

这是一个例子.

http://dotnetslackers.com/articles/designpatterns/HowToWriteAProviderModel.aspx

它可以适应服务.