Reprinted-interview record on "easily understanding WCF helps you find the entry brick"

Source: Internet
Author: User
Tags object serialization msmq biztalk

"Easy understanding of WCF helps you find entry bricks" interview transcript

Address: http://www.cnblogs.com/wayfarer/archive/2008/03/25/1121378.html

From pm to PM on April 9, 51cto invited two teachers, Zhang Yi and Zhao Yi, to discuss the topic "easily understanding WCF helps you find the entry brick, they also answered questions about their work and study. The following is the transcript of this interview:

Opening Remarks

Host:Now the two teachers have come to our chat room and say hello to everyone! At the same time, I would like to introduce myself to you first!
Zhang Yi:Hello everyone!
Zhang Yi:I am a translator of "WCF Service programming" and have some experience in WCF. I have also used WCF to develop some projects. I hope this exchange will be helpful for you to learn about WCF.
Zhao Wei:Hello everyone! I am a developer. I usually have a great deal of interest in. NET development and have invested a lot in it. The main "achievement" lies in writing some technologiesArticle. Currently, WCF is already a "factual standard" for Microsoft Distributed communication (this trend has been reached). It is important for anyone who needs it to know about it.

About WCF

Zhang Yi: Let me explain first what is WCF?
Zhang Yi:Strictly speaking, WCF is a set of specialized classes specifically used for service customization, publishing and running, and message transmission and processing, that is, the so-called "class library ". These classes are organized in a certain way to work together and provide developers with a unified programming mode. The reason why WCF is special is that it deals with common scenarios. the net class library is different. It is mainly used to process inter-process and inter-machine message transmission and processing. It also introduces the design idea of SOA and publishes and runs it as a service, to facilitate the client's cross-process and machine calls to services. In fact, WCF is a set of developers of distributed processing. It integrates DCOM, remoting, Web Service, WSE, and MSMQ, reducing the learning curve of distributed system developers, and unified development standards.

HOST: How long have you been using WCF?

Zhang Yi:I started from Indigo, the predecessor of WCF, and became very interested in it. After all, I first developed some projects using. Net remotin, and I am very keen on distributed development.
Zhang Yi:From the perspective of the position of WCF, it is included in. Net 3.0 (also including. Net 3.5. The only difference between. Net 3.0 and. NET 2.0 is that. Net 3.0 contains WCF, WPF, WF (or cardspace. Therefore, we think that WCF is part of the. NET Framework and it does not seem to be too much. The most important thing is that WCF cannot be separated. the net framework exists independently (but not the WCF client can call the WCF Service). Therefore, although WCF is specially released by Microsoft to meet the development requirements of SOA solutions, however, it is not a framework like spring or struts, nor a container or server like EJB. Microsoft is truly in line with the SOA Enterprise Application Server role. I think it should be BizTalk Server.

On-site question answering

1. Q: Do I have any background to learn about WCF?
Zhang Yi:
It is not difficult to learn about WCF. In fact, you can start with the basic knowledge of. net. Of course, if you know more about distributed development and SOA, you can easily understand some of these concepts.

2. A netizen asked: I want to call WCF in xbap. I use the TCP/IP protocol, but the permission is locked by the sandbox. How can I call the WCF Service !? Xbap is deployed in IIS !! I want to call WCF in xbap. the TCP/IP protocol is used, but the permission is locked by the sandbox. How can I call the WCF Service !? Xbap is deployed in IIS !!

Zhao Wei:About the xbap permission, this is the same as Ajax. To ensure performance, it runs in a security sandbox. The solution is the same as Ajax. Use the server as the proxy.
Zhao Wei:The solution to xbap sandbox restrictions is to use the server side as a proxy to access the WCF Service.
Zhang Yi:Agree with Lao Zhao. This is true of Microsoft's technologies. It is easy to use and difficult to explore. Because Microsoft's designers have a set of skills to simplify and simplify. But if you want to understand how to simplify the traditional architecture, you need to study it in depth.
Zhao Wei:Simply put, it is to make your xbapProgramRequest a resource of your own (such as an httphandler or WCF Service), then your background program receives the request and then requests your target service, then, your background program returns the result to xbap.

3. A netizen asked: Why should I use WCF? I am a beginner. What are the benefits of WCF?

Zhao Wei:Currently, WCF is already a "factual standard" for Microsoft Distributed communication (this trend has been reached). It is important for anyone who needs it to know about it.
Zhang Yi:To put it simply, WCF integrates all the services and distributed development-related Microsoft technologies you mentioned. You can use WCF to solve problems that previously require multiple technologies.
Zhao Wei:If you need to do your work (that is, you need to use distributed communication on the. NET platform), natural learning of WCF is the best choice.
Zhang Yi:If you do not plan to develop enterprise applications, and do not encounter interoperability problems, do not consider scalability requirements, or solve the problem of information islands between enterprise systems, I naturally don't have to learn about WCF. On the other hand, these scenarios are exactly the application of WCF.

4. Q: Is it easy to write a WCF program? What kind of foundation do you need to know?

Zhang Yi:It is very easy to compile a WCF program. If you are only a WCF application, you only need to master some unique attributes of the WCF.

HOST: Can I give an example?

Zhang Yi:For example, [servicecontract] and [datacontract. This is because the WCF programming mode is not much different from the traditional programming mode. This is also Microsoft's painstaking efforts (or sinister intentions :-), which lowers the technical barriers for learners.
Zhang Yi:The Service programming of WCF is naturally based on the Windows platform.
Zhao Wei:Of course, this is a consistent feature of Microsoft technology and is easy to use. However, if you want to go deep, you still need to invest a lot of energy .. The components in net 3.0 are used to deal with enterprise-level requirements. Due to different businesses, they are flexible and changeable. Therefore, the advanced components of WCF will inevitably introduce considerable complexity and flexibility.

5. Q: Is the remoting performance of WCF much better than that of. NET 2.0 remoting?

Zhang Yi:I don't know whether Zhao has tested the performance. Frankly speaking, I didn't compare the performance of. Net remoting with WCF. I cannot rashly answer this question!
Zhao Wei:I have never performed system performance tests, but Microsoft has published a White Paper, indicating that the performance of WCF is generally better than that of the same (or similar) protocol.. net. I believe that nettcpbinding has better performance than. Net remoting.

6. Q: Can I give a real-world example to illustrate what kind of requirements can be solved by using WCF?

Zhao Wei:It is not a good answer to "What kind of requirements should be solved better by using WCF.
In fact, WCF has gradually become a standard technology for Distributed communication under. net. If you have such requirements, you need to learn. For example, release the web service. The System Application Server interacts externally, and MSMQ-based asynchronous operations in the system.

7. Q: Can I give a common example hello in programming?

Zhang Yi:In fact, there are many examples of cool on the Internet. Writing hello with WCF is simple:

Using system. servicemodel;
[Servicecontract]
Public interface ihello
{
[Operationcontract]
Void sayhello (string MSG );
}
Public class Hello: ihello
{
Public void sayhello (string MSG)
{
Console. writeline (MSG );
}
}

Zhang Yi:Haha! In the preceding example, there are no major differences between attributes and common programming. The only difference is that after we develop this service, we still need host.

8. Ask a netizen: Please give me a simple explanation. What do you think is the biggest advantage of WCF?

Zhao Wei:I personally think that the biggest advantage of WCF is that it unifies and simplifies the Application of Distributed Technology. In the past, different distributed technologies were used in different ways. Now, you only need to mark the attribute and add the configuration to implement distributed communication under different technologies. In this way, programmers can focus more on business-related logic, instead of sticking to technical implementation.

9. Q: Can I modify the communication mode without changing the interface? If I do not have such a requirement for the time being, can I not consider using WCF first? In other words, what are the risks of switching from remoting to WCF?

Zhao Wei:The risk of switching from remoting to WCF mainly lies in engineering rather than technology. In general, all functions that remoting can achieve are qualified for WCF. However, there are many technical issues related to such "porting" tasks, such as the cost and the risks caused by transplantation.
Zhang Yi:If it is limited to a LAN, I do not recommend that you upgrade it to WCF if remoting has been used to develop a stable system.

10. HOST: using WCF, different systems can communicate with each other. At the same time, layers can communicate with each other based on WCF. For communications between the UI Layer and the BLL layer, if it is based on the WPF or winform C/S architecture, it is very convenient Based on WCF, but if it is a B/S architecture, ASP. the. NET page and business logic layer may be deployed in the same IIS. Previously, the service logic layer can be called directly based on APIs. Is it necessary to implement it based on WCF?

Zhao Wei:"The first criterion of distributed applications is" non-distributed ". Compared with inter-process communication, distributed communication can significantly reduce the performance, as you said, such as ASP. net web layer and business logic, it is likely that you should not use WCF for communication. In fact, if Java technology is used, remote access to ejbs is rampant in the past, but currently almost all Internet applications are not applicable to ejbs. Instead, they use lightweight frameworks such as struct and spring, because Remote Communication is costly.
Zhang Yi:To select a technology, you must first look at the specific application scenarios and needs, rather than choosing it if you think the technology is good or new. For B/S systems, if other systems are not required to call the B/S system in the form of services, there is no need to use the WCF technology. The most reasonable way is to design a service layer in the B/S system to reflect the so-called service-oriented characteristics. The service in this service layer is a little coarse-grained, it should also be called by other systems. We can consider the design of this layer in advance. It is not necessarily an internal call of the B/S system, but an extension of the future.

11. Q: I have another question. I don't think there is any obvious application server in WCF. If it is deployed in IIS, it is actually a web service! I don't know if WCF will have a real application server. Just like the application server of COM + and EJB, it provides complete functions such as component management, scheduling, and load balancing.

Zhang Yi:In fact, BizTalk is a good application server. Of course, we can also use WCF to develop a lightweight application server. This article is available on the Internet. Zhao Wei: Of course, everything cannot be generalized. For some enterprise applications or large-scale system integration, it is likely that the business logic needs to be released using WCF. This is why most Internet applications do not need independent application servers, and many enterprise applications have independent application layers.

12. Q: How stable is the WCF program? Can it be applied in large-scale enterprise development?

Zhang Yi:At present, WCF has been well developed, and its stability can be fully applied to enterprise development. The only weakness in the US is that for Internet scenarios, the httpbinding transmission method still has certain performance limitations.

13. Q: What are the extensions of WCF? For example, I customize the transfer sink and add a security mechanism to the transmission link?

Zhao Wei:WCF provides flexible and complex extensions. I don't understand what you mean. If you just want to implement your own security mechanism, you can. However, if you are referring to extensions at the TCP/IP protocol level (or similar communication level), it is obvious that WCF is powerless.

4. Q: Does WCF support exposing an interface to the rset service?

Zhao Wei:The. NET 3.5 provides the wcf http service, which is designed to release restful interfaces.
Zhang Yi:Currently, WCF supports binding and behavior extension. I suggest you read Aaron skonnard's article in msdn. He has made a good introduction to this content. Could you take a look at this article: http://msdn.microsoft.com/msdnmag/issues/07/12/ServiceStation/Default.aspx? Loc = Zh. In addition, WCF 3.5 supports the rest service.

15. Q: Some people say that WCF is part of Vista. Is that true? What is the relationship between them?

Zhao Wei:Vista includes WCF, but WCF is a component that can be independent from Vista. For example, you can install and use it in Server 2003.

16. Q: Will Ajax call of WCF increase the server's affordability?

Zhao Wei:WCF itself does not increase the pressure on the server, and the pressure is generally caused by the business itself. That is to say, it is difficult for WCF to become a performance bottleneck. It does not cause performance problems because Ajax calls WCF.

17. Some netizens asked: remoting is still widely used to create a boundary object using a factory method. It seems that the corresponding method is not found in WCF. The Duplex message exchange mode exists in WCF, but it still cannot solve the problem that the remoting client obtains a group of boundary objects in batches from a simple interface, at least cannot be completely replaced.
Zhang Yi:I don't understand what you mean. Does remoting use the marshal method to create objects?
Zhang Yi:Boundobject?
Questions:Objects that can call remote methods. That is to say, declare an externalbyref object on the server side, and then use a factory method to obtain this object. Of course, this factory method should also be exposed as the remoting interface, so that the client can use this factory method to obtain a lot of remote objects for use.
Zhang Yi:In my opinion, the three instance modes of WCF fully cover the three activation modes of remoting in the past.
Zhang Yi:Currently, the enhancement of the client is not only reflected in deplex, but also the strong support of the callback method by WCF, which has enhanced the interaction between the server and the client.
Zhang Yi:I understand your problem. I mentioned it before when I was studying remoting. In fact, the channelfactory of WCF can be used to achieve this goal. In WCF Service programming, it is also divided into management and programming methods.

18. Q: How can I implement enterprise-level applications using LINQ to SQL in WCF !?

Zhao Wei:In fact, there is no need to associate LINQ to SQL with WCF. One is data access technology, and the other is distributed communication technology, which can be used together at will. Of course, there may also be something worth attention, that is, some types of LINQ to SQL, such as entityset, cannot be serialized by WCF and converted to other data types during transmission.
Zhao Wei:Ajax calls to WCF will not cause performance problems. performance problems are often caused by program development. Both WCF and Ajax are pure technologies, and there is no problem in proper use.
Zhang Yi:In fact, the problem of Object serialization mentioned by Lao Zhao is also a problem that I am not satisfied with WCF. This increases the difficulty of using WCF.

19. Q: Is it easy for WCF to troubleshoot problems? For example, do you have a solution that is easy to debug and troubleshoot by capturing dump and network packets?

Zhao Wei:In fact, WCF is essentially a common distributed communication technology. It can be used in the past for troubleshooting methods and tools. Of course, some methods specific to the WCF framework sometimes have miraculous effects. For example, you can compile an extended "Insert" for debugging to execute the WCF.
Zhang Yi: The Troubleshooting of your problem is not related to the technology of WCF. However, it is difficult to test the distributed program itself. Visual Studio 2008 has released some gadgets for WCF to simulate the client to test the service when designing the service, however, there are no tools like dump in Linux for network transmission and data packets.

20. A netizen asked: I used X509 for verification, but it was several seconds slower than not. How can I increase the verification rate !?

Zhao Wei:Is every call slow for several seconds? I personally think this should not be the case. Are you experiencing problems that are time-consuming during initialization?
Zhang Yi:The question you raised is more in-depth. I am afraid there is a balance between performance and security concerning security issues. Enhanced security will inevitably affect performance. Therefore, the author of "WCF Service programming" suggested that the most dangerous should be guessed maliciously first, and then the security requirements should be gradually reduced according to specific scenarios.

21. Q: As a Java User, what should I pay attention to when the emergence of WCF?

Zhang Yi:If you are a Java developer and want to develop a system that interacts with. net programs, I am afraid I will learn about WCF. As for how to learn, it is better to understand some of. Net's special differences from Java. In fact, the internal operating mechanism is very similar, including hosting, application domains, and so on. The most important thing is to understand the characteristics of SOA.
Zhao Wei:As a Java User, you may be most concerned with the inteop issue of WCF. In fact, WCF implements many standard-based communication protocols. Generally, no problem occurs. In addition, WCF has been able to support restful APIs, so there is no problem with the interoperability between technologies. Because restful uses the HTTP protocol, this protocol has long been widely adopted.

22. Q: WS-Addressing, WS-reliability, and WS-Security. These three don't know whether the future will fully support WS-I specifications?

Zhang Yi:Your question is hard to answer. However, the support for WS-* In WCF is absolutely complete, but there is a problem that this involves a game between many stakeholders.
Zhang Yi:P2P is supported in XP, but you must specify the peer network name, unique path, and port.
Zhao Wei:To use P2P in WCF, you also need to install PNRP on Windows XP. You can search for related content on the Internet.
Zhang Yi:XP should be available on SP1.
Zhao Wei:However, if you use XP SP2, it should be possible.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.