webservice通用客户端代码

package test;

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;

public class TestWS2 {

public static void main(String[] args) {

try {

// Web Service路径

String endpoint = “http://10.1.3.142:8001/ats/GetUserFund”;

//String endpoint = “http://10.1.3.113/ls/services/ATSTransWSService”;

OperationDesc oper = new OperationDesc();

// getExtendSystemXmlData ->Web Service供调用的方法

oper.setName(“getExtendSystemXmlData”);

ParameterDesc param = new ParameterDesc(new javax.xml.namespace.QName(“”, “arg0”), ParameterDesc.IN,

new javax.xml.namespace.QName(“http://www.w3.org/2001/XMLSchema”, “string”), java.lang.String.class, false, false);

oper.addParameter(param);

oper.setReturnType(new javax.xml.namespace.QName( “http://www.w3.org/2001/XMLSchema”, “string”));

oper.setReturnClass(java.lang.String.class);

oper.setReturnQName(new javax.xml.namespace.QName(“”, “arg0”));

oper.setStyle(org.apache.axis.constants.Style.RPC);

oper.setUse(org.apache.axis.constants.Use.ENCODED);

Service service = new Service();

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

call.setTargetEndpointAddress(new java.net.URL(endpoint));

call.setUseSOAPAction(true);

call.setSOAPActionURI(“”);

call.setOperation(oper);

call.setOperationName(new QName(“http://impl.getUseFund.webservice.ats.fund.hundsun.com/”,”getExtendSystemXmlData”));

//文档规范的请求XML;

String xmlStr = “<?xml version=\”1.0\” encoding=\”UTF-8\”?>”

+ “<PACKET type=\”REQUEST\” version=\”1.0\”>”

+ ” <HEAD>”

+ ” <REQUEST_TYPE>09</REQUEST_TYPE>”

+ ” <SYSTYPE>101</SYSTYPE>”

+ ” </HEAD>”

+ ” <BODY>”

+ ” <DETAILITEM>”

+ ” <RECORDSOURCE_BATNO>2590</RECORDSOURCE_BATNO>”

+ ” <ORIGIN_NOTE>5138</ORIGIN_NOTE>”

+ ” </DETAILITEM>”

+ ” </BODY>”

+ “</PACKET>”;

 

// res->返回文档标准的回执XML,xmlStr->文档规范的请求Xml

String res = (String) call.invoke(new Object[] { xmlStr });

System.out.println(res);

} catch (Exception e) {

e.printStackTrace();

}
}
}

 

转载于:https://www.cnblogs.com/gaopengpy/p/6849541.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值