mkey3g应用开发

                   Mkey3g开发理解

 

1.      首先在数字天堂官网注册,下载激活码!!

2.      安装mkey3g所需要的Tomcat,MySql并将mkey3gdb数据库导入到MySql,以供mkey3g配置文件能打开,在打开的mkey3g配置页面中配置登陆方式和透传地址,只需要配置如图的两项即可

3.      装好手机应用客户端

4.      mkey3g文件夹中的app文件夹中的global.xml配置登陆的xml文件

5.      登陆先省略

6.      配置home.xml以显示手机客户端的应用程序

如图:

7.开发其中的应用程序(以理赔查询为例)

      

       首先需要产生这样一个页面则需要写一个xml文件(需用数字天堂开发的识别格式)

       如:

              <?xml version="1.0" encoding="UTF-8"?>

<dhmi type="response">

    <msc type="form" name="initform" action="?action=query@mdpdhmi&amp;interface=lipei_chaxun">

       <head>

           <script type="text/javascript">

                <![CDATA[

                   function submit(){

                       document.initform.submit();

                   }

                ]]>

        </script>

       </head>

      

       <body>

            <span dock="top" align="center" width="100%">

                <img src="img/allMaterial/top.png"/>

            </span>

            <span width="100%" height="10"/>

            <span>

              <img src="res:allow_r.png"/>

              <font color="#ff0000">理赔查询</font>

            </span>

           

            <span width="100%">

              <span width="30%">客户姓名:</span><input name="CUSTOMERNAME" type="text" value=""/>

              <span width="30%">身份证号:</span><input name="ORGANIZECODE" type="text" value=""></input>

            </span>

            <span width="100%" align="left">

              <span width="30%" align="center"><img src="img/query_btn.png" href="script:submit()"></img></span>

           </span>

           <br/>

       </body>

    </msc>

</dhmi>

需以dhmi为根目录,msc则类似html标签,注意其javascript写法,在这里不叫javascript而叫DHS,action的配置需以?action= query@mdpdhmi&amp;这是规定

 

7.      interface=lipei_chaxun中的lipei_chaxun则是配置在dhmi_access_config.properties属性文件中在启动时读取并初始化其中的数据。

8.      将写好理赔查询登陆页面发送到服务器,而服务器并不认识,则需要将此xml转为服务器认识的xml,先写一个转换xml格式的xsl定好节点格式.

:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <xsl:template match="/">

       <CarQuoteCustomerInfoQueReq>

           <ReqHead>

              <UUID>待确定</UUID>

              <REQUESTTYPE>Q06</REQUESTTYPE>

              <FLOWINTIME>时间要在java代码中填写</FLOWINTIME>

           </ReqHead>

           <CUSTOMERCODE/>

           <CUSTOMERCNAME>

              <xsl:value-of select="//CUSTOMERNAME/text()"/>

           </CUSTOMERCNAME>

           <ORGANIZECODE>

              <xsl:value-of select="//ORGANIZECODE/text()"/>

           </ORGANIZECODE>

           <POLICYNO/>

       </CarQuoteCustomerInfoQueReq>

    </xsl:template>

</xsl:stylesheet>

9.      在后台服务器写代码将请求过来的xml文件转换成可以识别的xml文件在取其中所需节点的值,再做业务编码!!

:

private static  Properties config = SysConfig.getConfig("connector_config.properties");

    private Logger logger = Logger.getLogger(PaymentInfoAccess.class);

    @SuppressWarnings("unchecked")

    @Override

    public Document invoke(Document reqDoc) {

       logger.debug(reqDoc.asXML());

       //

       Document rspDoc = null;

       try{

           //客户信息查询页面结果返回

           reqDoc = XMLHelper.dom4jXsltTransferXml(reqDoc, "payment/DHMI_lipei_MDSP.xsl");

           Element rootEle = reqDoc.getRootElement();

           Element custName = (Element)rootEle.selectSingleNode("/CarQuoteCustomerInfoQueReq/CUSTOMERCNAME");

           Element custNo = (Element)rootEle.selectSingleNode("/CarQuoteCustomerInfoQueReq/ORGANIZECODE");

           if(custName.getText().equals("") && custNo.getText().equals("")){

              String msg = "客户名称和身份证号不能同时为空!";

              rspDoc = transeferErrorMsgToXML(msg);

           }else{

//            ServletConnector servletConnector = new ServletConnector("CarQuoteCustomerInfoQueReq");

//            String rspString  = (String)servletConnector.callService(reqDoc.asXML());

//            String rspString = UtilHelp.rspString;

              rspDoc = XMLHelper.parseXML(UtilHelp.rspString);

              List<Element> customerInfoList = rspDoc.selectNodes("/body/CarQuoteInfoQueRsp/CarQuoteCustomerInfoList/CarQuoteCustomerInfo");

              if(customerInfoList.size() == 1){

                  //如果客户名称和身份证号都输入则只有一条记录,取出其中的客户代码

                  Element custInfoEle = (Element)customerInfoList.get(0);

                  String customerCode = "";

                  customerCode = (custInfoEle.selectSingleNode("CUSTOMERCODE")).getText();

                  rspDoc = new PaymentInfoListAccess(customerCode).invoke(rspDoc);

              }else{

                  //如果只输入用户名则可能有多条客户信息(显示多条客户信息的客户代码和名称)

                  //

                  List<String[]> custList = new ArrayList<String[]>();

                  for(Element custEle : customerInfoList){

                     String[] custArray = new String[]{custEle.selectSingleNode("CUSTOMERCNAME").getText(),

                            custEle.selectSingleNode("CUSTOMERCODE").getText()};

                     custList.add(custArray);

                  }

                  //将此List数据putxsl

                  rspDoc = transferCustInfoToXML(custList);

              }

           }

       }catch(Exception e){

           e.printStackTrace();

       }

       return rspDoc;

    }

    public CustomerWebServicesPortType getCustomerWebServicesConnector(String url) {

        CustomerWebServices service = new CustomerWebServicesLocator();

        CustomerWebServicesPortType connector = null;

        try {

           

            connector = service.getCustomerWebServicesHttpPort(new URL(config.getProperty(url)));

        } catch (MalformedURLException e) {

            e.printStackTrace();

        } catch (ServiceException e) {

            e.printStackTrace();

        }

        

        return connector;

    }

    /**

     * 将客户信息数据保存到xml

     * @param list

     * @return Document

     */

    public Document transferCustInfoToXML(List<String[]> list){

       Document custInfoDoc = null;

       custInfoDoc = DocumentHelper.createDocument();

       Element rootEle = custInfoDoc.addElement("CustInfo");

       for(String[] custArr : list){

           Element custData = rootEle.addElement("CustData");

           custData.addElement("CustomerName").setText(custArr[0]);

           custData.addElement("CustomerCode").setText(custArr[1]);

       }

       System.out.println(custInfoDoc.asXML());

       custInfoDoc = XMLHelper.dom4jXsltTransferXml(custInfoDoc, "payment/customer_info.xsl");

       System.out.println(custInfoDoc.asXML());

       return custInfoDoc;

    }

   

    public Document transeferErrorMsgToXML(String errormsg){

       Document rspDoc = null;

       rspDoc = DocumentHelper.createDocument();

       Element ele = rspDoc.addElement("body");

       ele.addElement("error").setText(errormsg);

       rspDoc = XMLHelper.dom4jXsltTransferXml(rspDoc, "payment/lipei_cx_warning.xsl");

       return rspDoc;

    }

10.   相关代码示例:

 private Logger log = Logger.getLogger(PaymentInfoListAccess.class);

    private static  Properties config = SysConfig.getConfig("connector_config.properties");

    private String customer_code = "";

    public PaymentInfoListAccess(){}

    public PaymentInfoListAccess(String customerCode){

       customer_code = customerCode;

    }

    @Override

    public Document invoke(Document reqDoc) {

       log.debug(reqDoc.asXML());

       Document rspDoc = null;

       try{

           //一个客户可能有多个保单

//         CustomerWebServicesPortType client = getCustomerWebServicesConnector("PaymentInfo");

//         PrpLRegistCustCarVo[] vo = client.findPrpLcustRegistCarByCustomerCodes(customer_code);

           UtilHelp.init();

           List<PrpLRegistCustCarVo> custList = transferArrayToList(UtilHelp.vo);

           if(customer_code.equals("")){

               customer_code=reqDoc.selectSingleNode("//dhmi/data/customerCode").getText();

           }

           rspDoc = transferPaymentInfoToXML(custList, customer_code);

           rspDoc = XMLHelper.dom4jXsltTransferXml(rspDoc, "payment/lipei_cx_list.xsl");

       }catch(Exception e){

           e.printStackTrace();

       }

       return rspDoc;

    }

    public CustomerWebServicesPortType getCustomerWebServicesConnector(String url) {

        CustomerWebServices service = new CustomerWebServicesLocator();

        CustomerWebServicesPortType connector = null;

        try {

           

            connector = service.getCustomerWebServicesHttpPort(new URL(config.getProperty(url)));

        } catch (MalformedURLException e) {

            e.printStackTrace();

        } catch (ServiceException e) {

            e.printStackTrace();

        }

       

        return connector;

    }

    /**

     * VO[]转换为List

     * @param vo

     * @return List<PrpLRegistCustCarVo>

     */

    private List<PrpLRegistCustCarVo> transferArrayToList(PrpLRegistCustCarVo[] vo){

       List<PrpLRegistCustCarVo> custList = new ArrayList<PrpLRegistCustCarVo>();

       for(int i = 0 ; i < vo.length ; i++){

           custList.add(vo[i]);

       }

       return custList;

    }

    /**

     * 将赔付信息封装为XML

     * @param list

     * @param customerName

     * @param customerCode

     * @return Document

     */

    public Document transferPaymentInfoToXML(List<PrpLRegistCustCarVo> list,String customerCode){

       Document paymentInfoDoc = null;

       paymentInfoDoc = DocumentHelper.createDocument();

       Element rootElement = paymentInfoDoc.addElement("body");

       for(PrpLRegistCustCarVo vo : list){

           Element payment = rootElement.addElement("payment");

           //客户代码

           payment.addElement("CUSTOMERCODE").setText(customerCode);

           //状态

           payment.addElement("STATUS").setText(vo.getRegistState());

           //报案号

           payment.addElement("REGISTNO").setText(vo.getRegistNo());

       }

       return paymentInfoDoc;

    }

通过这些代码则可以出来一个列表页面:

      

 

11.   点击其中的某项的页面

12.   其实这些都是通过一系列的xml和对xml转换的xsl来做的

13.   比如要将10中的列表页面显示出来则需要配置一个显示列表的xsl

:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <xsl:template match="/">

       <dhmi type="response">

           <msc type="form" showfoot="true">

              <head>

                  <title>手机远程销售系统</title>

              </head>

              <body background="img/allMaterial/bg.png">

                  <span  dock="top" align="center" width="100%">

                       <img src="img/allMaterial/top.png"/>

                   </span>

                   <span width="100%" height="10"/>

                  <listbox id="firstCust" visible="true">

                     <xsl:apply-templates mode="all" select="/body/payment"></xsl:apply-templates>

                  </listbox>

              </body>

           </msc>

       </dhmi>

    </xsl:template>

    <xsl:template match="/body/payment" mode="all">

       <xsl:variable name="customerCode" select="CUSTOMERCODE"/>

       <xsl:variable name="status" select="STATUS"/>

       <xsl:variable name="registNo" select="REGISTNO"/>

       <listitem target="_blank" icon="img/Notice/star.png" value="000" href="?action=query@mdpdhmi&amp;interface=lipei_list_item&amp;registNo={$registNo}&amp;customerCode={$customerCode}">

           <caption>

              报案号:<xsl:value-of select="$registNo"></xsl:value-of>(

                  <xsl:choose>

                     <xsl:when test="$status = 0">未决</xsl:when>

                     <xsl:otherwise>已决</xsl:otherwise>

                  </xsl:choose>

              )

           </caption>

           <sndcaption>

              客户代码:<xsl:value-of select="$customerCode"></xsl:value-of>

           </sndcaption>

           <digest>

              客户代码:<xsl:value-of select="$customerCode"></xsl:value-of>

           </digest>

       </listitem>

    </xsl:template>

</xsl:stylesheet>

再经过10的解析封装成一个xml格式的xml不需加<dhmi><msc>标签,因为此为返回到手机客户端的xml,在经过mkey3g中间件时通过下行模板会自动进行拼装.到手机客户端后则可以正常显示了

14.   流程演示;

 

 

 

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值