SP SMS Development -Provision Interface Implementation - Positive Ordering Instance Code

xiaoxiao2021-03-30  243

Instance code: MyProvision.jsp, implemented with JSP.

<% @ Page ContentTyPe = "Text / XML; Charset = UTF-8"%> <% @ page import = "com.aaa.appn. * "%> <% @ page import =" java.io. * "%> <% @ page import =" org.jdom.xpath. * "%> // Of course, the XML data is available. <% @ page import = "org.jdom. *"%> <% @ page import = "java.util. *"%> <% // user sends custom or canceling instructions to the corresponding SP special service number via mobile phone. The gateway receives the MO message and initiates the MO authentication batch request, // MISC to receive the MO authentication price request, cancel the on-demand command match; // If the judgment command is custom or canceling the instruction, the MISC will Send a subscription relationship to the SP Synchronous request package SyncORDERRELATIONREQ

boolean resultStr = true; String XMLData = null; StringBuffer tempStringBuffer = new StringBuffer (); String tempString = null; BufferedReader reader = request.getReader (); // MISC receiving the synchronization request packet subscription relationship SyncOrderRelationReq while ((tempString = reader. readLine ()) = null)! {tempStringBuffer.append (tempString); // read subscription relationship content synchronization request packet SyncOrderRelationReq} XMLData = tempStringBuffer.toString (); // convert subscription relationship synchronization request packet SyncOrderRelationReq content STRING, storage In XMLDATA

IF (xmldata == null && xmldata.length () <10) {resultStr = false;} TempstringBuffer.setLength (0); // Clear TempstringBuffer Tempstring = NULL;

//out.println ("xml: =" (xmldata.equals ("))))

Org.jdom.input.saxbuilder sb = new org.jdom.input.saxbuilder (); org.jdom.document doc = null; // xmlData is non-empty character if (XmlData.equals (")) {// DOC = sb.build ("/ home / web / proVision.xml"); return;} else {// Call the following function, write the provision.xml and the provision.log file. Write ("/ Home / Web / Provision.xml", XMLDATA); // Local Provision.xml is a temporary file; append ("/ home / web / provision.log", xmldata); // provides.log is A record file for a synchronization information; DOC = Sb.Build ("/ home / web / provision.xml"); // Read the proVision.xml file, how to use SB and DOC is not very clear;} // The following is reading Take the information of Provision.xml to explain the part definitions of the XML file, and read the value to the variable. Org.jdom.Element Root = doc.getrootElement (); element syncorderReLanceReq = null; element send_address = null; element dest_address = null; element feedr_id = null; element destuser_id = null;

String transactionId = null; string msgtype = null; string hret = null; string version = null; // ------------------ String linkid = null; string actionID = NULL; string actionReasonid = null; string spid = null; string spserviceid = null; string accessmode = null; string featureStr = null; // --------------------- -String Send_Address_DeviceType = null; String Send_Address_DeviceID = null; String Dest_Address_DeviceType = null; String Dest_Address_DeviceID = null; String FeeUser_ID_UserIDType = null; String FeeUser_ID_MSISDN = null; String FeeUser_ID_PseudoCode = null; String DestUser_ID_UserIDType = null; String DestUser_ID_MSISDN = null; String DestUser_ID_PseudoCode = null ; 读 读 读 信息 信息; element header = (element) xpath.selectsinglenode (root, "/ soap-env: envelope / soap-env: header"); list ns = header.getChildren (); for (Iterator i = Ns.ITerator (); I.hasNext (); {Object n = i.next (); if (n instanceof element) {ELEMENT E = (ELEMENT) N; if (E.GETNAME (). Equals ("TransactionID). ")) {TransactionId = E.GettextNormalize ();}}} // read BODY information; Element body = (element) xpat H.selectsinglenode (root, "/ soap-env: envelope / soap-env: body"); ns = body.getchildren (); for (Iterator i = ns.ITERATOR (); I.hasnext ();) {Object n = i.next (); if (n instanceof element) {element E = (element) n; if (e.getname (). Equals ("SyncorderReranceReq")) {syncorderReranceReq = E;}}}

// Get all children of the packet. IF (syncorderReLanceReq! = null) {ns = syncorderReLanceReq.getChildren (); for (Iterator i = ns.iterator (); I.hasNext ();) {Object n = i.next (); if (n instanceof element) {ELEMENT E = (Element) n; // ------------------------------------ IF (e .getname (). Equals ("send_address")) {send_address = E;} if (E.GETNAME (). Equals ("dest_address") {dest_address = E;} if (E.GETNAME (). Equals. FEEUSER_ID ") {feed_id = e;} if (E.GETNAME (). Equals (" destuser_id ")) {Destuser_ID = E;} // ----------------- ------------------- IF (E.GETNAME (). Equals ("Version")) {Version = E.GettextNormalize ();} if (E.GETNAME ). Equals ("msgtype")) {msgtype = E.GettextNormalize ();} if (E.GETNAME (). Equals ("linkid")) {linkid = E.GettextNormalize ();} if (E.GETNAME ). Equals ("actionID")) {actionID = E.GettextNormalize ();} if (E.GETNAME (). Equals ("actionreasonid") {ActionReasonId = E.GettextNorMalize ();} If (E.GETNAME (). Equals ("spid")) {spid = E.GettextNormalize ();} if (E.GETNAME (). Equals ("spserviceid") {spserviceID = E.GettextNormalize ();} If (E.GETNAME (). Equals ("accessmode")) {accessMode = E.GettextNormalize ();} if (E.GETNAME (). Equals ("featureStr") {featureStr = E.GetTextNorMalize ();}}}} // analyze the data package

IF (send_address! = null) {ns = send_address.getchildren (); for (Iterator i = ns.Iterator (); I.hasnext ();) {Object n = i.next (); if (n instanceof element) {ELEMENT E = (ELEMENT) N; if (E.GETNAME (). Equals ("DeviceType")) {send_address_deviceType = E.GETTEXTNORMALIZE ();} if (E.GETNAME (). Equals ("deviceID")) { Send_address_deviceid = E.GettextNormalize ();}}}}} {ns = dest_address.getChildren (); for (Iterator i = ns.ITerator (); I.hasNext ();) {Object n = i.next (); if (n instanceof element) {ELEMENT E = (ELEMENT) N; if ("deviceType") {dest_address_deviceType = E.getTextNormalize ();} if (e.); GetName (). Equals ("DeviceID")) {dest_address_deviceid = E.GETTEXTNORMALIZE ();}}}}}}}}}}} {ns = feEuser_id.getchildren (); for (Iterator i = ns.Iterator () I.hasNext (); {Object n = i.next (); if (n instanceof element) {ELEMENT E = (ELEMENT) N; if (E.GETNAME (). Equals ("useridtype") { Feeuser_id_useridtype = E.GetTextNormalize ();} if (E.GETNAME (). Equals ("msisdn")) {freeuser_id_msdn = E.GETTEXTNORMALIZE ();} if (E.GETNAME (). Equals ("pseudocode") { Feeuser_id_pseudocode = E.GettextNormalize ();}}}}} {ns = destuser_id.getchildren (); for (Iterator i = ns.ITerator (); I.hasNext ();) {Object n = i.next (); if (n instanceof element) {ELEMENT E = (ELEMENT) N; if (E.GETNAME (). Equals ("useridType")) {Destuser_ID_UseridType = E.getTextNormalize ();} if (e.); GetName (). Equals.

MSISDN ")) {Destuser_id_msisdn = E.GettextNormalize ();} if (" pseudocode ") {Destuser_id_pseudocode = E.GETTEXTNORMALIZE = E.GetTextNormalize ();}}}} // More content is moved by mobile Define the SOAP XML field, mainly explaining and reading data to variables // below is a business logic section, and now write to the JSP, you can use it directly to the business layer to use servlet to do business processing.

// To increase the service information synchronization, only you need to modify the following part of the code; if (! TransactionID = null && ActionID = null && DestUser_ID_MSISDN = null && SPServiceID = null!!!) {Sun.misc.BASE64Decoder b = new sun.misc.BASE64Decoder (); BYTE [] BB = B.DecodeBuffer (FeatureStr); // Service order parameter (Base64 encryption), the content is long-term number space user send content, and use decodebase64decoder () BYTE []

String content = new string (BB, "GB2312"); // Convert to String; String SQL _ = "Insert Into Provision (Content, ActionID, ProvisionTime, MSISDN, PSERVICEID) VALUES ('" content "," ActionID " , now (), '" Destuser_ID_MSISDN "', '" spserviceid " "; dbutil.exe (SQL _); // Write the provision's ordering information into the data sheet; database write operation function content = content. Trim (). TouPpercase (); actionId = actionid.trim (). Touppercase (); spserviceid = spserviceid.trim (). Touppercase (); int userid = bizlogicutil.getuserid (destuser_id_msiSDN); // Analyze user synchronization order information Content, and update the corresponding SP registration database table; if (Content.StartSwith ("aa")) {BizLogicutil.registerUser (UserID, 3, 1, null); NVSHService.register (userID); // Registered men and women dictionary users; } else IF ("a")) {BizLogicutil.registerUser (UserID, 2, 1, null); // The following three IF code sense is whether or not the custom information sent by the user "AA" and " A ", as long as the SPServiceID of the ordering information is synchronized, the operation, // actionID, service status management action code, the specific value is as follows: // 1: Open service; // 2: Stop service; // 3: Activate Service; // 4: Suspension Service;} else IF (spserviceid.startswith ("- test1") && actionID.startSwith ("1")) {BizLogicutil.RegisterUser (UserID, 1, 1, null); // Register User Function ELSE IF (SPS) ERVICEID.STARTSWITH ("- test2") && actionID.StartSwith ("2")) {// stop service; bizLogicutil.RegisterUser (userID, 1, 2, null); // logout user functions.

Else IF ("- Qtyx") && actionId.startSwith ("2")) {// Stop service; BizLogicutil.RegisterUser (UserID, 2, 2, null); BizLogicutil.RegisterUser (UserID, 3, 2) , NULL);} // Write a group-issued information table, send a subscriber information to the subscriber information, SMS or menu; SQL _ = "Insert Into Pushsms (Content, MSISDN, PSERVICEID, Feetype, Feecode, Sended, ActionID, Revtime) VALUES ('" content ",' " destuser_id_msisdn ", '" spserviceid ",' 01 ',' 00 ', 0, " actionid ", now () "; dbutil.exe (SQL_) }

/ * String TransactionId = null; string msgtype = null; string hret = null; string version = null; // ------------------ String linkid = null; string ActionID = null; string spid = null; string spserviceid = null; string accessmode = null; string featureStr = null; // ------------------- --- String Send_Address_DeviceType = null; String Send_Address_DeviceID = null; String Dest_Address_DeviceType = null; String Dest_Address_DeviceID = null; String FeeUser_ID_UserIDType = null; String FeeUser_ID_MSISDN = null; String FeeUser_ID_PseudoCode = null; String DestUser_ID_UserIDType = null; String DestUser_ID_MSISDN = null; String DestUser_ID_PseudoCode = NULL; * / hret = "0";%> <%! // overwrites write content to file file; /// p l = = null; trywriter Writer = NULL; try {i (File! = null && content! = null) {Writer = New FileWriter (file); new string ("GBK")));}} Catch (ioException ex) {} finally {if (writer! = Null);} catch (ooException ex1) {}}}} // Add Comtent to File File

Public static void append (string file, string content) {fileoutputstream fo = null; bufferedwriter fout = null; string contents = ""; try {

FO = New FileOutputStream (File, True); Fout = New BufferedWriter (New OutputStreamWriter (fo)); Contents = Content "/ N"; Fout.write (Contents, 0, Contents.Length ()); fout.close ); Fo.close (); catch (Exception E) {} finally {try {fout.close (); fo.close ();} catch (exception E1) {}}}

}

%> // This part of the code basically meets the requirements, can not be changed; // After the SP receives the synchronous request package, the subscription request is handled accordingly, and return to the order relationship Synchronization Answer SyncOrderReranceResP // MISC receives the answer package After that, according to whether the return result is correct, the formal order relationship is generated or the ordering relationship is generated, and the subscription is issued to the user to order success or cancel the successful reminder message // SyncorderReranceResp message field description: // field name importance Type Description // MSGTYPE Must String Message Type // TransactionID Must String This message number // Version must string the version number of the interface message, this time all interface messages are "1.5.0" // hret must INTEGER Return Value, main mistakes are as follows: // 0: Success // 4007: MISC Synchronous Open Service, but the SP end has a subscription relationship, and the state is open // 4008: MISC synchronous open service, and the SP terminal does not have order relationship, but Open service failed // 4010: MISC synchronization stop service, and the SP end has a subscription relationship, but the cancel service failed // 4011: MISC synchronized stop service, but the SP end does not have order relationship // 4012: MISC Synchronous pause service, and SP There is a subscription relationship, but the pause service failed // 4013: MISC synchronous pause service, but the SP terminal does not have order relationships // 4015: MISC synchronous activation service, but the SP end has a subscription relationship, and the state is open // 4016: MISC synchronous activation services, but there is no order relationship / / other errors, please refer to the "MISC System SMS SP Access Guide - Interface Reform Volume".

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

New Post(0)