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

📄 syncorderrelationreqbean.java

📁 对于cmpp3.0 开发有一定的帮助,请大家下载下来进行研究.
💻 JAVA
字号:
package com.zhanghao.provision;

import javax.xml.soap.*;
import java.util.Iterator;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import com.zhanghao.common.util.Base64;


public class SyncOrderRelationReqBean{

  public String TransactionID;

  public String Version;

  public SchemaOfAddress Send_Address = new SchemaOfAddress();

  public SchemaOfAddress Dest_Address = new SchemaOfAddress();

  public SchemaOfUserID FeeUser_ID  = new SchemaOfUserID();

  public SchemaOfUserID DestUser_ID = new SchemaOfUserID();

  public String LinkID;

  public int ActionID;

  public int ActionReasonID;

  public String SPID;

  public String SPServiceID;

  public int AccessMode;

  public String FeatureStr; //=Base64(SPNumber + MsgContent)

  public String SPNumber;
  public String MsgContent;

  public SOAPMessage soapMessage;

  public SyncOrderRelationReqBean() {
  }

  public SyncOrderRelationReqBean(SOAPMessage soapMsg) throws Exception{
    parseSOAPMsg(soapMsg);
  }


  public void parseSOAPMsg(SOAPMessage soapMsg) throws Exception{

    this.soapMessage = soapMsg;

    try{
      Name name;
      Iterator child;
      SOAPElement soapEle;
      SOAPElement soapEleTemp;

      SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
      //该消息编号
      name = soapEnv.createName("TransactionID","","http://www.monternet.com/dsmp/schemas/");
      TransactionID = ((SOAPElement)soapEnv.getHeader().getChildElements(name).next()).getValue();

      //SyncOrderRelationReq消息Body
      name = soapEnv.createName("SyncOrderRelationReq","","http://www.monternet.com/dsmp/schemas/");
      child = soapEnv.getBody().getChildElements(name);
      soapEle = (SOAPElement)child.next();

      //该接口消息的版本号,本次所有的接口消息的版本都为“1.5.0”
      name = soapEnv.createName("Version","","http://www.monternet.com/dsmp/schemas/");
      Version = ((SOAPElement)soapEle.getChildElements(name).next()).getValue();

      //address_info_schema	发送方的地址
      name = soapEnv.createName("Send_Address","","http://www.monternet.com/dsmp/schemas/");
      soapEleTemp = (SOAPElement)soapEle.getChildElements(name).next();
      name = soapEnv.createName("DeviceType","","http://www.monternet.com/dsmp/schemas/");
      this.Send_Address.DeviceType = Integer.parseInt(((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue());
      name = soapEnv.createName("DeviceID","","http://www.monternet.com/dsmp/schemas/");
      this.Send_Address.DeviceID = ((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue();

      //address_info_schema	接收方的地址
      name = soapEnv.createName("Dest_Address","","http://www.monternet.com/dsmp/schemas/");
      soapEleTemp = (SOAPElement)soapEle.getChildElements(name).next();
      name = soapEnv.createName("DeviceType","","http://www.monternet.com/dsmp/schemas/");
      this.Dest_Address.DeviceType = Integer.parseInt(((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue());
      name = soapEnv.createName("DeviceID","","http://www.monternet.com/dsmp/schemas/");
      this.Dest_Address.DeviceID = ((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue();

      //user_id_schema	计费用户标识
      name = soapEnv.createName("FeeUser_ID","","http://www.monternet.com/dsmp/schemas/");
      soapEleTemp = (SOAPElement)soapEle.getChildElements(name).next();
      name = soapEnv.createName("UserIDType","","http://www.monternet.com/dsmp/schemas/");
      this.FeeUser_ID.UserIDType = Integer.parseInt(((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue());
      name = soapEnv.createName("MSISDN","","http://www.monternet.com/dsmp/schemas/");
      this.FeeUser_ID.MSISDN = ((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue();
      name = soapEnv.createName("PseudoCode","","http://www.monternet.com/dsmp/schemas/");
      this.FeeUser_ID.PseudoCode = ((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue();

      //user_id_schema	使用用户标识
      name = soapEnv.createName("DestUser_ID","","http://www.monternet.com/dsmp/schemas/");
      soapEleTemp = (SOAPElement)soapEle.getChildElements(name).next();
      name = soapEnv.createName("UserIDType","","http://www.monternet.com/dsmp/schemas/");
      this.DestUser_ID.UserIDType = Integer.parseInt(((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue());
      name = soapEnv.createName("MSISDN","","http://www.monternet.com/dsmp/schemas/");
      this.DestUser_ID.MSISDN = ((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue();
      name = soapEnv.createName("PseudoCode","","http://www.monternet.com/dsmp/schemas/");
      this.DestUser_ID.PseudoCode = ((SOAPElement)soapEleTemp.getChildElements(name).next()).getValue();

      //string	临时订购关系的事务ID
      name = soapEnv.createName("LinkID","","http://www.monternet.com/dsmp/schemas/");
      LinkID = ((SOAPElement)soapEle.getChildElements(name).next()).getValue();

      //服务状态管理动作代码,具体值如下:
      //1: 开通服务;
      //2: 停止服务;
      //3: 激活服务;
      //4: 暂停服务;
      name = soapEnv.createName("ActionID","","http://www.monternet.com/dsmp/schemas/");
      ActionID = Integer.parseInt(((SOAPElement)soapEle.getChildElements(name).next()).getValue());

      //产生服务状态管理动作原因的代码,具体值如下:
      /** 1:用户发起行为
          2:Admin&1860发起行为
          3:Boss停机
          4:Boss开机
          5:Boss过户
          6:Boss销户
          7:Boss改号
          8:扣费失败导致的服务取消
          9:其他
      **/
      name = soapEnv.createName("ActionReasonID","","http://www.monternet.com/dsmp/schemas/");
      ActionReasonID = Integer.parseInt(((SOAPElement)soapEle.getChildElements(name).next()).getValue());

      //string	SP的企业代码
      name = soapEnv.createName("SPID","","http://www.monternet.com/dsmp/schemas/");
      SPID = ((SOAPElement)soapEle.getChildElements(name).next()).getValue();

      //string	SP中该服务的服务代码
      name = soapEnv.createName("SPServiceID","","http://www.monternet.com/dsmp/schemas/");
      SPServiceID = ((SOAPElement)soapEle.getChildElements(name).next()).getValue();

      //服务的访问方式1:WEB2:WAP3:SMS
      name = soapEnv.createName("AccessMode","","http://www.monternet.com/dsmp/schemas/");
      AccessMode = Integer.parseInt(((SOAPElement)soapEle.getChildElements(name).next()).getValue());

      //服务订购参数(base64加密)
      name = soapEnv.createName("FeatureStr","","http://www.monternet.com/dsmp/schemas/");
      FeatureStr = ((SOAPElement)soapEle.getChildElements(name).next()).getValue()==null?
          "":((SOAPElement)soapEle.getChildElements(name).next()).getValue();
      System.out.println("FeatureStr = " + FeatureStr);
      if(!FeatureStr.equals("")){
         String temp = Base64.decodeBase64(FeatureStr);
         this.SPNumber = temp.substring(0,temp.indexOf(" ")).trim();
         this.MsgContent = temp.substring(temp.indexOf(" ")+1).trim();
      }



      System.out.println("SPNumber = " + SPNumber);
      System.out.println("MsgContent = " + MsgContent);
    }
    catch(Exception ex){
      ex.printStackTrace();
      throw new Exception("解析SOAP包错误:"+ex.getMessage());
    }
  }



  public int getMsgLength(){
    try{
      ByteArrayOutputStream byteArrayOutStream = new ByteArrayOutputStream();
      DataOutputStream dataOutStream = new DataOutputStream(byteArrayOutStream);

      this.soapMessage.writeTo(dataOutStream);
      return byteArrayOutStream.toByteArray().length;
    }
    catch(Exception ex){
      return 0;
    }
  }
}

⌨️ 快捷键说明

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