如何调用别人提供的webservice接口
1个回答
2017-05-05 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
传递对方的url,方法名,参数信息。不需要引用对方的代码。
测试跑通。
========
package com.flyfox.client;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class HelloWorldServiceClient {
public static void main(String[] args) throws Exception {
Service service = new Service();
try {
Call call = (Call) service.createCall();
call
.setTargetEndpointAddress("http://172.16.192.73:8080/np-fy-ajpc/services/ajpcTjpcService?wsdl");
call.setOperationName("tjpcProcess");
call.addParameter(
"xmlParam", //设置要传递的参数
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
// call.setTimeout(5000);
call.setUseSOAPAction(true);
call
.setSOAPActionURI("http://support.ajpc.fy.np.thunisoft.com/tjpcProcess");
String result = (String) call
.invoke(new Object[] { "<QueryParam NAjlb='1' NSpcx='2' CBhAj='6A10F8068A8015310BA2887DEFFC8960' NSyfy='1'></QueryParam>" });
System.out.println(result);
} catch (Exception ex) {
测试跑通。
========
package com.flyfox.client;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class HelloWorldServiceClient {
public static void main(String[] args) throws Exception {
Service service = new Service();
try {
Call call = (Call) service.createCall();
call
.setTargetEndpointAddress("http://172.16.192.73:8080/np-fy-ajpc/services/ajpcTjpcService?wsdl");
call.setOperationName("tjpcProcess");
call.addParameter(
"xmlParam", //设置要传递的参数
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
// call.setTimeout(5000);
call.setUseSOAPAction(true);
call
.setSOAPActionURI("http://support.ajpc.fy.np.thunisoft.com/tjpcProcess");
String result = (String) call
.invoke(new Object[] { "<QueryParam NAjlb='1' NSpcx='2' CBhAj='6A10F8068A8015310BA2887DEFFC8960' NSyfy='1'></QueryParam>" });
System.out.println(result);
} catch (Exception ex) {
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询