反向取消接口规范-流程说明
1)SP代替用户,向MISC发起反向取消请求UnSubscribeServiceReq
并等待MISC处理
2)MISC对消息中的来源地址、企业代码进行鉴权,判断是否允许
该SP进行反向取消
3)接入鉴权成功后,再进行用户鉴权和订购关系鉴权,判断用户状
态是否正确以及是否存在订购关系
4)上面鉴权成功后,MISC向SP发送订购关系同步请求包
SyncOrderRelationReq
5)SP收到同步请求后,对订购请求做相应的取消处理,并返
回订购关系同步应答SyncOrderRelationResp
6)MISC收到应答后,判断应答值是否为0。如果应答值为0,则在
MISC中取消订购关系,并给SP返回成功的反向取消处理应答包
UnSubscribeServiceResp;如果应答值不为0,则不取消订购关系,同
时给SP返回不成功的反向取消应答包UnSubscribeServiceResp
7)SP如果收到MISC的错误响应,则说明取消失败,SP必须对这个失
败消息做相应处理,比如把已取消的订购关系恢复等等。
8)如果收到MISC的正确响应,则SP可以不做任何处理
11、反向取消接口消息定义
• 功能描述
此接口用于用户通过SP取消已订购的数据业务的时候,SP先通过该接口向MISC进行用户取消服务订购的请求。MISC进行取消服务订购成功后,SP才取消用户对应的业务订购关系。
消息名
|
消息类型
|
消息方向
|
UnSubscribeServiceReq
|
Request
|
SP
àMISC
|
UnSubscribeServiceResp
|
Response
|
MISC
àSP
|
•
接口内容描述
UnSubscribeServiceReq
消息字段描述
:
字段名
|
重要性
|
类型
|
说明
|
MsgType
|
必须
|
string
|
消息类型
|
TransactionID
|
必须
|
string
|
该消息编号(不能超过16位)
|
Version
|
必须
|
string
|
该接口消息的版本号,本次所有的接口消息
的版本都为“1.5.0”
|
Send_Address
|
必须
|
address_info_schema
|
发送方的地址
|
Dest_Address
|
必须
|
address_info_schema
|
接收方的地址
|
FeeUser_ID
|
必须
|
user_id_schema
|
计费用户标识
|
DestUser_ID
|
必须
|
user_id_schema
|
使用用户标识
当使用用户和计费用户为同一用户的时候,
FeeUser_ID和DestUser_ID的值相同。
|
Service_ID
|
必须
|
service_id_schema
|
服务标识
|
UnSubscribeServiceResp消息字段描述:
字段名
|
重要性
|
类型
|
说明
|
MsgType
|
必须
|
string
|
消息类型
|
TransactionID
|
必须
|
string
|
该消息编号
|
Version
|
必须
|
string
|
该接口消息的版本号,本次所有的接口消
息的版本都为“1.5.0”
|
hRet
|
必须
|
integer
|
返回值。具体定义请参见《MISC系
统短信SP接入指南-接口改造分册》
|
反向取消实例代码。
以下代码保留所有权。请不要转载。
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%@ page language="java" contentType="text/html; charset=gb2312" import="java.sql.*" %>
<%@ include file="../Cos/cos.jsp" %>
<%@ include file="fun.jsp" %>
<%@ page import="java.util.*"%>
<%@ page import="java.net.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.AAA.appk.*"%>
<%!
private String SendReq(String TransactionID,String sp_id,String dest_mobile,
String fee_mobile,String service,String spnumber,String send_DeviceID,StringBuffer bf){
String sReturn="success";
try
{
//http://dsmp.gd.monternet.com/dsmp/dsmp.wsdl
// ???p://211.136.253.116/dsmp/dsmp.wsdl
String sURL = " http://211.136.253.116/dsmp/dsmp.wsdl";
sURL=sURL.trim();
URL Url = new URL(sURL);
HttpURLConnection connection = (HttpURLConnection) Url.openConnection();//建立连接
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches (false);
connection.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
PrintWriter out = new PrintWriter(connection.getOutputStream());//准备输出数据。
//反向取消XML UnSubscribeServiceReq包数据写入STRINGBUFFER中。
StringBuffer xmlStr=new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
xmlStr.append("<SOAP-ENV:Envelope");
xmlStr.append(" xmlns:SOAP-ENV=\" http://schemas.xmlsoap.org/soap/envelope/\"");
xmlStr.append(" xmlns:SOAP-ENC=\" http://schemas.xmlsoap.org/soap/encoding/\"");
xmlStr.append(" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\"");
xmlStr.append(" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema\"");
xmlStr.append("SOAP-ENV:encodingStyle=\" http://schemas.xmlsoap.org/soap/encoding/\"");
xmlStr.append(" xmlns=\" http://www.monternet.com/dsmp/schemas/\">");
xmlStr.append("<SOAP-ENV:Header>");
xmlStr.append("<TransactionID xmlns=\" http://www.monternet.com/dsmp/schemas/\" xsi:type=\"xsd:string\">0011"+dest_mobile+"</TransactionID>");
xmlStr.append("</SOAP-ENV:Header>");
xmlStr.append("<SOAP-ENV:Body>");
xmlStr.append("<UnSubscribeServiceReq xmlns=\" http://www.monternet.com/dsmp/schemas/\">");
xmlStr.append("<Version>1.5.0</Version>");
xmlStr.append("<MsgType>UnSubscribeServiceReq</MsgType>");
xmlStr.append("<Send_Address>");
xmlStr.append("<DeviceType>400</DeviceType>");
xmlStr.append("<DeviceID>"+sp_id+"</DeviceID>");
xmlStr.append("</Send_Address>");
xmlStr.append("<Dest_Address>");
xmlStr.append("<DeviceType>0</DeviceType>");
xmlStr.append("<DeviceID>0011</DeviceID>");
xmlStr.append("</Dest_Address>");
xmlStr.append("<FeeUser_ID>");
xmlStr.append("<UserIDType>1</UserIDType>");
xmlStr.append("<MSISDN>"+fee_mobile+"</MSISDN>");
xmlStr.append("<PseudoCode />");
xmlStr.append("</FeeUser_ID>");
xmlStr.append("<DestUser_ID>");
xmlStr.append("<UserIDType>1</UserIDType>");
xmlStr.append("<MSISDN>"+dest_mobile+"</MSISDN>");
xmlStr.append("<PseudoCode />");
xmlStr.append("</DestUser_ID>");
xmlStr.append("<Service_ID>");
xmlStr.append("<ServiceIDType>1</ServiceIDType>");
xmlStr.append("<SPID>"+sp_id+"</SPID>");
xmlStr.append("<SPServiceID>"+service+"</SPServiceID>");
xmlStr.append("<AccessNo />");
xmlStr.append("<FeatureStr />");
xmlStr.append("</Service_ID>");
xmlStr.append("</UnSubscribeServiceReq>");
xmlStr.append("</SOAP-ENV:Body>");
xmlStr.append("</SOAP-ENV:Envelope>");
//向MISC输出数据
out.println(xmlStr.toString());
//把输出数据保存到BF里,
bf.append("start");
bf.append(xmlStr.toString());
bf.append("end");
out.close();
//读取连接返回的数据。UnSubscribeServiceResp?SyncOrderRelationReq?SyncOrderRelationResp?
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
bf.append("rstart");
bf.append(line);
bf.append("rend");
}
in.close();
}
catch (MalformedURLException e)
{
sReturn="fail";
bf.append("wap Connect SP Error1:"+e.toString());
}
catch (IOException e)
{
sReturn="fail";
bf.append("wap Connect SP Error2:"+e.toString());
}
return sReturn;
}
<%@ page language="java" contentType="text/html; charset=gb2312" import="java.sql.*" %>
<%@ include file="../Cos/cos.jsp" %>
<%@ include file="fun.jsp" %>
<%@ page import="java.util.*"%>
<%@ page import="java.net.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.AAA.appk.*"%>
<%!
private String SendReq(String TransactionID,String sp_id,String dest_mobile,
String fee_mobile,String service,String spnumber,String send_DeviceID,StringBuffer bf){
String sReturn="success";
try
{
//http://dsmp.gd.monternet.com/dsmp/dsmp.wsdl
// ???p://211.136.253.116/dsmp/dsmp.wsdl
String sURL = " http://211.136.253.116/dsmp/dsmp.wsdl";
sURL=sURL.trim();
URL Url = new URL(sURL);
HttpURLConnection connection = (HttpURLConnection) Url.openConnection();//建立连接
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches (false);
connection.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
PrintWriter out = new PrintWriter(connection.getOutputStream());//准备输出数据。
//反向取消XML UnSubscribeServiceReq包数据写入STRINGBUFFER中。
StringBuffer xmlStr=new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
xmlStr.append("<SOAP-ENV:Envelope");
xmlStr.append(" xmlns:SOAP-ENV=\" http://schemas.xmlsoap.org/soap/envelope/\"");
xmlStr.append(" xmlns:SOAP-ENC=\" http://schemas.xmlsoap.org/soap/encoding/\"");
xmlStr.append(" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\"");
xmlStr.append(" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema\"");
xmlStr.append("SOAP-ENV:encodingStyle=\" http://schemas.xmlsoap.org/soap/encoding/\"");
xmlStr.append(" xmlns=\" http://www.monternet.com/dsmp/schemas/\">");
xmlStr.append("<SOAP-ENV:Header>");
xmlStr.append("<TransactionID xmlns=\" http://www.monternet.com/dsmp/schemas/\" xsi:type=\"xsd:string\">0011"+dest_mobile+"</TransactionID>");
xmlStr.append("</SOAP-ENV:Header>");
xmlStr.append("<SOAP-ENV:Body>");
xmlStr.append("<UnSubscribeServiceReq xmlns=\" http://www.monternet.com/dsmp/schemas/\">");
xmlStr.append("<Version>1.5.0</Version>");
xmlStr.append("<MsgType>UnSubscribeServiceReq</MsgType>");
xmlStr.append("<Send_Address>");
xmlStr.append("<DeviceType>400</DeviceType>");
xmlStr.append("<DeviceID>"+sp_id+"</DeviceID>");
xmlStr.append("</Send_Address>");
xmlStr.append("<Dest_Address>");
xmlStr.append("<DeviceType>0</DeviceType>");
xmlStr.append("<DeviceID>0011</DeviceID>");
xmlStr.append("</Dest_Address>");
xmlStr.append("<FeeUser_ID>");
xmlStr.append("<UserIDType>1</UserIDType>");
xmlStr.append("<MSISDN>"+fee_mobile+"</MSISDN>");
xmlStr.append("<PseudoCode />");
xmlStr.append("</FeeUser_ID>");
xmlStr.append("<DestUser_ID>");
xmlStr.append("<UserIDType>1</UserIDType>");
xmlStr.append("<MSISDN>"+dest_mobile+"</MSISDN>");
xmlStr.append("<PseudoCode />");
xmlStr.append("</DestUser_ID>");
xmlStr.append("<Service_ID>");
xmlStr.append("<ServiceIDType>1</ServiceIDType>");
xmlStr.append("<SPID>"+sp_id+"</SPID>");
xmlStr.append("<SPServiceID>"+service+"</SPServiceID>");
xmlStr.append("<AccessNo />");
xmlStr.append("<FeatureStr />");
xmlStr.append("</Service_ID>");
xmlStr.append("</UnSubscribeServiceReq>");
xmlStr.append("</SOAP-ENV:Body>");
xmlStr.append("</SOAP-ENV:Envelope>");
//向MISC输出数据
out.println(xmlStr.toString());
//把输出数据保存到BF里,
bf.append("start");
bf.append(xmlStr.toString());
bf.append("end");
out.close();
//读取连接返回的数据。UnSubscribeServiceResp?SyncOrderRelationReq?SyncOrderRelationResp?
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
bf.append("rstart");
bf.append(line);
bf.append("rend");
}
in.close();
}
catch (MalformedURLException e)
{
sReturn="fail";
bf.append("wap Connect SP Error1:"+e.toString());
}
catch (IOException e)
{
sReturn="fail";
bf.append("wap Connect SP Error2:"+e.toString());
}
return sReturn;
}
%>
<%
String phoneno=getString(request.getParameter("phoneno"));
int app=getInt(request.getParameter("app"));
if(phoneno==null)phoneno="";
String ServiceID="";
if(app==2){
ServiceID="-OTYX";
}else if(app==1){
ServiceID="-OLBY";
}else if(app==3){
ServiceID="-OTYX";
}else if(app==6){
ServiceID="-OTYX";
}
String res=null;
String command=getString(request.getParameter("command"));
if(command!=null&&command.equals("send")&&phoneno!=null&&phoneno.length()>0){
String TransactionID=System.currentTimeMillis()+"";
String send_DeviceID="10666666";
String FeeUser_ID=phoneno;
String DestUser_ID=phoneno;
String SPServiceID=ServiceID;
String sp_code="456789";
TransactionID=sp_code+TransactionID.substring(sp_code.length()-(15-TransactionID.length()),TransactionID.length());
StringBuffer sb=new StringBuffer("");
String restr=SendReq(TransactionID,sp_code,DestUser_ID,FeeUser_ID,SPServiceID,send_DeviceID,send_DeviceID,sb);
res=restr;
//out.println("res:"+restr+" full:"+sb.toString());//可以读取,发送UnSubscribeServiceReq数据后,MISC返回的数据,
}
Collection apps=null;
if(phoneno.length()>0){
apps=BizUtil.list("select * from UserReg u,accuser a where u.id=a.id and a.phonenum='"+phoneno+"'");
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" _fcksavedurl=""style.css"" rel="stylesheet" type="text/css">
<title>Untitled Document</title>
</head>
<script language="JavaScript" type="text/JavaScript">
<!--
function send(id) { //v3.0
formI.command.value="send";
formI.app.value=id;
formI.submit();
}
//-->
</script>
<body>
<tabIe width="100%">
<tr>
<td ><table width="100%" >
<form name="form1" method="post" action="cancel.jsp">
<tr>
<td colspan="5" bgcolor="#FFFFCC">
<p>o?? <input type="text" name="phoneno" value="<%=phoneno%>">
<input type="submit" name="Submit2" value="2?">
<input name="command" type="hidden" id="command">
<input name="app" type="hidden" id="app">
</td>
</tr>
<%if(apps!=null&&apps.size()>0){%>
<tr>
<td height="22" bgcolor="#00CCCC" ><strong>
???3?/strong></td>
<td bgcolor="#00CCCC" ><strong>????strong></td>
<td bgcolor="#00CCCC" ><strong>?2?¨·</strong></td>
<td bgcolor="#00CCCC" ><strong>????¨·</strong></td>
<td bgcolor="#00CCCC" ><strong>??</strong></td>
</tr>
<%for (Iterator i=apps.iterator();i.hasNext();) {
HashMap r=(HashMap)i.next();
int proid=getInt(r.get("proid"));
String name="";
String code="";
int flag=getInt(r.get("flag"));
if(proid==1){
name="8¨©???;
code="-LBY";
}else if(proid==2){
name="???¡?
code="-jYX";
}else if(proid==3){
name="???¦?¢;
code="-lYX";
}else if(proid==6){
name="??¡?";
code="-llYX";
}
int prevnum=getInt(r.get("prevnum"));
String registertime=getString(r.get("regtime"));
String unregtime=getString(r.get("unregtime"));
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" _fcksavedurl=""style.css"" rel="stylesheet" type="text/css">
<title>Untitled Document</title>
</head>
<script language="JavaScript" type="text/JavaScript">
<!--
function send(id) { //v3.0
formI.command.value="send";
formI.app.value=id;
formI.submit();
}
//-->
</script>
<body>
<tabIe width="100%">
<tr>
<td ><table width="100%" >
<form name="form1" method="post" action="cancel.jsp">
<tr>
<td colspan="5" bgcolor="#FFFFCC">
<p>o?? <input type="text" name="phoneno" value="<%=phoneno%>">
<input type="submit" name="Submit2" value="2?">
<input name="command" type="hidden" id="command">
<input name="app" type="hidden" id="app">
</td>
</tr>
<%if(apps!=null&&apps.size()>0){%>
<tr>
<td height="22" bgcolor="#00CCCC" ><strong>
???3?/strong></td>
<td bgcolor="#00CCCC" ><strong>????strong></td>
<td bgcolor="#00CCCC" ><strong>?2?¨·</strong></td>
<td bgcolor="#00CCCC" ><strong>????¨·</strong></td>
<td bgcolor="#00CCCC" ><strong>??</strong></td>
</tr>
<%for (Iterator i=apps.iterator();i.hasNext();) {
HashMap r=(HashMap)i.next();
int proid=getInt(r.get("proid"));
String name="";
String code="";
int flag=getInt(r.get("flag"));
if(proid==1){
name="8¨©???;
code="-LBY";
}else if(proid==2){
name="???¡?
code="-jYX";
}else if(proid==3){
name="???¦?¢;
code="-lYX";
}else if(proid==6){
name="??¡?";
code="-llYX";
}
int prevnum=getInt(r.get("prevnum"));
String registertime=getString(r.get("regtime"));
String unregtime=getString(r.get("unregtime"));
%>
<tr>
<td >
<% = name %>
</td>
<td ><% = code %></td>
<td ><% = regtime; %></td>
<td ><% = unregtime %></td>
<td ><% =(flag=I?"<a href='#' οnclick='send("+proid+");'>?¡§??</a>":"????") %></td>
</tr>
<%}%>
<%}%>
</form>
</tabIe></td>
</tr>
</tabIe>
</body>
</html>
<td >
<% = name %>
</td>
<td ><% = code %></td>
<td ><% = regtime; %></td>
<td ><% = unregtime %></td>
<td ><% =(flag=I?"<a href='#' οnclick='send("+proid+");'>?¡§??</a>":"????") %></td>
</tr>
<%}%>
<%}%>
</form>
</tabIe></td>
</tr>
</tabIe>
</body>
</html>
作者Blog:
http://blog.csdn.net/cutemouse/