开发者

Concerns to convert Web Service (asmx) into WCF

I have some basic questions related to the conversion of Web Service (.asmx) into WCF. We have a running website which use tons of Web Services. These web services use a common dll that has the business logic. We are planning to convert the web services into WCF. Since there many web services, we are planning to convert one at a time. So to begin with there will be one WCF and many web services (asmx) residing on the production server. I have some confusion on how to make the website run with both - WCF and ASMX residing at one place. I would appreciate if someone can answer my queries:

  1. Can I share the same web.config file for both .asmx web service and WCF service? If yes, then what all changes do I need do to to make sure both works at t开发者_运维知识库he same time. Adding ServiceModel tag is enough to the existing web.config?

  2. Can I use the web.config to store some configuration parameters that can be shared between the two services - WCF and .asmx? How to call it?

  3. Currently, the common dll (business layer) is using HTTPContext.Current to cache some values. How can I make sure that the code works for both WCF and .asmx calls? What is the best way to convert the code similar to:

    xslt = (XslCompiledTransform)HttpContext.Current.Cache[fileName];
    string XslFilePath = HttpContext.Current.Server.MapPath(@"~/xsl/" + fileName);
    

    What is the WCF equivalent?

  4. Finally, how can I deploymy WCF changes in production server? Do I just need to copy the service dll and the .svc file?

I know, I have so many questions, and these may look simple to you guys but I am finding hard to figure them out.


1) Can I share the same web.config file for both .asmx web service and WCF service?

Yes, absolutely - the WCF config lives in the <system.serviceModel> section (mostly), so that's no an issue at all.

2) Can I use the web.config to store some configuration parameters that can be shared between the two services - WCF and .asmx?

If you create your own custom configuration section or section group - yes, sure. Both the ASMX web service as well as your WCF code can read that custom config section - that's all standard .NET stuff, really (See: How to: Create Custom Configuration Sections Using ConfigurationSection)

3) Currently, the common dll (business layer) is using HTTPContext.Current to cache some values.

You can turn on the ASP.NET compabitibility mode on your WCF services, and doing so, you a) tie yourself to IIS forever, and b) get access to all the usual HTTP context and stuff like that. See: WCF Services and ASP.NET for more info.

4) Finally, how can I deploy my WCF changes in production server? Do I just need to copy the service dll and the .svc file?

Copy the service DLL(s), the SVC file, make the config changes - that's it!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜