从 angular 2 和 Silverlight 应用程序使用相同的 WCF 服务 [英] Consume same WCF service from angular 2 and Silverlight application

查看:28
本文介绍了从 angular 2 和 Silverlight 应用程序使用相同的 WCF 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我们有一个带有 WCF 服务(后端)的 Silverlight 应用程序(前端).现在,我们将用 Angular 2 应用程序替换 Silverlight 应用程序,而不更改 WCF 服务 - 只会更改 UI.

Currently we have one Silverlight application (frontend) with WCF services (backend). Now, we are going replace the Silverlight application with an Angular 2 application without changing the WCF services - only the UI will get changed.

在开始使用 Angular 2 之前,我们已经在 Angular 2 中创建了一个演示应用程序来验证 WCF 服务是否可以与 Angular 2 一起使用,因为 Silverlight 支持 basicHttpBinding 并且对于 Angular 2,我们需要使用 <代码>webHttpBinding.目前我们正面临着这方面的问题.

Before starting with Angular 2, we have created a demo application in Angular 2 to verify that WCF services are working with Angular 2, because Silverlight supports basicHttpBinding and for Angular 2, we need to use webHttpBinding. Currently we are facing issues with that.

是否可以在 Silverlight 和 Angular 2 中并行使用一项 WCF 服务?请建议.

Is it possible to use one WCF service in Silverlight and Angular 2 in parallel? Please suggest.

推荐答案

由于一种 wcf 服务的工作方式,可以以多种方式使用它们.你说你遇到了问题,但你没有说它们是什么.

It is possible to use the one wcf service in several ways due to the way they work. You say you're facing issues but you don't say what they are.

WCF 服务具有端点.它是通过 basicHttpBinding 或 webHttpBinding 或其他方式定义连接的端点.一项服务可以有多个端点.这些在您的配置中定义.如果您查看那里,您将看到所有基本的httpbinding 端点.为您的一项服务添加一个,并尝试使用 angular.这是一个 webHttpbinding 的样子:https://weblogs.asp.net/kiyoshi/wcf-使用-webhttpbinding-for-rest-services还有一些关于一些常见问题的建议.WCF 的这方面设置起来非常繁琐.可以想象,重复使用相同的 wcf 服务是不切实际的.在这种情况下,我建议将代码移植到 web api(尽管我认为他们可能已将其重命名为当前风格).编写大多数东西非常容易,因为它们只是具有指定路由的属性的方法.

WCF services have endpoints. It is the endpoint that defines a connection via basicHttpBinding or webHttpBinding or whatever. You can have multiple endpoints for the one service. These are defined in your config. If you take a look in there, you'll see all your basichttpbinding endpoints. Add one to that for one of your services and give it a go with angular. This is what a webHttpbinding looks like: https://weblogs.asp.net/kiyoshi/wcf-using-webhttpbinding-for-rest-services There is also some advice in there for some common issues. This aspect of WCF is very fiddly to set up. It is conceivable that re-using the same wcf services will not be practical. In which case I would suggest porting the code to web api ( although I think they may have renamed that in current flavour ). It's dead easy to write most stuff because they're just methods with an attribute specifying routing.

这篇关于从 angular 2 和 Silverlight 应用程序使用相同的 WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆