动态调用web service

来源:互联网 发布:java版qq2013 编辑:程序博客网 时间:2024/05/14 06:28
  1.         //利用service参照,得到web service的client,在app.config中有。
  2.         MyServiceReference.MyServiceClassNameSoapClient oClient = new MyServiceReference.MyServiceClassNameSoapClient();
  3.         //设定web service的url
  4.         EndpointAddress ea = new EndpointAddress("http://localhost:7777/pyh/MyService.asmx");
  5.         oClient.Endpoint.Address = ea;
  6.         //设定web service的timeout时间为1秒
  7.         long lTimeout = 10000000;//1s=10000000ns
  8.         TimeSpan timeout = new TimeSpan(lTimeout);
  9.         oClient.InnerChannel.OperationTimeout = timeout;
原创粉丝点击