In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you what are several basic knowledge points in WCF. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Without saying much, follow the editor to have a look.
Sorted out several basic knowledge points in several WCF:
1. Message in WCF
The message object Message in WCF is stateful. Its state is MessageState enumeration. There are the following types:
Public enum MessageState {Created, Read, Written, Copied, Closed}
The Message object can only be read in the Create state, otherwise there will be an exception in the read. Message
Many methods such as Write are also defined, and these Write methods can also be used only for messages in Created.
In WCF, you may need to do some reading, etc. But the read operation changes the Message
State, causing an exception to read again. At this point, you can use the CreateBufferedCopy method defined by Message.
Its signature is as follows:
Public MessageBuffer CreateBufferedCopy (int maxBufferSize)
It returns a MessageBuffer object, which can do multiple Create and return a Message object, and the state of Message is Created.
2. Message encoding format in WCF:
Text 、 MTOM 、 Binary . The Text format is platform-independent; MTOM, based on the WS-*MTOM specification, is an optimized format for transmitting large amounts of binary data to SOAP, and it is also platform-independent; Binary is encoded in binary format and is only used on .net platforms.
3. Metadata exchange endpoint
Metadata exchange endpoints are a special class of endpoints, which also become MEX endpoints, which support the standard of metadata exchange; services can publish their own metadata according to it.
For WebService, it publishes metadata through WSDL, so for WebService, it automatically publishes service metadata information, so we can generate proxy classes for WebService through the WSDL tool.
In WCF, a service can choose not to publish metadata information, even for the cross-platform HTTP protocol it supports. However, we can generate a proxy for the service by publishing metadata exchange endpoints.
WCF automatically provides an implementation of the IMetadataExchange interface for the service host. For metadata exchange endpoints
WCF provides special binding elements to support different protocols (such as HTTP, TCP, IPC). For example, HTTP corresponds to
MexHttpBinding; corresponds to mexTcpBinding; for Tcp and mexNamedPipeBinding to IPC.
The following is the configuration of metadata exchange endpoints under HTTP, TCP and IPC protocols:
In this way, we can generate proxy classes through the SVCUtil tool, regardless of the HTTP, TCP, IPC, and so on supported by the service.
And then access the service.
In WCF, for the HTTP protocol, we can directly configure the behavior of the service
The metadata information of the service is published through httpGetEnabled= "true", which does not support other protocols.
For other protocols we want to publish metadata information, through configuration is obviously a good way.
For metadata exchange endpoint configuration, such as
If the address configuration is empty or the same as the name configuration in behavior, you can use SVCUtil directly
Add baseAddress to generate proxy classes. As shown below:
If the name configuration in address and behavior is different, the SVCUtil needs to be added when generating the proxy class
The property value of address in baseAddress +. The figure is as follows:
When using metadata exchange endpoints, if the endpoint binding supported by the service supports the HTTP protocol, regardless of the following configuration:
A proxy class can be generated regardless of the value of httpGetEnabled in the.
These are the basic knowledge points in WCF, and the editor believes that some of them may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.