//调用Web Service,传入参数
String res = ( String ) call.invoke( new Object[](\
System.out.println(\
return res;
}
/**
* @param args
*/
public static void main(String[] args) {
try {
System.out.println(getResult());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} catch (SOAPException e) {
e.printStackTrace();
}
}
}
2、利用Eclipse自动生成WebService client代码就容易多了:(由于还不会发图片,就用语言描述
了,大家酬和看吧。。。)
首先,new project,选择other,在输入框中输入Web Service Client,选中搜索后的结果,点击
Next,在Service definition中输入 WebService的发布地址,点击Finish
这样,WebService Client代码已经生成好了。
接下来写一个Test类,在main函数中输入如下代码:
String endpoint = \服务器的WebService的地址\
YourWebServiceNameProxy umsp = new YourWebServiceNameProxy (endpoint);
try {
String resultStr = umsp.opMethod(\
System.out.println(resultStr);
} catch (Exception e) {
System.out.println(\异常\
e.printStackTrace();
} catch (RemoteException e) {
System.out.println(\异常\
e.printStackTrace(); }