简体   繁体   English

获取IIS中托管的服务版本

[英]Get the version of Service hosted in IIS

We are hosting a WCF service in IIS. 我们在IIS中托管WCF服务。 For tracking purposes we need to know the version of the service that's being hosted in IIS. 为了进行跟踪,我们需要知道IIS中托管的服务的版本。

This service is part of an suite of services so we implemented all common functionality (Like the mentioned tracking service in a common library) 该服务是服务套件的一部分,因此我们实现了所有通用功能(就像在公共库中提到的跟踪服务一样)

When trying to get the Assembly version using normal calls Assembly.GetExecutingAssembly() 当尝试使用常规调用获取Assembly版本时,Assembly.GetExecutingAssembly()

  • Assembly.GetExecutingAssembly(): get the version of the common Library Assembly.GetExecutingAssembly():获取公共库的版本
  • Assembly.GetEntryAssembly(): null Assembly.GetEntryAssembly():null
  • Assembly.GetCallingAssembly(): get the version of the common library Assembly.GetCallingAssembly():获取公共库的版本

I also tried getting the call stack and getting the last one (got the IIS version). 我还尝试获取调用堆栈并获取最后一个(获取IIS版本)。

Does anyone know how to programmatically get the version of the WCF service that is hosted in IIS? 有谁知道如何以编程方式获取IIS中托管的WCF服务的版本?

I am assuming that you need to get the WCF service's version from within common library dll that is referenced by the WCF service at runtime. 我假设您需要从运行时WCF服务引用的公共库dll中获取WCF服务的版本。 If not, I don't understand why you would get the common library assembly by running Assembly.GetExecutingAssembly() . 如果没有,我不明白为什么您会通过运行Assembly.GetExecutingAssembly()获得公共库程序集。

If that is the case, then you want to find the assembly containing the Application object that IIS is running. 如果真是这样,那么您想找到包含IIS正在运行的Application对象的Application集。 By using the standard reflection methods on that root Application object, you should get a reference back to the dll that IIS is executing, which should be the WCF service. 通过在该根Application对象上使用标准反射方法,您应该获得对IIS正在执行的dll的引用,该DLL应该是WCF服务。

Documentation for Application class: Application类的文档:

http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx

This looks like a promising way to get it: 这看起来是一种有前途的方法:

http://msdn.microsoft.com/en-us/library/system.windows.application.current(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/system.windows.application.current(v=vs.110).aspx

When talking about versions of WCF services, more likely you will realize you want versioning of Web services, rather than assembly version, though you mix both in your question. 在谈论WCF服务的版本时,您很可能会意识到您想要Web服务的版本控制,而不是程序集版本,尽管您在问题中混合了两者。

The assembly version is of implementation details, and there are no legitimate case that you need to expose such implementation details through either Web services or IIS. 程序集版本包含实现详细信息,没有合法的情况需要通过Web服务或IIS公开此类实现详细信息。 IIS itself is of deployment detail, and has nothing to do with versioning of Web services. IIS本身具有部署详细信息,与Web服务的版本无关。

System.Windows.Application is of WPF, has nothing to do with WCF or Web service. System.Windows.Application是WPF的,与WCF或Web服务无关。

When you learned programming, probably you had learned the once an interface is published, you should never alter it, though you could change implementation or introduce new versions of the interface. 当您学习编程时,很可能是一旦接口发布后就学到的,尽管可以更改实现或引入新版本的接口,但切勿更改它。 a Web service is basically an API or interface through http binding, and the description language is typically WSDL for SOAP base Web service. Web服务基本上是通过http绑定的API或接口,而描述语言通常是SOAP基本Web服务的WSDL。

In a nutshell, versioning of Web service is done through Xml namespace, and in .NET, you could have a mapping between XML namespace and CLR namespace. 简而言之,Web服务的版本控制是通过Xml名称空间完成的,在.NET中,您可以在XML名称空间和CLR名称空间之间建立映射。 During deployment, you could have multiple versions of the same service being hosted in the host, so legacy clients could consume the legacy services, and new clients could consume the new versions. 在部署期间,主机中可以托管同一服务的多个版本,因此旧客户端可以使用旧服务,而新客户端可以使用新版本。 So you will have seamless transition strategy. 因此,您将拥有无缝的过渡策略。

There's no direct link between assembly versions and service versions, and you should not expose assembly versions, since the clients say PHP or Java clients do not know what assembly version is. 程序集版本和服务版本之间没有直接链接,并且您不应该公开程序集版本,因为客户端说PHP或Java客户端不知道什么是程序集版本。

For more details of starting points, here are a few good links if you google "Web service versioning": http://www.ibm.com/developerworks/webservices/library/ws-version/ http://www.oracle.com/technetwork/articles/web-services-versioning-094384.html http://msdn.microsoft.com/en-us/library/ms731060(v=vs.110).aspx 有关起点的更多详细信息,如果您使用Google“ Web服务版本控制”,则这里有一些不错的链接: http : //www.ibm.com/developerworks/webservices/library/ws-version/ http://www.oracle。 com / technetwork / articles / web-services-versioning-094384.html http://msdn.microsoft.com/zh-CN/library/ms731060(v=vs.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM