Apply WSDK- Implement and use DIME's Web Services (below)

zhaozj2021-02-17  82

Apply WSDK- Implement and use DIME's Web Services

Mood

2002-10-20

Article Type: in-depth

Difficult Level: 7/9

Version: 1.26

two. Generate Client Consumer Web Services

This part we will do two things, the first generation of proxy, the second is to write some code to get the picture from the Web Services.

First, the Proxy class of the above Web Services, here I suggested using WSDL.exe to do this, because the function of automatically generating the Proxy class using VS.NET is not not, but it will automatically update and maintain with Web Services Server The consistency between, and then we will see the code we want to modify this proxy class so that you will find that vs.net will also modify the code of the Proxy class. The basic order is as follows:

CD / TEMP WSDL / L: CS /OUT :WSDKDIMESERVER.CS / URLKEY: WSDKDIMESERVER http: //localhost/wsdk/dimeMessage/wsdkdimeserver.asmx? WSDL

After we select Add Existing Items in vs.net, then select the WSDKDIMserver.cs file in the Temp directory, then VS.NET will automatically copy this file to the directory of our project. One of the following steps is very important, that is, the code in the Proxy class is modified, and steps are two: First: first add a reference to Microsoft.WSDK in the client's project. Two: Add USING Microsoft.wsdk in the Proxy of WSDKDimeServer.cs; then modify the inherited parent class from the original system.Web.Services.Protocols.SoAphttpClientProtocol into Microsoft.wsdk.wsdkClientProtocol

After that, it is some client code. I think it is not too big to consume some of our Web Services before, the code is as follows:

Private void btnetdime_click (Object Sender, System.Eventargs E)

{

Service1 svc = new service1 ();

BYTE [] bogbuffer = {0,1};

MemoryStream Stm = New MemoryStream (Bogbuffer);

DimeAttachment Dimeatt = New Dimeattachment

("Image / JPEG", TypeFormatenum.mediatype, STM);

Svc.RequestsoapContext.attachments.add (Dimeatt);

Svc.getdotnettoolslog ();

IF (svc.responsesoapcontext.attachments.count> 0)

{

Bitmap bmp = new bitmap (svc.responsesoapcontext.attachments [0] .stream);

THIS.PICBOX.IMAGE = BMP;

}

} If compiled, the F5 operation results are as follows: Already very interesting. For the above example so that our client might look like this: public void btnGetImag_Click (object sender, System.EventArgs e) {localhost.BinaryServices BinServer = new localhost.binaryServices (); Byte [] arrBytes = BinServer.GetImage (); IF (arrbytes! = Null) {memorystram = new memoryStream (arrbytes); bitmap image = new bitmap; picbox.image = image;}}

three. Set up Trace debugging.

The settings of this tool are actually just a little secret. When MS SOAP Toolkit V2.0, I am very interested in it. Finally, I found the answer in the discussion group on the Internet. There is nothing different from V3.0, and the only improvement is to increase the tracking of DIME. In fact, the secret is to understand the meaning of Listen and Forward TO in Trace Setup. Complete explanation is that MSSoApt.exe opens a TCP / IP's socket on the machine running, listening to the port set in Local Port #, and any TCP / IP is forwarded to the forward to set. Port device, Forward TO often defaults to this unit's web server, of course you can go to other Web Server. What will you think of? Yes - Modify our Web Services's Proxy class. Specifically, add the following code to the client's app.config:

Value = "http:// localhost: 8080 / myproject / wsdk / timeMessage / wsdkdimeserver.asmx" />

I like VS.NET to process App.config because after compiling, you will find the Config file that is the same as your EXE file in the compiling directory, which is vs.net to help you do. Then modify our proxy code:

public Service1 () {string urlSetting = System.Configuration.ConfigurationSettings.AppSettings [ "WSDKDIMEService"]; if ((urlSetting = null)!) {this.Url = urlSetting;} else {this.Url = "http: // localhost /MyProject/wsdk/dimeMessage/wsdkdimeserver.asmx ";}} then starts Microsoft Soap Tookit V3 Trace Utility, running our client as before. The results are as follows: Will you like TRACE UTILITY, or still like the TcaPtrace in Pocketsoap or the first SOAP debugging tool claimed in XMLSPY, but Trace Utilty is really simple and applicable. I am willing to promise you to show you in the following article (but there is no time you wrote before, I found that this promise seems to be a lot, so don't really believe "I am willing" doesn't mean "I will do this") anyway, I hope more people are interested in Web Services, care about it, any sharing in this process will be a very happy experience. . I wish you a happy program!

Related files Download: [WSDKDIME.ZIP 22K]

especially:

This article original, 9CBS signature start, all text and photo copyright. Do not propagate, reprint, or adaptation without authorization.

If you have any questions or suggestions, please email new2001@msn.com

转载请注明原文地址:https://www.9cbs.com/read-30981.html

New Post(0)