参考片段(一)
public String getService(String methodName, String xml) {
try {
String endpointURL = "http://219.136.207.188/mobtongbao/services/UmpsToGmccWS";
AxisProperties.setProperty("http.proxyHost", "10.243.184.17"); //代理IP
AxisProperties.setProperty("http.proxyPort", "8081"); //代理端口
AxisProperties.setProperty("http.proxyUser", "dwyaoyongsheng"); //用户名
AxisProperties.setProperty("http.proxyPassword", "yys963"); //密码
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpointURL);
call.addParameter("test", XMLType.XSD_STRING, ParameterMode.IN);
call.setOperationName(methodName);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
String ret = (String) call.invoke(new Object[] { new String(xml) });
return ret;
} catch (Exception e) {
return "";
}
}
参考片段(二)
proxyFalg=getinfo.getNetProxyProperty("proxyFalg");
// 请自行加上try...cache代码
URL url = new URL( "http://192.168.80.7:8080/DBJailServer/services/ReadClient");
if(proxyFalg.equals("1")){
// 设置客户端代理服务
SocketAddress add = new InetSocketAddress("192.168.80.4",
808);
//设置webservices代理服务
AxisProperties.setProperty("http.proxyHost","168.168.80.4");
AxisProperties.setProperty("http.proxyPort","808");
AxisProperties.setProperty("http.proxyUser","");
AxisProperties.setProperty("http.proxyPassword","");
Proxy p=null;
if(getinfo.getNetProxyProperty("proxyType").equals("sock5")){
p= new Proxy(Proxy.Type.SOCKS , add);
}
else
{
p = new Proxy(Proxy.Type.HTTP , add);
}
// 打开连接
HttpURLConnection conn = (HttpURLConnection)url.openConnection(p);
conn.connect();
}
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
call.setOperationName( new QName("ReadClient", name) );
call.addParameter( "op1", XMLType.XSD_STRING, ParameterMode.IN );
call.addParameter( "op2", XMLType.XSD_STRING, ParameterMode.IN );
call.addParameter( "op3", XMLType.XSD_INT, ParameterMode.IN );
call.addParameter( "op4", XMLType.XSD_INT, ParameterMode.IN );
call.setReturnType(XMLType.XSD_STRING );
result = (String)call.invoke(new Object[]{str,key,length,count});//
System.out.println(result);
参考片段(三)
/**如果客户那边是使用代理服务器上网的。
在使用axis的调用webservice之前。则只要调用下面的代码即可:**/
AxisProperties.setProperty("http.proxyHost", ProxyServer.getValue("host"));
AxisProperties.setProperty("http.proxyPort", ProxyServer.getValue("port"));
AxisProperties.setProperty("http.proxyUser",ProxyServer.getValue("username"));
AxisProperties.setProperty("http.proxyPassword",ProxyServer.getValue("password"));
//ProxyServer是我自己写的类。是去读取配置文件的