1. 配置 IIS 绑定 IP地址
2. 在 SL 中引用 WebService
3. 在需要调用 WebService 的地方写下列代码:
WCF :
WCF18
19// 创建 wcf 客户端
20
21DynWCFClient client = (DynWCFClient)Activator.CreateInstance(typeof(DynWCFClient), binding, endPoint);
22
23client.DoWorkCompleted += new EventHandler<DoWorkCompletedEventArgs>(client_DoWorkCompleted);
24
25client.DoWorkAsync();
26
27
19// 创建 wcf 客户端
20
21DynWCFClient client = (DynWCFClient)Activator.CreateInstance(typeof(DynWCFClient), binding, endPoint);
22
23client.DoWorkCompleted += new EventHandler<DoWorkCompletedEventArgs>(client_DoWorkCompleted);
24
25client.DoWorkAsync();
26
27
传统 WebService:
WebService
8
9AsmxSoapClient client = (AsmxSoapClient)Activator.CreateInstance(typeof(AsmxSoapClient), binding, endPoint);
10
11client.HelloWorldCompleted += new EventHandler<HelloWorldCompletedEventArgs>(client_HelloWorldCompleted);
12
13client.HelloWorldAsync();
14
15
8
9AsmxSoapClient client = (AsmxSoapClient)Activator.CreateInstance(typeof(AsmxSoapClient), binding, endPoint);
10
11client.HelloWorldCompleted += new EventHandler<HelloWorldCompletedEventArgs>(client_HelloWorldCompleted);
12
13client.HelloWorldAsync();
14
15
这样就可以动态的调用 webservice 了. 完全不需要 ServiceReferences.ClientConfig 文件了.