📄 recvmofromwapdm.java~4~
字号:
package business.mo;
import java.io.*;
import javax.servlet.http.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Connection;
import business.mt.*;
public class RecvMOFromWapdm
{
private Connection dbConnection = null;
private Statement stmt = null;
private ResultSet rs = null;
public RecvMOFromWapdm() {
}
public String processMoData(HttpServletRequest request) {
try {
DocumentBuilderFactory documentbuilderfactory = DocumentBuilderFactory.
newInstance();
//解析XML文件生成DOM文档的接口类,以便访问DOM
//DocumentBuilder documentbuilder = documentbuilderfactory.
// newDocumentBuilder();
Document document = documentbuilder.parse(request.getInputStream());
document.normalize();
//获得Root元素
Element root = document.getDocumentElement();
System.out.println("NodeName: " + root.getNodeName());
/* try {
WebSiteSrc ws = new WebSiteSrc();
String su = ws.storeURL;
File fd = new File(su + "rootwapdm.log");
RandomAccessFile raf = new RandomAccessFile(fd, "rw");
raf.seek(raf.length());
raf.write( (root.getNodeName() + "::" +
root.getNodeName().equalsIgnoreCase(
"SBMP_USER_CANCEL_CONTRACTED_BUSNESS_MESSAGE")).getBytes());
raf.close();
}
catch (FileNotFoundException e) {
e.printStackTrace(System.out);
}*/
//SBMP_MO_MESSAGE节点
if (root.getNodeName().equalsIgnoreCase("SBMP_MO_MESSAGE")) {
this.getMO_MESSAGE(document.getElementsByTagName("SBMP_MO_MESSAGE"));
}
else if (root.getNodeName().equalsIgnoreCase("SBMP_REPORT_MESSAGE")) {
this.getREPORT_MESSAGE(document.getElementsByTagName(
"SBMP_REPORT_MESSAGE"));
}
else if (root.getNodeName().equalsIgnoreCase(
"SBMP_USER_ORDER_BUSINESS_MESSAGE")) {
this.getUSER_ORDER(document.getElementsByTagName(
"SBMP_USER_ORDER_BUSINESS_MESSAGE"));
}
else if (root.getNodeName().equalsIgnoreCase(
"SBMP_USER_CANCEL_CONTRACTED_BUSNESS_MESSAGE")) {
this.getUSER_CANCEL(document.getElementsByTagName(
"SBMP_USER_CANCEL_CONTRACTED_BUSNESS_MESSAGE"));
}
else {
System.out.println("The request is unknown!");
}
}
catch (ParserConfigurationException e) {
System.out.println(e);
}
catch (IOException e) {
System.out.println(e);
}
catch (SAXException e) {
}
finally {
return "OK";
/*
byte [] buffer = new byte [2048];
FileOutputStream fos = new FileOutputStream("D:/result.xml");
request.getInputStream().read(buffer);
fos.write(buffer);
fos.close();
System.out.println("i was called " + ++times + " times !");*/
}
}
public void getMO_MESSAGE(NodeList MO_MESSAGE) {
SendMTtoWapdm sendSMSToWapdm1 = new SendMTtoWapdm();
Element node = (Element) MO_MESSAGE.item(0);
//MO信息连接标识
int CONNECT_ID = Integer.parseInt(node.getElementsByTagName("CONNECT_ID").
item(0).getFirstChild().getNodeValue());
//MO消息ID
String MO_MESSAGE_ID = null;
if (node.getElementsByTagName("MO_MESSAGE_ID").item(0) != null) {
MO_MESSAGE_ID = node.getElementsByTagName(
"MO_MESSAGE_ID").
item(0).getFirstChild().getNodeValue().toString();
}
//短信业务平台接收到此MO消息的日期
String RECEIVE_DATE = node.getElementsByTagName("RECEIVE_DATE").
item(0).getFirstChild().getNodeValue();
//短信业务平台接收到此MO消息的时间
String RECEIVE_TIME = node.getElementsByTagName("RECEIVE_TIME").
item(0).getFirstChild().getNodeValue();
//转发此MO消息的网关
String GATEWAY_ID = node.getElementsByTagName("GATEWAY_ID").
item(0).getFirstChild().getNodeValue();
//此手机号码是否有效 0:无效,1:有效
int VALID = Integer.parseInt(node.getElementsByTagName("VALID").
item(0).getFirstChild().getNodeValue());
//手机号码所在城市的区号
String CITY_CODE = node.getElementsByTagName("CITY_CODE").
item(0).getFirstChild().getNodeValue();
//手机号码所在城市的名称
String CITY_NAME = node.getElementsByTagName("CITY_NAME").
item(0).getFirstChild().getNodeValue();
//手机号码所在省的区号
String STATE_CODE = node.getElementsByTagName("STATE_CODE").
item(0).getFirstChild().getNodeValue();
//手机号码所在省的名称
String STATE_NAME = node.getElementsByTagName("STATE_NAME").
item(0).getFirstChild().getNodeValue();
//GSM协议
String TP_PID = node.getElementsByTagName("TP_PID").
item(0).getFirstChild().getNodeValue();
//GSM协议
String TP_UDHI = node.getElementsByTagName("TP_UDHI").
item(0).getFirstChild().getNodeValue();
//发送此MO信息的手机号码
String MSISDN = node.getElementsByTagName("MSISDN").
item(0).getFirstChild().getNodeValue();
//消息类型
int MESSAGE_TYPE = Integer.parseInt(node.getElementsByTagName(
"MESSAGE_TYPE").
item(0).getFirstChild().getNodeValue());
//消息内容
String MESSAGE = node.getElementsByTagName("MESSAGE").
item(0).getFirstChild().getNodeValue();
//用户发送此MO消息时的长号码
String LONG_CODE = node.getElementsByTagName("LONG_CODE").
item(0).getFirstChild().getNodeValue();
//用户发送此MO消息时的特符号
String SERVICE_CODE = node.getElementsByTagName("SERVICE_CODE").
item(0).getFirstChild().getNodeValue();
///////////下面商户可以对接收到的mo消息处理了/////////////////////
//System.out.println("CONNECT_ID-> " + CONNECT_ID);
//System.out.println("MO_MESSAGE_ID-> " + MO_MESSAGE_ID);
//System.out.println("RECEIVE_DATE-> " + RECEIVE_DATE);
//System.out.println("RECEIVE_TIME-> " + RECEIVE_TIME);
//System.out.println("GATEWAY_ID-> " + GATEWAY_ID);
String str = "CONNECT_ID-> " + CONNECT_ID + "MO_MESSAGE_ID-> " +
MO_MESSAGE_ID + "GATEWAY_ID-> " + GATEWAY_ID + "VALID->" + VALID +
"MSISDN->" + MSISDN;
try {
File fd = new File("D:/wapdm.log");
RandomAccessFile raf = new RandomAccessFile(fd, "rw");
raf.seek(raf.length());
raf.write(str.getBytes());
raf.close();
}
catch (FileNotFoundException e) {
e.printStackTrace(System.out);
}
catch (IOException e) {
e.printStackTrace(System.out);
}
/* String dzxx =
"select b.cxb002 as cxb002,b.aah003,b.cxb001 as cxb001 from zhcwdx.cx01 a,zhcwdx.cx02 b where a.cxa004='" +
MESSAGE + "' and a.cxa002=b.cxa002 order by b.aah003 desc";
try {
dbConnection = getDBConnection();
stmt = createStatement(dbConnection);
rs = stmt.executeQuery(dzxx);
if (rs.next()) {
if (LONG_CODE.equals("6883")) {
sendSMSToWapdm1.SmbppSendUnicodeMessage(MO_MESSAGE_ID + "",
"4261ZJCX4261T0100", "",
MSISDN,
MSISDN,
rs.getString("cxb002"), 0, 0,
0, 0, 0,
0);
String cx05 =
"insert into zhcwdx.cx05(CXC001,CXB001,cxc002,cxc003)values('" +
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -