如何为 Web 服务设置 spring.net 依赖注入?

发布于 2024-08-19 08:27:18 字数 661 浏览 8 评论 0原文

我收到了一个 wsdl 文件 + 一些 xsd 类型定义文件 - 我需要编码的服务尚未准备好,我需要组合一个假服务(所谓的存根或模拟),以便在以下情况下做好准备:真正的事情来了。

我的问题是 - 一旦我获取我需要从 wsdl 实现的接口,如何设置依赖注入,以便每当新服务出现时我都可以添加服务引用或 Web 引用,然后只需编辑 spring.net 配置文件即可交换在消费者中我想要的服务?有可能吗?

我发现这篇文章,专门针对WCF,它是相当不错,但他似乎可以访问服务代码,并且他在服务端而不是消费者端进行依赖项注入 - 在我的情况下,我很可能只会获得一个网址,我将不得不将其与假本地交换一并从那里开始。

还有一种方法可以仅取决于我使用服务的方式而不取决于服务的组合方式吗?我的意思是,只要我获得 wsdl 的 URL,我就不应该关心使用哪种技术来开发服务。

任何指示表示赞赏!

I have been handed a wsdl file + a number of xsd type definition files - the service I need to code against is not ready yet and I need to put together a fake service (so called a stub or mock) in order to be ready when the real thing comes along.

My question is - once I get the interface I need to implement from the wsdl, how do I setup dependency injection so that whenever the new service comes along I can add a service reference or a web reference and just edit the spring.net config file to swap in the service I want in the consumer? Is it even possible?

I found this article, specific to WCF, It's pretty good but he seems to have access to the service code and he's doing dependency injection on the service side rather than on the consumer side - in my case I will most likely just get a url, I will have to swap it with the fake local one and go from there.

Also is there a way of doing this only dependent on the way I consume the service but not on the way the service was put together? I mean, I shouldn't care less which technology was used to develop the service as long as I get a url to the wsdl.

Any pointers appreciated!

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

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

发布评论

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

评论(1

半夏半凉 2024-08-26 08:27:18

只需创建一个映射到 Web 服务方法的接口并在客户端使用它即可。无论是本地服务、网络服务还是其他服务,都没有关系。

我之前已经完成了您想要做的事情,您可以阅读它 此处

Just create an interface which maps to the webservice methods and use that on the client side. It doesn't matter if it's a local service, webservice, or whatever.

I've done what you are trying to do before, you can read about it here.

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