获得合同
有没有办法以编程方式从正在运行的服务获取合同?我想将正在运行的服务的合同与客户端引用的合同进行比较。
例如,我有两个 Service1 实例运行在具有不同实现的不同计算机上。 他们都有一个名为 IService1 的合约,但实现不同。 我有一个 Console1,它引用了 IService1(第一个实例)。 Console1有2个端点地址的集合。 Console1 想要检查哪个正在运行的服务对于他正在使用的合约(第一个实例)来说是正确的服务。
我在这里想要做的是使用地址以编程方式从服务获取合同,并将其与我拥有的引用合同进行比较。
Is there a way to get a contract from a running service programatically? I want to compare the contract of a running service from a referenced contract in the client side.
For example I have two instances of Service1 running on different machines that has different implementations.
They both have a contract named IService1 but different implementation.
I have a Console1 that has a reference to IService1(First instance).
Console1 has a collection of 2 endpoint address.
Console1 wants to check which of the running services is the correct service for the contract(First instance) he is using.
What I want to do here is to programatically get the contract from the service using the address and compare it to the referenced contract that I have.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果服务公开元数据,则可能是的。具体如何取决于所使用的绑定,如果是普通的 http 绑定,您可以使用 http://myserver/myservice。 svc?WSDL。要比较合约,您必须使用普通的 http API 下载 WSDL,然后将其与存储的参考 WSDL 进行比较。
我认为在实施比较之前还应该考虑一些事情:
If the service exposes metadata it is possible yes. Exactly how depends on the binding used, if it is a normal http binding you can use http://myserver/myservice.svc?WSDL. To compare the contracts you would have to download the WSDL by using a normal http API and then compare it to a stored reference WSDL.
There are also a few things I think you should take into consideration before implementing a comparison: