webservice通⽤客户端代码
package test;
l.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路径如何生成webservice客户端
String endpoint = “10.1.3.142:8001/ats/GetUserFund”;
//String endpoint = “10.1.3.113/ls/services/ATSTransWSService”;
OperationDesc oper = new OperationDesc();
// getExtendSystemXmlData ->Web Service供调⽤的⽅法
oper.setName(“getExtendSystemXmlData”);
ParameterDesc param = new ParameterDesc(l.namespace.QName(“”, “arg0”), ParameterDesc.IN,
l.namespace.QName(“/2001/XMLSchema”, “string”), java.lang.String.class, false, false); oper.addParameter(param);
oper.setReturnType(l.namespace.QName( “/2001/XMLSchema”, “string”));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(l.namespace.QName(“”, “arg0”));
oper.setStyle(org.stants.Style.RPC);
oper.setUse(org.stants.Use.ENCODED);
Service service = new Service();
Call call = (Call) ateCall();
call.setTargetEndpointAddress(new java.URL(endpoint));
call.setUseSOAPAction(true);
call.setSOAPActionURI(“”);
call.setOperation(oper);
call.setOperationName(new QName(“UseFund.webservice.ats.fund.hundsun/”,”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();
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论