如何调用别人提供的webservice接口

2024-12-19 02:36:22
推荐回答(1个)
回答1:

传递对方的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[] { "" });
System.out.println(result);
} catch (Exception ex) {