67,512
社区成员
发帖
与我相关
我的任务
分享
package test;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class TestWebService {
public static void main(String[] args) throws Exception {
//String endpoint = "http://localhost:8086/testwebservice/services/TestWebService";
String endpoint = "http://testweb.dev.php/testWebService/testWebService.php";//该段就是上面刚将的地址
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("hello");
String param = new String("中文".getBytes(),"ISO-8859-1");//如果没有加这段,中文参数将会乱码
String s = (String) call.invoke(new Object[] {param});
s = new String(s.getBytes("ISO-8859-1"),"GBK");//如果没有转换编码,中文也会乱码
System.out.println(s);
}
}