Java如何调用WebService?为了方便大家,特意整理如下文章,下面一起来和小编看看吧!
package biz;
import ;
import Format;
import ;
import ice;
import e;
import ger;
import meterMode;
public class TempService {
public static void main(String[] args) {
try {
String endpoint = "
// 创建一个服务(service)调用(call)
Service service = new Service();
Call call = (Call)teCall();// 通过service创建call对象
// 设置service所在URL
argetEndpointAddress(new (endpoint));
perationName(new QName("","getMobileCodeInfo"));
//Add 是net 那边的方法 "" 这个也要注意Namespace 的.地址,不带也会报错
arameter(new QName("","mobileCode"),_STRING, );
arameter(new QName("","userID"),_STRING, );
// 这就是我搞了一天的原因所在,"test" 这个就是传参数的变量,也就是NET方面的参数,一定不要带错了
// 我当初不知道 ,以为这个参数是自己随便写的,结果总是报NULL,真是气死人了
seSOAPAction(true);
eturnType(_STRING); //返回参数的类型
OAPActionURI(""); //这个也要注意 就是要加上要调用的方法Add,不然也会报错
// Object 数组封装了参数,参数为"This is Test!",调用processService(String arg)
String ret = (String)ke(new Object[]{"13473211647",""});
tln("--------"+ret);
}
catch (Exception e)
{
tln(ring());
}
}
}