C# Winform动态调用Web Service
来源:互联网 发布:怎样提升淘宝销量 编辑:程序博客网 时间:2024/05/19 12:13
写项目的时候,忽然遇到一个小问题,在Winform里需要调用Web Service(以前都是调用WCF的,封装好的DLL就可以,比较简单)
上网了解了一下,找到一位师兄写的 http://www.csharpwin.com/csharpspace/10261r1810.shtml(这个地址不知道是转帖还是原创),他采用了动态编译的方式。
我把代码套上试验了一下,能用是肯定的,但是貌似Winform每次重新启动后,第一次连接的耗时总是特别长,因为动态编译的原因
所以想到用最简单的方案来实现,后来还是用微软的方法搞定了。看见网上没其他人下过,就写出来希望能帮助别人,非常简单,高手勿喷,呵呵
1、添加服务引用
2、填入Web Service的地址
3、下一步后会自动生成一个app.config的文件,注意endpoint的名称,name="WebService1Soap"
<?xml version="1.0" encoding="utf-8" ?><configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="WebService1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:15434/WebService1.asmx" binding="basicHttpBinding" bindingConfiguration="WebService1Soap" contract="ServiceReference1.WebService1Soap" name="WebService1Soap" /> </client> </system.serviceModel></configuration>
3、在窗体的cs代码中写调用代码
ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient("WebService1Soap","http://127.0.0.1/test.asmx");
4、第一个参数是endpoint的名称,第二个参数就可以自己填入Web Service的地址了
- C# Winform动态调用Web Service
- C# WinForm动态调用远程Web服务
- C# WinForm动态调用远程Web服务
- WinForm如何调用Web Service
- WinForm如何调用Web Service
- WinForm如何调用Web Service
- WinForm如何调用Web Service
- [WinForm].NET的WinForm调用Web Service
- 动态调用Web Service
- 动态调用web service
- 动态调用Web Service
- C#调用 Web Service
- .NET的WinForm调用Web Service
- 【.Net码农】WinForm如何调用Web Service
- winform对web service的调用
- VS2010 C# 调用Web Service
- C#动态加载web service
- 收藏C# winform 动态调用webservices
- Android NDK 开发环境搭建
- MySQL 数据类型 详解
- .net服务器控件Button之Confirm篇
- Android很有用的代码片段
- Linux下的硬件驱动——USB设备(上)(驱动配置部分)
- C# Winform动态调用Web Service
- MSVCRTD.lib(crtexew.obj) error LNK2019错误
- 泰克测试测量产品
- throws
- Java本地接口(Java Native Interface (JNI))概述
- 先记录一道概率题
- 彻底解决COM端口被占用(在使用中)问题的办法
- QTP自动化测试框架系列一【测试框架产生的原因】
- fork bomb 介绍