Monitoring WebService Information

Source: Internet
Author: User

Since wince does not provide good support for WCF, we still need to use traditional WebService. When wince6.0 communicates with WebService, sometimes the signal is not very stable, the exception message "unable to obtain data from the transmission connection" may occur, because the signal is always stable during the debugging process, which makes it difficult to find the cause, through the exception log record, I found that the status returned by HTTP is 204 (the returned result is successful but the content is blank). It is strange that I knew that the returned content was not empty, but this exception was indeed returned, in addition, this kind of prompt information makes the customer particularly disgusted, with such questions, so I want to record what the client and server WebService send and receive in the communication process after being serialized into XML.

It is not difficult to record the data serialized into XML by WebService. You only need to add the implementation of the soap extension soapextension class to WebService. The main methods used are chainsream and processmessage.

Processmessage (soapmessage message) has four stages:

Soapmessagestage. beforedeserialize (before deserialization), soapmessagestage. serialize (before serialization), soapmessagestage. afterserialize (after serialization) and soapmessagestage. afterdeserialize (after deserialization)

Pay attention to the following points during use:

1. soap extensions with different priorities have different calling sequence in different stages of SOAP message transmission. They can be divided into two stages: serialize stage, its invocation is performed according to the priority of the soap Extension from low to high,

In the deserialize stage, the call is executed from high to low according to the soap extension priority.

2. chainstream is called in sequence from the higher priority to the lower priority of soap extension, and is executed four times.

3. It is of a high priority to be close to the transport layer of the slave network. In addition, during the whole serialization and deserialization process, chainstream is first executed before processmessage () is executed ()

4. the soapextension class may be called through the soapextensionattribute class (for each method) or the Web can be configured globally. config, app. the configuration of the entire method is used. However, because wince does not support global configuration, only one method attribute can be defined.

5. in the deserialization process, because the data is first obtained from the network transmission layer, its soapmessage. stream is not empty, while serialization is empty. You need to set a buffer in chainstream to fill the data.

There are three other methods for soapextension:

 

// Set the initialization attribute (used for global configuration)

Public override object getinitializer (type servicetype)
{
Return System. Web. httpcontext. Current. Request. mappath (".") + "\ log.txt ";
}

// Obtain the attributes used for soapextensionattribute calling (used for Attribute calling)

Public override object getinitializer (logicalmethodinfo methodinfo, soapextensionattribute attribute)
{
Return (extensionattribute) Attribute). filename;
}

// Get the attributes set by getinitializer ().

Public override void initialize (Object initializer)
{
Filename = (string) initializer;
}

The global config configuration code is as follows:

<WebServices>
<Soapextensiontypes>
<Add type = "lyerp. myextension, lyerp" priority = "1" group = "high"/>
</Soapextensiontypes>

This example only records the data serialized into XML by WebService. It can be used for testing, XML encryption, compression, and other operations.

Example program:

Http://download.csdn.net/detail/jj516585042/4941845

 

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.