package com.jettech.webservice;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis2.AxisFault;
public class SendMessageServer {
/**
* 发送报文到平台
* @param requestXml
* @throws Exception
*/
public String sendMessageRPC(String requestXml) throws Exception{
String returnStr ="";
//请求IP地址
// String baseUrl = SysConfig.getProperty("ELECTRICINVOICEPLAT_URL");
String baseUrl = "//http://111.202.226.74:8080/LXKP_TB/services/WKWebService";
try {
//以下都是套路
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(baseUrl);
call.setOperationName("doService");//WSDL里面描述的接口名称
call.addParameter("requestXml", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型
QName opAddEntry = new QName("http://impl.service.tax.inspur",
"doService");
call.setOperationName(opAddEntry);
call.setUseSOAPAction(true);
call.setTimeout(1*60*1000);
returnStr = (String)call.invoke(new Object[]{requestXml});
} catch (AxisFault e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
return returnStr;
}
}
所需jar包在这里:https://download.youkuaiyun.com/download/yimba/10685641