⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unsubscribehandler.java

📁 采用JAVA开发
💻 JAVA
字号:
/*
 * Created on 2004-7-30
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.gctech.misc.provision.handler;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.input.SAXBuilder;

import com.gctech.misc.provision.bean.UnSubscribeBean;
import com.gctech.misc.provision.bean.UnSubscribeResBean;
import com.gctech.misc.util.SOAPClient;

/**
 * <p>Title:反向取消处理类</p>
 * <p>Description:</p>
 * <p>Copyright: Copyright (c) Gctech 2004-7-30</p>
 * <p>Company: 吉芙德资讯有限公司</p>
 *
 * @version 1.0
 * @author liyi
 *
 */
public class UnSubscribeHandler {
	public UnSubscribeResBean handle(String SOAPUrl, String xmlFile2Send, String SOAPAction, UnSubscribeBean bean) {
		try {
			/* first, get and initialize an engine */
			VelocityEngine ve = new VelocityEngine();
			ve.init();
			/* next, get the Template */
			Template t = ve.getTemplate(xmlFile2Send);
			/* create a context and add data */
			VelocityContext context = new VelocityContext();
			context.put("version", bean.getVersion());
			context.put("senddevicetype", bean.getSenddevicetype());
			context.put("senddeviceid", bean.getSenddeviceid());
			context.put("destdevicetype", bean.getDestdevicetype());
			context.put("destdeviceid", bean.getDestdeviceid());
			context.put("feeusertype", bean.getFeeusertype());
			context.put("feemsisdn", bean.getFeemsisdn());
			context.put("feepseudocode", bean.getFeepseudocode());
			context.put("destusertype", bean.getDestdevicetype());
			context.put("destmsisdn", bean.getDestmsisdn());
			context.put("destpseudocode", bean.getDestpseudocode());
			context.put("spid", bean.getSpid());
			context.put("spserviceid", bean.getSpserviceid());
			/* now render the template into a StringWriter */
			StringWriter writer = new StringWriter();
			t.merge(context, writer);
			/* show the World */
			String response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + SOAPClient.provision(SOAPUrl, writer.toString(), SOAPAction);

			UnSubscribeResBean respBean = new UnSubscribeResBean();
			Namespace soapNS = Namespace.getNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
			Namespace subNS = Namespace.getNamespace("http://www.monternet.com/dsmp/schemas/");
			try {
				SAXBuilder builder = null;
				builder = new SAXBuilder();
				Document doc = builder.build(new StringReader(response));
				Element root = doc.getRootElement();
				Element versionEle = root.getChild("Body", soapNS).getChild("UnSubscribeServiceResp", subNS).getChild("Version", subNS);
				respBean.setVersion(versionEle.getText());
				Element hRetEle = root.getChild("Body", soapNS).getChild("UnSubscribeServiceResp", subNS).getChild("hRet", subNS);
				respBean.setHret(hRetEle.getText());
				Element msgTypeEle = root.getChild("Body", soapNS).getChild("UnSubscribeServiceResp", subNS).getChild("MsgType", subNS);
				respBean.setMsgtype(msgTypeEle.getText());
			} catch (JDOMException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return respBean;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	public static void main(String[] args) throws Exception {
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -