I'm integrating a product from another vendor with our existing processes.
我正在将来自其他供应商的产品与我们现有的流程集成。
This product interfaces with our system via an ASP.NET Web Service. As in, I need to write an ASP.NET Web Service that has the particular method names and parameters that the vendor has specified.
该产品通过ASP.NET Web服务与我们的系统连接。在中,我需要编写一个ASP.NET Web服务,它具有供应商指定的特定方法名称和参数。
Simple enough, but we're wanting to migrate as much stuff as possible to WCF. I haven't used WCF much yet, but as I see it it's the replacement for ASP.NET Web Services (and other things).
很简单,但我们希望尽可能多地向WCF迁移。我还没有使用过WCF,但是我认为它是ASP.NET Web Services(和其他东西)的替代品。
Seeing as how I cannot modify the vendor's product, the only way I could write this new web service using WCF is if a WCF Service can be consumed as if it were an ASP.NET Web Service (i.e., as far as the vendor's product is concerned, it is consuming an ASP.NET Web Service).
看到我不能修改供应商的产品,我可以使用WCF编写这个新Web服务的唯一方法是,可以像使用WMS服务那样使用ASP.NET Web服务(即,就供应商的产品而言有关,它正在消耗ASP.NET Web服务)。
Can WCF Services be consumed in this way?
可以通过这种方式使用WCF服务吗?
2 个解决方案
#1
5
yes, web services are web services. In general WCF is more flexible and more powerful than ASP.NET, but you can get the on-the-wire message into and out of a WCF service to look exactly the same as the messages for an ASMX service. But, WCF is also different by default.
是的,Web服务是Web服务。通常,WCF比ASP.NET更灵活,功能更强大,但是您可以将有线消息放入和转出WCF服务,使其看起来与ASMX服务的消息完全相同。但是,默认情况下,WCF也不同。
Migrating should be almost mechanical. Replace the .asmx file containing this:
迁移应该几乎是机械的。替换包含以下内容的.asmx文件:
<%@ WebService
Language="C#"
CodeBehind="~/App_Code/CommunicationService.cs"
Class="CommunicationService" %>
...with a .svc file containing this:
...包含以下内容的.svc文件:
<%@ ServiceHost
Language="C#"
CodeBehind="~/App_Code/CommunicationService.cs"
Service="CommunicationService" %>
...and you are nearly done.
......你差不多完成了。
But, the default settings for a WCF web service are different than those for an ASP.NET web service. In particular, the XML namespaces of the incoming and outgoing messages may be different. Not everybody specifies distinct xml namespaces for their service and messages, but for those who do, migration will be an issue. The difference in behavior (WCF-vs-ASPNET) will cause apps that successfully were able to call an ASMX service, to not work with a "converted" WCF service.
但是,WCF Web服务的默认设置与ASP.NET Web服务的默认设置不同。特别是,传入和传出消息的XML名称空间可能不同。并非每个人都为其服务和消息指定不同的xml名称空间,但对于那些人来说,迁移将是一个问题。行为差异(WCF-vs-ASPNET)将导致成功能够调用ASMX服务的应用程序无法使用“转换”的WCF服务。
This article discusses the issue in some detail, and describes a good workaround: use a custom ServiceHost.
本文将详细讨论该问题,并描述一个很好的解决方法:使用自定义ServiceHost。
The service host code in the article above is incomplete in that it works to fix only the request schema; you might/could also need to do something similar for the response schema.
上面文章中的服务主机代码不完整,因为它只能修复请求模式;您可能/可能还需要为响应模式执行类似的操作。
Good luck.
祝你好运。
#2
0
In addition to the other answers and pointing to your Migration concern, you can STILL open to keep your old Webservices working as it is now, but point these Webservices(Existing) to WCF Host Service. So new as well as old Webservice work seamlessly.
除了其他答案并指出您的迁移问题之外,您仍然可以打开以保持旧Web服务现在正常工作,但将这些Web服务(现有)指向WCF主机服务。因此,新旧Webservice可以无缝地工作。
#1
5
yes, web services are web services. In general WCF is more flexible and more powerful than ASP.NET, but you can get the on-the-wire message into and out of a WCF service to look exactly the same as the messages for an ASMX service. But, WCF is also different by default.
是的,Web服务是Web服务。通常,WCF比ASP.NET更灵活,功能更强大,但是您可以将有线消息放入和转出WCF服务,使其看起来与ASMX服务的消息完全相同。但是,默认情况下,WCF也不同。
Migrating should be almost mechanical. Replace the .asmx file containing this:
迁移应该几乎是机械的。替换包含以下内容的.asmx文件:
<%@ WebService
Language="C#"
CodeBehind="~/App_Code/CommunicationService.cs"
Class="CommunicationService" %>
...with a .svc file containing this:
...包含以下内容的.svc文件:
<%@ ServiceHost
Language="C#"
CodeBehind="~/App_Code/CommunicationService.cs"
Service="CommunicationService" %>
...and you are nearly done.
......你差不多完成了。
But, the default settings for a WCF web service are different than those for an ASP.NET web service. In particular, the XML namespaces of the incoming and outgoing messages may be different. Not everybody specifies distinct xml namespaces for their service and messages, but for those who do, migration will be an issue. The difference in behavior (WCF-vs-ASPNET) will cause apps that successfully were able to call an ASMX service, to not work with a "converted" WCF service.
但是,WCF Web服务的默认设置与ASP.NET Web服务的默认设置不同。特别是,传入和传出消息的XML名称空间可能不同。并非每个人都为其服务和消息指定不同的xml名称空间,但对于那些人来说,迁移将是一个问题。行为差异(WCF-vs-ASPNET)将导致成功能够调用ASMX服务的应用程序无法使用“转换”的WCF服务。
This article discusses the issue in some detail, and describes a good workaround: use a custom ServiceHost.
本文将详细讨论该问题,并描述一个很好的解决方法:使用自定义ServiceHost。
The service host code in the article above is incomplete in that it works to fix only the request schema; you might/could also need to do something similar for the response schema.
上面文章中的服务主机代码不完整,因为它只能修复请求模式;您可能/可能还需要为响应模式执行类似的操作。
Good luck.
祝你好运。
#2
0
In addition to the other answers and pointing to your Migration concern, you can STILL open to keep your old Webservices working as it is now, but point these Webservices(Existing) to WCF Host Service. So new as well as old Webservice work seamlessly.
除了其他答案并指出您的迁移问题之外,您仍然可以打开以保持旧Web服务现在正常工作,但将这些Web服务(现有)指向WCF主机服务。因此,新旧Webservice可以无缝地工作。