WebService Issue 2 credit (ASP.NET C # actual combat example)

xiaoxiao2021-03-06  16

There are too many actual code, I only post key part, and, note, mainly for yourself, pay attention to the red word! The actual application needs to encrypt / decrypt SOAP HEADER.

Encryption / Decryption Article Reference: http://blog.9cbs.net/hnwanghb/archive/2005/03/19/323869.aspx

First define a data structure:

I still nested a strureMotefile structure!

///

/// Hotel Managing Data Structure /// Contains 2 Encryption Image Information /// Public StructHotelcertified {Public String ID; // Record Serial Number / Public String Certified_ID ; // Exquisite certificate number / public string name; // Name / public string sex; // gender / public string education_id; // Education / public string Identity_Card; // ID / PUBLIC STRING UNIT_NAME; // Unit Name / public String Obtain_Year; // Get Annual / Public String Establish_time; // Last Modified Time /

Public strureMotefile RMTPICFILE; / / Photo (Note: 2 Structure of Biltribute)}

///

/// Transfer 2 data structure /// String filename; // file name ///tete [] contents; // file content /// DateTime credime; // creation time /// DateTime LastAccesstime; // File Last Access Time /// DateTime LastWritetime; // File Last Modified Time /// Public Struct StruRureMotefile {Public String FileName; // File Name Public Byte [] Contents; / / File content public datetime codeTime; // File Create Time PUBLIC DATETIME LastAccesstime; // File Last Access Time PUBLIC DATETIME LastWRittime; // File Last Modified Time}

///

/// function Description: Get a qualification certificate for tourists [Hotel Manager] /// Parameter Description: Lastid - The client has updated the latest ID number, the current operation needs to get the ID number greater than lastid Record /// Parameter Description: Number - Number of records of data [Web Transportation is abnormal, so it needs to limit the number of data updated] /// [WebMethod (Description = "Get Hotel Hotel manager certificate information [including picture file] ")] [SoapHeader (" AuthenHeader ", Direction = SoapHeaderDirection.In, Required = true)] // authentication Code public structHotelCertified [] WebGetHotelCertified (int lastID, int number) {try {// data to be output THRDataExport objDataExport = new THRDataExport (objHRLogin.NewConnection ()); structHotelCertified [] pHotelCertified;! // if validated, data acquisition hotel manager if (! bAuthenUser) {if (AuthenHeader.ValidUser (AuthenHeader. username, AuthenHeader.Password, objHRLogin.DBConnection)) {return null;}} pHotelCertified = objDataExport.GetHotelCertifiedInfo (lastID, strHotelPicPath, number); // call to the program structure WebService binary objects comprise returning

// Code Note: ObjDataExport is an instance of a class of THRDATAEXPORT.

Return phoTelTified;} catch (exception e) {error;}}}

Code in THRDATAEXPORT:

///

/// function Description: Get the latest hotel manager qualification certificate information /// LastID-client has been updated the latest ID number, the current operation needs to get the ID number greater than Lastid record /// picture storage path /// Get recorded number /// structelcertified Structural array public structhotelcertified [] gethelcertifiedInfo (int lastid, string filepath, int getnum) {try {string strsql = ""; int ket = 0;

DataSet DS = new dataset (); / / =========================== Get data start ==== in the hotel manager qualification certificate =============================// Take all the data data of all the server, import DDS, different from DDS Tables [0] Record the full set of data on the server to filter strsql = "select * from t_hr_HOTEL_CERTIFIED WHERE ID> Lastid.toTString () " and rownum <= " getnum.toTString () " Order By ID ASC ";

OLEDBDataAdapter Dthotel = New OLEDBDataAdapter (strsql, cn);

// Fill record set DTHOTEL.FILL (DS, "T_HR_HOTEL_CERTITIFIED"); ICOUNT = DS.TABLES ["T_HR_HOTEL_CERTIED"]. Rows.count; // Get the Number of Hotel Manager Qualification Certificate of the Condition IF (iCount> 0) {structHotelCertified [] pHotelCert = new structHotelCertified [iCount]; for (int m = 0; m

// -------------------------- Get a hotel manager photo information Start -------------- -------------- PHOTELCERT [M] .rmtpicfile = getBinaryFile (@strfilename); // Read 2 credit // ------------- -------------- Get hotel manager photo information END ----------------------------} Return phtercert;} else {return null;} // =========================== Get data end of the hotel manager qualification certificate ================================================================================================================================================================= #} } ///

/// Get the specified file name [full path name, C: /TEMP/Data/12367.jpg] /// /// 2 hex digits private struRemoteFile GetBinaryFile (string FileName) {struRemoteFile pRmtFile = new struRemoteFile (); content if (File.Exists (@FileName)) {// read a file Stream fs = File.Open (FileName, Filemode.open; prmtfile.contents = new byte [fs.length];

fs.read (prmtfile.contents, 0, (int) fs.length); fs.close ();

// Get the time parameter of the file prmatfile.creationTime = file.getcreationTIME (FileName); prmtfile.lastaccesstime = file.getlastaccesstime (filename); prmtfile.lastwrittime = file.getlastwritetime (filename);}

Return prmtfile;}

Finally Note: If it is called a non-DOTNET program encoding, refer to the following WebService structure information. Reference URL: http://www.tttssss.com/webservice/thrdataservice.asmx? OP = WebGetErcertified

DataExchange

Click here for a complete list of operations.WebGetHotelCertified access to information Hotel manager qualifications [including image files] TestThe test form is only available for requests from the local machine. SOAPThe following is a sample SOAP request and response. The placeholders shown need To be replaced with actual value.post /webservice/thrdatasempice.asmx http / 1.1host: www.tttssss.com

Content-type: text / xml; charSet = UTF-8

Content-Length: Length

SOAPACTION: "http://www.tttsss.com/webservice/webgethotelcertified"

>>

Base64Binary

Base64Binary

Base64Binary

Base64Binary

des or rc2 or rijndael or tripledes

Int

int

http / 1.1 200 ok

Content-type: text / xml; charSet = UTF-8

Content-Length: Length

String

String

String

STRING

string

String

string

String

String

String

Base64Binary

DateTime

DateTime

DateTime

String

String

String

STRING

string

String

string

String

String

String

Base64Binary

DateTime

DateTime

DateTime

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

New Post(0)