Analysis of WebService transmission data streams and Data Interaction

Source: Internet
Author: User

Key words: dpws, embedded devices, WebService, HTTP, sniffing, and micro framework ..

The dpws method in mf3.0 is used to implement interaction between an embedded device and a Web Service of the host on the IIS server. However, this is really hard to use. Today, we will record the first step in the use process. First, we will analyze how a client interacts with a WebService and the format of the sent data stream, then encapsulate the SOAP header in the device and send it with httpclient.

Wireshark is used to analyze data packets for network interaction.

First, define a simple WebService running on IIS:

Namespace cashfree. Vending. Web. WebService
{
[WebService (namespace = "http://tempuri.org/")]
[Webservicebinding (conformsto = wsiprofiles. basicprofile1_1)]
[System. componentmodel. toolboxitem (false)]
Public class iisws: system. Web. Services. WebService
{

[Webmethod]
Public String helloworld ()
{
Return "Hello Robin ";
}

[Webmethod]
Public int add (int A, int B)
{
Return A + B;
}
}
}

Then define a client to access this WebService:

Namespace cashfree. Vending. iiswsinvoke
{
Class Program
{
Static void main (string [] ARGs)
{
Iswssoapclient isclient = new iswssoapclient ();
Console. writeline (isclient. Add (2, 3 ));
}
}
}

After the WebService is published, compile the client file and find the EXE file of the client.

In this case, enable Wireshark, monitor the data streams sent from the network adapter, and set filtering. The format is as follows:

(IP. addr eq 10.10.20.33 and IP. addr eq 192.168.0.100) and (TCP. Port EQ 1795 and TCP. Port EQ 8088)

Double-click the client to access the WebService on IIS and obtain the following data packet list:

This produces a complete interaction process. from the bottom up, the leftmost column is the frame ID.

I parsed several frames from 199 to 122 to get the following format:

First, the client sends a request to the IIS server. The request address is/WebService/iisws. asmx, which supports http1.1.

Then the connection type is to keep the connection.

 

This is an ACK returned by the server to the client to maintain the connection. The connection is successful.

Then the client starts to send a request to call the service above IIS, and two parameters are passed:

A = 2, B = 3;

After encapsulation, there is a header and a body. In mf2.5, envelope has a class library that directly corresponds to the SOAP header and body. In 3.0, I searched for xmldocument for N and did not find it for a long time. It was clearly written on mdsn. However, if mf is used for parsing, xmlreader can be called. It is only troublesome, but provides the most basic XML access method. You need to find one node and one node.

The server first returns an ACK and then follows an XML file to indicate the call result:

<Addresult> 5 </addresult>

Here, after we know the transmitted data format, we can encapsulate the SOAP message and then directly transmit it to the server.

Thursday, January 08,200 9

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.