If you utilize webservice to surf the extern Internet that do not set the proxy.then will
applear the phenomenon like this 【Unable to sendViaPost to url[http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx]
java.net.UnknownHostException: webservice.webxml.com.cn】
there are 2 ways to solve that.
One is set the properties to the System.
Source Code:
package cn.com.webxml.client;
import java.rmi.RemoteException;
import java.util.Properties;
import org.apache.axis2.AxisFault;
import cn.com.webxml.WeatherWSStub;
import cn.com.webxml.WeatherWSStub.ArrayOfStringE;
public class WeatherWSClientTest {
/**
* @param args
*/
public static void main(String[] args)
{
try {
Properties props = new Properties(System.getProperties());
props.put("http.proxySet", "true");
props.put("http.proxyHost", "172.25.75.2");
props.put("http.proxyPort", "8080");
props.put("http.proxyUser", "domrst\\hejian");
props.put("http.proxyPassword", "********");
Properties newProp = new Properties(props);
System.setProperties(newProp);
WeatherWSStub stub = new WeatherWSStub();
WeatherWSStub.GetWeather weather = new WeatherWSStub.GetWeather();
weather.setTheCityCode("31114");
ArrayOfStringE str = stub.getWeather(weather);
System.out.println(str);
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
another is :
at XXXXXXXStub(ConfigurationContext, String, boolean) method add the follow code:
HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties();
// proxyProperties.setUserName("hejian");
// proxyProperties.setPassWord("xxxxxxxxx");
// proxyProperties.setDomain("DOMRST");
// proxyProperties.setProxyName("172.25.75.2");
// proxyProperties.setProxyPort(8080);
// _serviceClient.getOptions().setProperty(HTTPConstants.PROXY, proxyProperties);
// _serviceClient.getOptions().setProperty(HTTPConstants.CHUNKED, false);
or
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername("hejian");
auth.setPassword("xxxxxxx");
auth.setDomain("domrst");
auth.setHost("172.25.75.2");
auth.setPort(8080);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);*/
// stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);
分享到:
相关推荐
Android通过IIS搭建WebService访问 SQLServer,实现增、删、查
然后自动产生代理类,但是在调用JAVA的WebService时并没有这么简单,特别是对于SoapHeader的处理,通过C#添加Web引用方式访问JavaWebService的方法,除了string类型能正常传递参数外,q其他类型的参数不是默认值就是...
labview调用webservice访问远程数据1
程序首次访问服务时,都需要将服务转成动态库,这得花费一些时间,如果根据以上的做法,便能节约这里所花费的时间,从而提高了WebService的访问速度,虽然可能只能提速1秒,但已很可贵了。
SAP webservice 通过soapui的测试方法 SAP webservice 通过soapui的测试方法
WebService压缩方法整合 有整套的WebService工程 已最简单的方法体现了WebService的简化
【 webservice 】- 白名单配置
详细的描述了远程访问WebService方法,操作步骤及代码
Flex调用WebService访问MSSQL数据库
本代码介绍了vc6.0如何调用webservice的详细步骤,是通过自己的调试成功 总结下来的
调用webservice接口,设置网络代理参数
首先我们创建一个WebService,里面有两个方法:一个无参的方法,一个有参的方法: 创建好了WebService以后,把WebService部署到IIS上,并确保可以访问 二、静态引用 这种方式是通过添加静态引用的方式调用...
PB调用WebService
Android配合WebService访问远程数据库.docx
访问WebService处理拦截开始访问的消息
.NET Webservice Studio是一种以交互方式调用Web方法的工具。 用户可以提供WSDL端点。 单击按钮获取工具获取WSDL,从WSDL生成.NET代理并显示可用方法列表。 用户可以选择任何方法并提供所需的输入参数。 在单击...
WebService方法查看器.rar
Delphi通过WebService访问数据库. 1.查询数据 procedure TForm1.Button1Click(Sender: TObject); var ls_Table: string; ls_Service: Service1Soap; begin ls_Service := Buf_GetBuleService; ls_Table := '...
本文实例讲述了C#实现获取本地内网(局域网)和外网(公网)IP地址的方法。分享给大家供大家参考,具体如下: 1、获取本机的IP地址集合: /// /// 获取本机所有ip地址 /// /// <param name=netType>InterNetwork:...
为调用WebService的方法添加访问权限。