Interoperability with ASP.NET Web Services

來源:互聯網
上載者:User
Interoperability between ASP.NET Web services and Windows Communication Foundation (WCF) Web services can be achieved by ensuring that services implemented using both technologies conform to the WS-I Basic Profile 1.1 specification. ASP.NET Web services that conform to WS-I Basic Profile 1.1 are interoperable with WCF clients by using WCF system-provided binding, BasicHttpBinding.

Use ASP.NET 2.0 option of adding the WebService and WebMethodAttribute attributes to an interface rather than to a class, and writing a class to implement the interface, as shown in the following sample code.

Copy Code
[WebService]public interface IEcho{[WebMethod]string Echo(string input);}public class Service : IEcho{public string Echo(string input){return input;}}

Using this option is preferred, because the interface with the WebService attribute constitutes a contract for the operations performed by the service that can be reused with various classes that might implement that same contract in different ways.

Avoid using the SoapDocumentServiceAttribute attribute to have messages routed to methods based on the fully-qualified name of the body element of the SOAP message rather than the SOAPAction HTTP header. WCF uses the SOAPAction HTTP header for routing messages.

The XML into which XmlSerializer serializes a type by default is semantically identical to the XML into which the DataContractSerializer serializes a type, provided the namespace for the XML is explicitly defined. When defining a data type for use with ASP.NET Web services in anticipation of adopting WCF, do the following:

  • Define the type using .NET Framework classes rather than XML Schema.

  • Add only the SerializableAttribute and the XmlRootAttribute to the class, using the latter to explicitly define the namespace for the type. Do not add additional attributes from the System.Xml.Serialization namespace to control how the .NET Framework class is to be translated into XML.

  • By adopting this approach, you should be able to later make the .NET classes into data contracts with the addition of the DataContractAttribute and DataMemberAttribute without significantly altering the XML into which the classes are serialized for transmission. The types used in messages by ASP.NET Web services can be processed as data contracts by WCF applications, yielding, among other benefits, better performance in WCF applications.

Avoid using the authentication options provided by Internet Information Services (IIS). WCF clients do not support them. If a service must be secured, use the options provided by WCF, because these options are robust and are based on standard protocols.

Performance impact caused by loading the ServiceModel HttpModule

In the .NET Framework 3.0, the WCF HttpModule was installed in the root Web.config file such that every ASP.NET application was WCF enabled. This might affect performance, so you can remove ServiceModel for the Web.config file as shown in the following example.

Copy Code
<httpModules><remove name=”ServiceModel” /><httpModules/>
 
 
Ref:Interoperability with ASP.NET Web Service 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.