java原生调用webservice接口,原生java调用webservice的方法,不用生成客户端代码

package com.kingdee.eas.cp.trd.webservice.taskinter;

package com.kingdee.eas.cp.trd.webservice.taskinter;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.message.SOAPHeaderElement;

import com.kingdee.bos.Context;

import com.kingdee.bos.webservice.login.WSContext;

public class TaskInterUtil

{

public static String getUserCreditFilesData(Context ctx,String userId)

{

try {

Service s = new Service();

Call call = (Call) s.createCall();

call.setOperationName("login");

call.setTargetEndpointAddress("http://10.0.55.5:6888/ormrpc/services/EASLogin?wsdl");

call.setReturnType(new QName("urn:client", "WSContext"));

call.setReturnClass(WSContext.class);

call.setReturnQName(new QName("", "loginReturn"));

call.setMaintainSession(true);

String headerValue ;

String headerNamePlace = "http://login.webservice.bos.kingdee.com";

//                  WSContext result = ((WSContext) call.invoke(new Object[] { "sysWS","sysWS","eas","TESTSSC8", "l2",Integer.valueOf("2"),"BaseDB"}));

WSContext result = ((WSContext) call.invoke(new Object[] { "sysWS","sysWS","eas","TESTSSC8", "l2",2}));

String sessionid = result.getSessionId();

System.out.println(sessionid);

call.clearOperation();

//call = (Call)  new Service().createCall();,不能创建一个新的call

call.setOperationName("getUserCreditFilesData");

//          call.setOperationName("createJob");

call.setMaintainSession(true);

call.setTargetEndpointAddress("http://10.0.55.5:6888/ormrpc/services/WSTaskInterFacede?wsdl");

call.addHeader(new SOAPHeaderElement("http://login.webservice.bos.kingdee.com","SessionId", sessionid));

//          boolean b =(Boolean) call.invoke(new Object[] { "111"});

Object b = call.invoke(new Object[] { "bLXZIU9+SiuLKkJor2m9NhO33n8=", "", "", "", "", "", "", "10.0.55.5"});

System.out.println("ssss");

} catch (ServiceException e) {

e.printStackTrace();

} catch (RemoteException e) {

e.printStackTrace();    }

return "";

}

}

import java.rmi.RemoteException;

import javax.xml.namespace.QName;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.message.SOAPHeaderElement;

import com.kingdee.bos.Context;

import com.kingdee.bos.webservice.login.WSContext;

public class TaskInterUtil

{

public static String getUserCreditFilesData(Context ctx,String userId)

{

try {

Service s = new Service();

Call call = (Call) s.createCall();

call.setOperationName("login");

call.setTargetEndpointAddress("http://10.0.55.5:6888/ormrpc/services/EASLogin?wsdl");

call.setReturnType(new QName("urn:client", "WSContext"));

call.setReturnClass(WSContext.class);

call.setReturnQName(new QName("", "loginReturn"));

call.setMaintainSession(true);

String headerValue ;

String headerNamePlace = "http://login.webservice.bos.kingdee.com";

// WSContext result = ((WSContext) call.invoke(new Object[] { "sysWS","sysWS","eas","TESTSSC8", "l2",Integer.valueOf("2"),"BaseDB"}));

WSContext result = ((WSContext) call.invoke(new Object[] { "sysWS","sysWS","eas","TESTSSC8", "l2",2}));

String sessionid = result.getSessionId();

System.out.println(sessionid);

call.clearOperation();

//call = (Call) new Service().createCall();,不能创建一个新的call

call.setOperationName("getUserCreditFilesData");

//call.setOperationName("createJob");

call.setMaintainSession(true);

call.setTargetEndpointAddress("http://10.0.55.5:6888/ormrpc/services/WSTaskInterFacede?wsdl");

call.addHeader(new SOAPHeaderElement("http://login.webservice.bos.kingdee.com","SessionId", sessionid));

//boolean b =(Boolean) call.invoke(new Object[] { "111"});

Object b = call.invoke(new Object[] { "bLXZIU9+SiuLKkJor2m9NhO33n8=", "", "", "", "", "", "", "10.0.55.5"});

System.out.println("ssss");

} catch (ServiceException e) {

e.printStackTrace();

} catch (RemoteException e) {

e.printStackTrace(); }

return "";

}

}

2.

String result = null;

try {

Properties p = new Properties();

String propertiesUrl = "com/kingdee/eas/fi/gl/client/propertie.properties";

InputStream ins = VoucherEditUICTEx.class.getClassLoader().getResourceAsStream(propertiesUrl);

p.load(ins);

String showImageUrl = p.getProperty("showImageUrl");

//直接引用远程的wsdl文件

//以下都是套路

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(showImageUrl);

call.setOperationName("imageOutSrv");//WSDL里面描述的接口名称

call.addParameter("inJsonString", org.apache.axis.encoding.XMLType.XSD_DATE, javax.xml.rpc.ParameterMode.IN);//接口的参数

call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型

//          companyNumber = "CWGX001";

//          voucherPeriod = "2015-08";

//          voucherTitle = "记字集团";

//          voucherCode = "WK06-0001";

String AppID = "EAS701";

String Provider = "IMSSC";

StringBuffer param = new StringBuffer();

param.append("  {                   ");

param.append("      \"Message\":{                   ");

param.append("          \"Header\":{                    ");

param.append("              \"AppID\":\""+AppID+"\",                    ");

param.append("              \"Provider\":\""+Provider+"\"                   ");

param.append("          },                  ");

param.append("          \"Body\":{                  ");

param.append("              \"ACTION_METHOD\":\"showImage\",                    ");

param.append("              \"PARAMS\":{                    ");

param.append("                  \"COMPANY_CODE\":\""+companyNumber+"\",                 ");

param.append("                  \"VOUCHER_PERIOD\":\""+voucherPeriod+"\",                   ");

param.append("                  \"VOUCHER_TITLE\":\""+voucherTitle+"\",                 ");

param.append("                  \"VOUCHER_CODE\":\""+voucherCode+"\"                    ");

param.append("              }                   ");

param.append("          }                   ");

param.append("      }                   ");

param.append("  }                   ");

result = (String)call.invoke(new Object[]{param.toString()});

//给方法传递参数,并且调用方法

System.out.println("result is "+result);

} catch (Exception e1) {

e1.printStackTrace();

MsgBox.showInfo("EAS核算凭证影像调阅接口调用失败");

SysUtil.abort();

}

String result = null;

try {

Properties p = new Properties();

String propertiesUrl = "com/kingdee/eas/fi/gl/client/propertie.properties";

InputStream ins = VoucherEditUICTEx.class.getClassLoader().getResourceAsStream(propertiesUrl);

p.load(ins);

String showImageUrl = p.getProperty("showImageUrl");

//直接引用远程的wsdl文件

//以下都是套路

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(showImageUrl);

call.setOperationName("imageOutSrv");//WSDL里面描述的接口名称

call.addParameter("inJsonString", org.apache.axis.encoding.XMLType.XSD_DATE, javax.xml.rpc.ParameterMode.IN);//接口的参数

call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型

//companyNumber = "CWGX001";

//voucherPeriod = "2015-08";

//voucherTitle = "记字集团";

//voucherCode = "WK06-0001";

String AppID = "EAS701";

String Provider = "IMSSC";

StringBuffer param = new StringBuffer();

param.append("{");

param.append(" \"Message\":{");

param.append(" \"Header\":{");

param.append(" \"AppID\":\""+AppID+"\",");

param.append(" \"Provider\":\""+Provider+"\"");

param.append(" },");

param.append(" \"Body\":{");

param.append(" \"ACTION_METHOD\":\"showImage\",");

param.append(" \"PARAMS\":{");

param.append(" \"COMPANY_CODE\":\""+companyNumber+"\",");

param.append(" \"VOUCHER_PERIOD\":\""+voucherPeriod+"\",");

param.append(" \"VOUCHER_TITLE\":\""+voucherTitle+"\",");

param.append(" \"VOUCHER_CODE\":\""+voucherCode+"\"");

param.append(" }");

param.append(" }");

param.append(" }");

param.append("}");

result = (String)call.invoke(new Object[]{param.toString()});

//给方法传递参数,并且调用方法

System.out.println("result is "+result);

} catch (Exception e1) {

e1.printStackTrace();

MsgBox.showInfo("EAS核算凭证影像调阅接口调用失败");

SysUtil.abort();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值