WebService篇

package com.esky.shop.util;

import javax.xml.rpc.ParameterMode;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.util.Iterator;

import org.apache.axis.encoding.XMLType;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class CheckDongZhi {

 private static Call selectCall = null;
 
 private static final CheckDongZhi oaconnection = new CheckDongZhi();
 //state webService链接
 //private static final String state =" CommonForChange.OA_URL;
 private static final String state = "
http://10.9.21.138:8088/Fol/services/folserviceForOtherSystem.seam?wsdl";

 private static final String endpoint = state;
 
 private CheckDongZhi() {
  try {
   Service service = new Service();
   selectCall = (Call) service.createCall();
   selectCall.setOperationName(new QName(state, "call"));//getBudgetNoService 调用webService方法
   selectCall.setTargetEndpointAddress(new java.net.URL(endpoint));
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
 
 public static CheckDongZhi getInstance() {
  return oaconnection;
 }
 
  /***
   *
   *方法描述:发送数据
   * @param users    需要发送的Json串(其中包括动值单号)
   * @param ret  返回的数据字符
   * @param path    
   * @param serviceName
   * @return
   */
 public String selectPending(String code){
  String ret = "";
  try {
  System.out.println("发送参数:"+code);
   
    Service service = new Service();
    selectCall = (Call) service.createCall();
    selectCall.setOperationName(new QName(state, "call"));
    selectCall.setTargetEndpointAddress(new java.net.URL(endpoint));
    
    ret = (String) selectCall.invoke(new Object[]{code});
    
   } catch (RemoteException e1) {
    e1.printStackTrace();
   } catch (ServiceException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  
  return ret;
 }
 //返回的内容是json{ applyid: 动支申请号 14位,: 动支报销余额,businessactivityname : 活动项,currencytype  :币种类型,budgetponum  :动支号 5开头 10位,budgetponum   :动支号 5开头 10位,applycompanycode :申请公司code,applycompanyname  :申请公司名称,status :是否完成,只有6代表完成 }
 public static void main(String[] args) {
   // System.out.println(CheckDongZhi.getInstance().selectPending("{'sys':'请求系统标识','Key':'平台提供密码标识','type':'3','request':{'no':'12040050225963',dept:'8370'}}")); 
  System.out.println(CheckDongZhi.getInstance().selectPending("{'sys':'请求系统标识','Key':'平台提供密码标识','type':'3','request':{'no':'11120050000810',dept:'1700'}}")); 
      
 }
 
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值