简体   繁体   English

如何模拟另一个Web服务?

[英]How can I mock another web service?

I have code that calls a web service. 我有调用Web服务的代码。 We'll say a "3rd party" web service. 我们将说一个“第三方”网络服务。 So I can get the wsdl for this service, in fact I've generated a proxy class using this wsdl. 因此,我可以获得此服务的wsdl,实际上我已经使用此wsdl生成了一个代理类。

The requirement that I'm trying to meet is this: Create a web service that LOOKS just like the above mentioned one, but does other stuff. 我要满足的要求是:创建一个Web服务,它看起来像上面提到的一样,但是可以做其他事情。 So the web service URL will be changed in a config file/database, to allow switching between the two web services. 因此,将在配置文件/数据库中更改Web服务URL,以允许在两个Web服务之间进行切换。

What I'm not sure about is how I can use that proxy class that I generated, or some other method, so that the namespacing and data contract look exactly the same. 我不确定的是如何使用生成的代理类或其他方法,以便命名空间和数据协定看起来完全相同。 I don't know much about this and these are terms that colleagues have tossed out there. 我对此并不太了解,而这些是同事们抛弃的术语。 I only need to actually implement one of the web service's methods in my version. 我只需要在我的版本中实际实现Web服务的方法之一。

Build site with any technology you know of and return responses that match that service. 使用您知道的任何技术来构建站点,并返回与该服务匹配的响应。

Note that if you just need to return static enough responses for occasional testing you can use Fiddler as it allows to return arbitrary responses instead of real once. 请注意,如果您只需要返回足够静态的响应以进行偶尔的测试,则可以使用Fiddler,因为它允许返回任意响应,而不是真实的响应。

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

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