Can an ASP.NET 2.0 Web site reference WCF Web Services?

独自空忆成欢 提交于 2019-12-08 02:22:29

问题


Our company currently has a web site which is deployed in Windows 2000 OS, which means that we could only install .NET 2.0 on that machine. Upgrading the Webserver OS is out of the question, since this web server also hosts other web applications in our country. As also part of our IT's policy, for security reasons the web sites are not allowed to directly access data to our database. That 's why to comply with this restrictions, We have another Server where the Web services is deployed. This "app server" currently has .Net 3.5 SP1 installed, hence WCF Services is possible.

My question is if it is possible to add a web reference on WCF Web services through our ASP.NET Web site that hosts only .NET 2.0.


回答1:


Of course you can. If the WCF service uses the basicHttpBinding binding, then it will be compatible with all SOAP 1.1 clients, including "Add Web Reference".




回答2:


I did this a fair bit of time ago, it is possible, but here's some stumbling blocks that i had to overcome

  1. Use [XmlSerializer] instead of DataContractSerializer, .net 2.0 does not include System.Runtime.Serialization 3.0, which is neccessary to use [DataContract] attibute, which is a .net 3.0 namespace, and for some reason .net 2.0 cant read XML encoded using DataContractSerializer
  2. when you declare your service contracts, ie. [ServiceContract] also declare the attribute [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]
  3. You can encrypt the data using Transport security, requires a working certificate
  4. Generate Service reference using svcutil, use this switch when doing so /targetClientVersion:Version30


来源:https://stackoverflow.com/questions/2069288/can-an-asp-net-2-0-web-site-reference-wcf-web-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!