C#访问带有安全协议的Webservice(https、生成wsdl代理类)
2010-03-16 16:53 calm_水手 阅读(6667) 评论(3) 编辑 收藏 举报1.最近公司上项目,其中有一个小栏目 是查询身份证的,就是输入身份证码和姓名返回你的地址和图片的这种,也就是公安部全国公民身份信息系统(NCIIS)我是第一次,中间有几个问题第一个难题是这样的,要验证证书,当时给文档的时候只有一个地址,也只有安装上了证书文件才能访问,基本的方法是这样的
按上面写的把官方提共的地方输入到地址栏里,然后回车,然后会出现这个对话框,我们只要单击查看证书,就行了,在后面出现的界面 里单击安装就可以了
如果要导出则选择“复制到文件” ==下一步 “Base64编码x.509 (.cer)(s)”选择这一项下一步完成就OK了。
然后把你的证书文件复制到一个位置方便使用。文件名假设为tingting.cer(cer表示证书文件);
下面获取WSDL文件(C#):
2 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.cnblogs.com/ ");
3
4 //创建证书文件
5 X509Certificate objx509 = new X509Certificate(Application.StartupPath + "\\tingting.cer");
6
7 //添加到请求里
8 request.ClientCertificates.Add(objx509);
9
10 //User-AgentHTTP标头的值
11 request.UserAgent = "Client Cert Sample";
12 request.Method = "POST";
13
14 //读返回的流
15 StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream());
16
17 //把得到的WSDL文件放到一个richTextBox1
18 this.richTextBox1.Text = reader.ReadToEnd();
19
Application.StartupPath + "tingting.cer/" 这里就是我们刚才导出的证书文件的地址,当然我们在实际应用中要写成自己的才行;
request.UserAgent = "Client Cert Sample"; User-AgentHTTP标头的值这个可以参考这里 http://support.microsoft.com/kb/895971
下面是详细的代码:
2 方法 1
3 使用 x509 证书 类来读取从.cer 文件的证书,然后将 ClientCertificates 属性设置。
4 方法 2
5 使用 CryptoAPI 调用来从证书存储获得证书,然后将 x509 证书 类设置为接收从证书存储区的证书。 然后,您可以设置 ClientCertificates 属性。
6 回到顶端
7 发送客户端证书的要求
8 可与 ASP.NET 应用程序时确保完成以下要求:
9 LOCAL_MACHINE 注册表配置单元中并不在 CURRENT_USER 注册表配置单元中,必须安装客户端证书。 若要确认客户端证书的安装位置,请按照下列步骤操作:
10 单击 开始、 单击 运行,键入 mmc,然后单击 确定。
11 在 文件 菜单上单击 添加/删除管理单元。
12 在 添加/删除管理单元 对话框中单击 添加。
13 在 添加独立管理单元 对话框中单击 证书,然后单击 添加。
14 在 证书管理单元 对话框中单击 计算机帐户,然后单击 下一步
15 在 选择计算机 对话框中单击 完成。
16 在 添加独立管理单元 对话框中单击 关闭,然后单击 确定。
17 展开 证书 (本地计算机),展开 个人,然后单击 证书。
18 在右窗格中应列出客户端证书。
19 您必须授予 ASP.NET 用户客户端证书的私钥的帐户权限。 若要为 ASP.NET 用户授予客户端证书的私钥的帐户权限,使用 WinHttpCertCfg.exe 工具。有关详细信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
20 823193 (http://support.microsoft.com/kb/823193/ ) 如何获得 Windows HTTP 5.1 证书和跟踪工具
21 有关如何使用此工具,请访问下面的 Microsoft 开发人员网络 (MSDN) 的网站的详细信息:
22 WinHttpCertCfg.exe,证书配置工具 http://msdn2.microsoft.com/en-us/library/aa384088.aspx (http://msdn2.microsoft.com/en-us/library/aa384088.aspx)
23 回到顶端
24 使用.cer 文件
25 方法 1 是易于使用,但方法要求您具有一个.cer 文件。 如果您没有安装的.cer 文件,使用 Microsoft Internet 资源管理器导出.cer 文件。
26
27 下列源代码介绍如何获取证书从一个.cer 文件您可以使用 HttpWebRequest class.
28 //Uncomment the following code if you need a proxy. The boolean true is used to bypass the local address.
29 //WebProxy proxyObject = new WebProxy("Your Proxy value",true);
30 //GlobalProxySelection.Select = proxyObject;
31
32 // Obtain the certificate.
33 try
34 {
35 //You must change the path to point to your .cer file location.
36 X509Certificate Cert = X509Certificate.CreateFromCertFile("C:\\mycert.cer");
37 // Handle any certificate errors on the certificate from the server.
38 ServicePointManager.CertificatePolicy = new CertPolicy();
39 // You must change the URL to point to your Web server.
40 HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://YourServer/sample.asp");
41 Request.ClientCertificates.Add(Cert);
42 Request.UserAgent = "Client Cert Sample";
43 Request.Method = "GET";
44 HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
45 // Print the repsonse headers.
46 Console.WriteLine("{0}",Response.Headers);
47 Console.WriteLine();
48 // Get the certificate data.
49 StreamReader sr = new StreamReader(Response.GetResponseStream(), Encoding.Default);
50 int count;
51 char [] ReadBuf = new char[1024];
52 do
53 {
54 count = sr.Read(ReadBuf, 0, 1024);
55 if (0 != count)
56 {
57 Console.WriteLine(new string(ReadBuf));
58 }
59
60 }while(count > 0);
61 }
62 catch(Exception e)
63 {
64 Console.WriteLine(e.Message);
65 }
66
67
68 //Implement the ICertificatePolicy interface.
69 class CertPolicy: ICertificatePolicy
70 {
71 public bool CheckValidationResult(ServicePoint srvPoint,
72 X509Certificate certificate, WebRequest request, int certificateProblem)
73 {
74 // You can do your own certificate checking.
75 // You can obtain the error values from WinError.h.
76
77 // Return true so that any certificate will work with this sample.
78 return true;
79 }
80 }
81
82
83
84 使用 CryptoAPI 调用
85 如果您必须获取该证书从证书存储区,CryptoAPI 函数用于在获取该证书,然后将其存储在 x509 证书 类对象。 X509CertificateCollection 类枚举存储区中的所有证书,然后将其置于 X509CertificateCollection 类对象中。
86
87 如果想获得特定的证书,必须更改类代码,以使用 CertFindCertificateInStore 函数获取特定的证书。 Wincrypt.h 的文件中声明该函数。 鎴栬 € 咃,您可以枚举 X509CertificateCollection 函数,以查找所需的证书。
88
89 下面的代码示例使用从 CertEnumCertificatesInStore 函数返回集合中的第一个证书
90 using System;
91 using System.Net;
92 using System.IO;
93 using System.Text;
94 using System.Security.Cryptography;
95 using System.Security.Cryptography.X509Certificates;
96 using System.Runtime.InteropServices;
97
98 namespace SelectClientCert
99 {
100 /// Sample that describes how how to select client cetificate and send it to the server.
101
102 class MyCerts{
103
104 private static int CERT_STORE_PROV_SYSTEM = 10;
105 private static int CERT_SYSTEM_STORE_CURRENT_USER = (1 << 16);
106 ///private static int CERT_SYSTEM_STORE_LOCAL_MACHINE = (2 << 16);
107
108 [DllImport("CRYPT32", EntryPoint="CertOpenStore", CharSet=CharSet.Unicode, SetLastError=true)]
109 public static extern IntPtr CertOpenStore(
110 int storeProvider, int encodingType,
111 int hcryptProv, int flags, string pvPara);
112
113 [DllImport("CRYPT32", EntryPoint="CertEnumCertificatesInStore", CharSet=CharSet.Unicode, SetLastError=true)]
114 public static extern IntPtr CertEnumCertificatesInStore(
115 IntPtr storeProvider,
116 IntPtr prevCertContext);
117
118 [DllImport("CRYPT32", EntryPoint="CertCloseStore", CharSet=CharSet.Unicode, SetLastError=true)]
119 public static extern bool CertCloseStore(
120 IntPtr storeProvider,
121 int flags);
122
123 X509CertificateCollection m_certs;
124
125 public MyCerts(){
126 m_certs = new X509CertificateCollection();
127 }
128
129 public int Init()
130 {
131 IntPtr storeHandle;
132 storeHandle = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, "MY");
133 IntPtr currentCertContext;
134 currentCertContext = CertEnumCertificatesInStore(storeHandle, (IntPtr)0);
135 int i = 0;
136 while (currentCertContext != (IntPtr)0)
137 {
138 m_certs.Insert(i++, new X509Certificate(currentCertContext));
139 currentCertContext = CertEnumCertificatesInStore(storeHandle, currentCertContext);
140 }
141 CertCloseStore(storeHandle, 0);
142
143 return m_certs.Count;
144 }
145
146 public X509Certificate this [int index]
147 {
148 get
149 {
150 // Check the index limits.
151 if (index < 0 || index > m_certs.Count)
152 return null;
153 else
154 return m_certs[index];
155 }
156 }
157 };
158 class MyHttpResource
159 {
160 String m_url;
161
162 public MyHttpResource(string url){
163 m_url = url;
164 }
165
166 public void GetFile(){
167
168 HttpWebResponse result = null;
169
170 try{
171
172 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(m_url);
173 req.Credentials = CredentialCache.DefaultCredentials;
174
175 ///Method1
176 //req.ClientCertificates.Add(X509Certificate.CreateFromCertFile("D:\\Temp\\cert\\c1.cer"));
177
178 ///Method2
179 ///Uses interop services
180 MyCerts mycert = new MyCerts();
181 if(mycert.Init() > 0)
182 req.ClientCertificates.Add(mycert[0]);
183
184 result = (HttpWebResponse)req.GetResponse();
185
186 Stream ReceiveStream = result.GetResponseStream();
187 Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
188
189 StreamReader sr = new StreamReader( ReceiveStream, encode );
190 Console.WriteLine("\r\nResponse stream received");
191
192 Char[] read = new Char[256];
193 int count = sr.Read( read, 0, 256 );
194
195 Console.WriteLine("HTTP Response...\r\n");
196 while (count > 0)
197 {
198 String str = new String(read, 0, count);
199 Console.Write(str);
200 count = sr.Read(read, 0, 256);
201 }
202
203 }
204 catch(WebException e)
205 {
206
207 Console.WriteLine("\r\nError:");
208 #if (DEBUG)
209 Console.WriteLine(e.ToString());
210 #else
211 Console.WriteLine(e.Message);
212 #endif
213
214 }
215 finally
216 {
217 if ( result != null ) {
218 result.Close();
219 }
220 }
221
222 }
223
224 }
225
226 class CertSample
227 {
228 static void Main(string[] args)
229 {
230 try
231 {
232 if (args.Length < 1)
233 {
234 Console.WriteLine("No url is entered to download, returning.\n");
235 Console.WriteLine("Usage: CertSample <urltoget>\n");
236 Console.WriteLine(" e.g: CertSample https://servername \n");
237
238 return;
239 }
240
241 MyHttpResource hr = new MyHttpResource(args[0]);
242 hr.GetFile();
243 }
244 catch(Exception e)
245 {
246 Console.WriteLine(e.ToString());
247 }
248 return;
249 }
250 }
251 }
252
253
254
255 参考有关详细信息请访问下面的 Microsoft 开发网络 (MSDN) 网站: x509 证书类http://msdn2.microsoft.com/en-us/...有关详细信息请访问下面的 Microsoft 开发网络 (MSDN)
256
257 x509 证书类
258 http://msdn2.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate(vs.71).aspx)
259
260
得到WSDL的XML文档如下:
2 <wsdl:definitions targetNamespace="https://www.cnblogs.com/ " xmlns:tns="https://api.nciic.org.cn/nciicGetCondition" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://https//www.cnblogs.com/ 2003/05/soap-envelope" xmlns:xsd="http://https//www.cnblogs.com/ 2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://https//www.cnblogs.com/ 2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
3 <wsdl:types>
4 <xsd:schema xmlns:xsd="http://home.cnblogs.com/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="https://api.nciic.org.cn/nciicGetCondition">
5 <xsd:element name="nciicDiscern">
6 <xsd:complexType>
7 <xsd:sequence>
8 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
9 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
10 </xsd:sequence>
11 </xsd:complexType>
12 </xsd:element>
13 <xsd:element name="nciicDiscernResponse">
14 <xsd:complexType>
15 <xsd:sequence>
16 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
17 </xsd:sequence>
18 </xsd:complexType>
19 </xsd:element>
20 <xsd:element name="nciicCheckChina">
21 <xsd:complexType>
22 <xsd:sequence>
23 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
24 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
25 </xsd:sequence>
26 </xsd:complexType>
27 </xsd:element>
28 <xsd:element name="nciicCheckChinaResponse">
29 <xsd:complexType>
30 <xsd:sequence>
31 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
32 </xsd:sequence>
33 </xsd:complexType>
34 </xsd:element>
35 <xsd:element name="nciicGetCondition">
36 <xsd:complexType>
37 <xsd:sequence>
38 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
39 </xsd:sequence>
40 </xsd:complexType>
41 </xsd:element>
42 <xsd:element name="nciicGetConditionResponse">
43 <xsd:complexType>
44 <xsd:sequence>
45 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
46 </xsd:sequence>
47 </xsd:complexType>
48 </xsd:element>
49 <xsd:element name="nciicExactSearch">
50 <xsd:complexType>
51 <xsd:sequence>
52 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
53 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
54 </xsd:sequence>
55 </xsd:complexType>
56 </xsd:element>
57 <xsd:element name="nciicExactSearchResponse">
58 <xsd:complexType>
59 <xsd:sequence>
60 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
61 </xsd:sequence>
62 </xsd:complexType>
63 </xsd:element>
64 <xsd:element name="nciicCourt">
65 <xsd:complexType>
66 <xsd:sequence>
67 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
68 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
69 </xsd:sequence>
70 </xsd:complexType>
71 </xsd:element>
72 <xsd:element name="nciicCourtResponse">
73 <xsd:complexType>
74 <xsd:sequence>
75 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
76 </xsd:sequence>
77 </xsd:complexType>
78 </xsd:element>
79 <xsd:element name="nciicBirthplaceCompare">
80 <xsd:complexType>
81 <xsd:sequence>
82 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
83 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
84 </xsd:sequence>
85 </xsd:complexType>
86 </xsd:element>
87 <xsd:element name="nciicBirthplaceCompareResponse">
88 <xsd:complexType>
89 <xsd:sequence>
90 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
91 </xsd:sequence>
92 </xsd:complexType>
93 </xsd:element>
94 <xsd:element name="nciicAddrExactSearch">
95 <xsd:complexType>
96 <xsd:sequence>
97 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
98 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
99 </xsd:sequence>
100 </xsd:complexType>
101 </xsd:element>
102 <xsd:element name="nciicAddrExactSearchResponse">
103 <xsd:complexType>
104 <xsd:sequence>
105 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
106 </xsd:sequence>
107 </xsd:complexType>
108 </xsd:element>
109 <xsd:element name="nciicCheck">
110 <xsd:complexType>
111 <xsd:sequence>
112 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
113 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
114 </xsd:sequence>
115 </xsd:complexType>
116 </xsd:element>
117 <xsd:element name="nciicCheckResponse">
118 <xsd:complexType>
119 <xsd:sequence>
120 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
121 </xsd:sequence>
122 </xsd:complexType>
123 </xsd:element>
124 <xsd:element name="nciicCompare">
125 <xsd:complexType>
126 <xsd:sequence>
127 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
128 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
129 </xsd:sequence>
130 </xsd:complexType>
131 </xsd:element>
132 <xsd:element name="nciicCompareResponse">
133 <xsd:complexType>
134 <xsd:sequence>
135 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
136 </xsd:sequence>
137 </xsd:complexType>
138 </xsd:element>
139 <xsd:element name="nciicCombineSearch">
140 <xsd:complexType>
141 <xsd:sequence>
142 <xsd:element maxOccurs="1" minOccurs="1" name="inLicense" nillable="true" type="xsd:string"/>
143 <xsd:element maxOccurs="1" minOccurs="1" name="inConditions" nillable="true" type="xsd:string"/>
144 </xsd:sequence>
145 </xsd:complexType>
146 </xsd:element>
147 <xsd:element name="nciicCombineSearchResponse">
148 <xsd:complexType>
149 <xsd:sequence>
150 <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
151 </xsd:sequence>
152 </xsd:complexType>
153 </xsd:element>
154 </xsd:schema>
155 </wsdl:types>
156 <wsdl:message name="nciicCombineSearchResponse">
157 <wsdl:part name="parameters" element="tns:nciicCombineSearchResponse">
158 </wsdl:part>
159 </wsdl:message>
160 <wsdl:message name="nciicCheckChinaRequest">
161 <wsdl:part name="parameters" element="tns:nciicCheckChina">
162 </wsdl:part>
163 </wsdl:message>
164 <wsdl:message name="nciicBirthplaceCompareResponse">
165 <wsdl:part name="parameters" element="tns:nciicBirthplaceCompareResponse">
166 </wsdl:part>
167 </wsdl:message>
168 <wsdl:message name="nciicAddrExactSearchRequest">
169 <wsdl:part name="parameters" element="tns:nciicAddrExactSearch">
170 </wsdl:part>
171 </wsdl:message>
172 <wsdl:message name="nciicCheckRequest">
173 <wsdl:part name="parameters" element="tns:nciicCheck">
174 </wsdl:part>
175 </wsdl:message>
176 <wsdl:message name="nciicExactSearchResponse">
177 <wsdl:part name="parameters" element="tns:nciicExactSearchResponse">
178 </wsdl:part>
179 </wsdl:message>
180 <wsdl:message name="nciicCompareResponse">
181 <wsdl:part name="parameters" element="tns:nciicCompareResponse">
182 </wsdl:part>
183 </wsdl:message>
184 <wsdl:message name="nciicCheckResponse">
185 <wsdl:part name="parameters" element="tns:nciicCheckResponse">
186 </wsdl:part>
187 </wsdl:message>
188 <wsdl:message name="nciicCourtRequest">
189 <wsdl:part name="parameters" element="tns:nciicCourt">
190 </wsdl:part>
191 </wsdl:message>
192 <wsdl:message name="nciicExactSearchRequest">
193 <wsdl:part name="parameters" element="tns:nciicExactSearch">
194 </wsdl:part>
195 </wsdl:message>
196 <wsdl:message name="nciicBirthplaceCompareRequest">
197 <wsdl:part name="parameters" element="tns:nciicBirthplaceCompare">
198 </wsdl:part>
199 </wsdl:message>
200 <wsdl:message name="nciicAddrExactSearchResponse">
201 <wsdl:part name="parameters" element="tns:nciicAddrExactSearchResponse">
202 </wsdl:part>
203 </wsdl:message>
204 <wsdl:message name="nciicCombineSearchRequest">
205 <wsdl:part name="parameters" element="tns:nciicCombineSearch">
206 </wsdl:part>
207 </wsdl:message>
208 <wsdl:message name="nciicDiscernRequest">
209 <wsdl:part name="parameters" element="tns:nciicDiscern">
210 </wsdl:part>
211 </wsdl:message>
212 <wsdl:message name="nciicCourtResponse">
213 <wsdl:part name="parameters" element="tns:nciicCourtResponse">
214 </wsdl:part>
215 </wsdl:message>
216 <wsdl:message name="nciicCompareRequest">
217 <wsdl:part name="parameters" element="tns:nciicCompare">
218 </wsdl:part>
219 </wsdl:message>
220 <wsdl:message name="nciicDiscernResponse">
221 <wsdl:part name="parameters" element="tns:nciicDiscernResponse">
222 </wsdl:part>
223 </wsdl:message>
224 <wsdl:message name="nciicGetConditionRequest">
225 <wsdl:part name="parameters" element="tns:nciicGetCondition">
226 </wsdl:part>
227 </wsdl:message>
228 <wsdl:message name="nciicGetConditionResponse">
229 <wsdl:part name="parameters" element="tns:nciicGetConditionResponse">
230 </wsdl:part>
231 </wsdl:message>
232 <wsdl:message name="nciicCheckChinaResponse">
233 <wsdl:part name="parameters" element="tns:nciicCheckChinaResponse">
234 </wsdl:part>
235 </wsdl:message>
236 <wsdl:portType name="nciicGetConditionPortType">
237 <wsdl:operation name="nciicDiscern">
238 <wsdl:input name="nciicDiscernRequest" message="tns:nciicDiscernRequest">
239 </wsdl:input>
240 <wsdl:output name="nciicDiscernResponse" message="tns:nciicDiscernResponse">
241 </wsdl:output>
242 </wsdl:operation>
243 <wsdl:operation name="nciicCheckChina">
244 <wsdl:input name="nciicCheckChinaRequest" message="tns:nciicCheckChinaRequest">
245 </wsdl:input>
246 <wsdl:output name="nciicCheckChinaResponse" message="tns:nciicCheckChinaResponse">
247 </wsdl:output>
248 </wsdl:operation>
249 <wsdl:operation name="nciicGetCondition">
250 <wsdl:input name="nciicGetConditionRequest" message="tns:nciicGetConditionRequest">
251 </wsdl:input>
252 <wsdl:output name="nciicGetConditionResponse" message="tns:nciicGetConditionResponse">
253 </wsdl:output>
254 </wsdl:operation>
255 <wsdl:operation name="nciicExactSearch">
256 <wsdl:input name="nciicExactSearchRequest" message="tns:nciicExactSearchRequest">
257 </wsdl:input>
258 <wsdl:output name="nciicExactSearchResponse" message="tns:nciicExactSearchResponse">
259 </wsdl:output>
260 </wsdl:operation>
261 <wsdl:operation name="nciicCourt">
262 <wsdl:input name="nciicCourtRequest" message="tns:nciicCourtRequest">
263 </wsdl:input>
264 <wsdl:output name="nciicCourtResponse" message="tns:nciicCourtResponse">
265 </wsdl:output>
266 </wsdl:operation>
267 <wsdl:operation name="nciicBirthplaceCompare">
268 <wsdl:input name="nciicBirthplaceCompareRequest" message="tns:nciicBirthplaceCompareRequest">
269 </wsdl:input>
270 <wsdl:output name="nciicBirthplaceCompareResponse" message="tns:nciicBirthplaceCompareResponse">
271 </wsdl:output>
272 </wsdl:operation>
273 <wsdl:operation name="nciicAddrExactSearch">
274 <wsdl:input name="nciicAddrExactSearchRequest" message="tns:nciicAddrExactSearchRequest">
275 </wsdl:input>
276 <wsdl:output name="nciicAddrExactSearchResponse" message="tns:nciicAddrExactSearchResponse">
277 </wsdl:output>
278 </wsdl:operation>
279 <wsdl:operation name="nciicCheck">
280 <wsdl:input name="nciicCheckRequest" message="tns:nciicCheckRequest">
281 </wsdl:input>
282 <wsdl:output name="nciicCheckResponse" message="tns:nciicCheckResponse">
283 </wsdl:output>
284 </wsdl:operation>
285 <wsdl:operation name="nciicCompare">
286 <wsdl:input name="nciicCompareRequest" message="tns:nciicCompareRequest">
287 </wsdl:input>
288 <wsdl:output name="nciicCompareResponse" message="tns:nciicCompareResponse">
289 </wsdl:output>
290 </wsdl:operation>
291 <wsdl:operation name="nciicCombineSearch">
292 <wsdl:input name="nciicCombineSearchRequest" message="tns:nciicCombineSearchRequest">
293 </wsdl:input>
294 <wsdl:output name="nciicCombineSearchResponse" message="tns:nciicCombineSearchResponse">
295 </wsdl:output>
296 </wsdl:operation>
297 </wsdl:portType>
298 <wsdl:binding name="nciicGetConditionHttpBinding" type="tns:nciicGetConditionPortType">
299 <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
300 <wsdl:operation name="nciicDiscern">
301 <wsdlsoap:operation soapAction=""/>
302 <wsdl:input name="nciicDiscernRequest">
303 <wsdlsoap:body use="literal"/>
304 </wsdl:input>
305 <wsdl:output name="nciicDiscernResponse">
306 <wsdlsoap:body use="literal"/>
307 </wsdl:output>
308 </wsdl:operation>
309 <wsdl:operation name="nciicCheckChina">
310 <wsdlsoap:operation soapAction=""/>
311 <wsdl:input name="nciicCheckChinaRequest">
312 <wsdlsoap:body use="literal"/>
313 </wsdl:input>
314 <wsdl:output name="nciicCheckChinaResponse">
315 <wsdlsoap:body use="literal"/>
316 </wsdl:output>
317 </wsdl:operation>
318 <wsdl:operation name="nciicGetCondition">
319 <wsdlsoap:operation soapAction=""/>
320 <wsdl:input name="nciicGetConditionRequest">
321 <wsdlsoap:body use="literal"/>
322 </wsdl:input>
323 <wsdl:output name="nciicGetConditionResponse">
324 <wsdlsoap:body use="literal"/>
325 </wsdl:output>
326 </wsdl:operation>
327 <wsdl:operation name="nciicExactSearch">
328 <wsdlsoap:operation soapAction=""/>
329 <wsdl:input name="nciicExactSearchRequest">
330 <wsdlsoap:body use="literal"/>
331 </wsdl:input>
332 <wsdl:output name="nciicExactSearchResponse">
333 <wsdlsoap:body use="literal"/>
334 </wsdl:output>
335 </wsdl:operation>
336 <wsdl:operation name="nciicCourt">
337 <wsdlsoap:operation soapAction=""/>
338 <wsdl:input name="nciicCourtRequest">
339 <wsdlsoap:body use="literal"/>
340 </wsdl:input>
341 <wsdl:output name="nciicCourtResponse">
342 <wsdlsoap:body use="literal"/>
343 </wsdl:output>
344 </wsdl:operation>
345 <wsdl:operation name="nciicBirthplaceCompare">
346 <wsdlsoap:operation soapAction=""/>
347 <wsdl:input name="nciicBirthplaceCompareRequest">
348 <wsdlsoap:body use="literal"/>
349 </wsdl:input>
350 <wsdl:output name="nciicBirthplaceCompareResponse">
351 <wsdlsoap:body use="literal"/>
352 </wsdl:output>
353 </wsdl:operation>
354 <wsdl:operation name="nciicAddrExactSearch">
355 <wsdlsoap:operation soapAction=""/>
356 <wsdl:input name="nciicAddrExactSearchRequest">
357 <wsdlsoap:body use="literal"/>
358 </wsdl:input>
359 <wsdl:output name="nciicAddrExactSearchResponse">
360 <wsdlsoap:body use="literal"/>
361 </wsdl:output>
362 </wsdl:operation>
363 <wsdl:operation name="nciicCheck">
364 <wsdlsoap:operation soapAction=""/>
365 <wsdl:input name="nciicCheckRequest">
366 <wsdlsoap:body use="literal"/>
367 </wsdl:input>
368 <wsdl:output name="nciicCheckResponse">
369 <wsdlsoap:body use="literal"/>
370 </wsdl:output>
371 </wsdl:operation>
372 <wsdl:operation name="nciicCompare">
373 <wsdlsoap:operation soapAction=""/>
374 <wsdl:input name="nciicCompareRequest">
375 <wsdlsoap:body use="literal"/>
376 </wsdl:input>
377 <wsdl:output name="nciicCompareResponse">
378 <wsdlsoap:body use="literal"/>
379 </wsdl:output>
380 </wsdl:operation>
381 <wsdl:operation name="nciicCombineSearch">
382 <wsdlsoap:operation soapAction=""/>
383 <wsdl:input name="nciicCombineSearchRequest">
384 <wsdlsoap:body use="literal"/>
385 </wsdl:input>
386 <wsdl:output name="nciicCombineSearchResponse">
387 <wsdlsoap:body use="literal"/>
388 </wsdl:output>
389 </wsdl:operation>
390 </wsdl:binding>
391 <wsdl:service name="nciicGetCondition">
392 <wsdl:port name="nciicGetConditionHttpPort" binding="tns:nciicGetConditionHttpBinding">
393 <wsdlsoap:address location="http://api.nciic.org.cn/nciic_ws/services/nciicGetCondition"/>
394 </wsdl:port>
395 </wsdl:service>
396 </wsdl:definitions>
397
398
我们得把它转化成一个类文件才行,
方法很简单,这是在我知道 了之后才这样讲的,呵呵
利用wsdl.exe生成webservice代理类:
根据提供的wsdl生成webservice代理类
1、开始->程序->Visual Studio 2008 命令提示
2、输入如下红色标记部分
D:\Program Files\Microsoft Visual Studio 8\VC>wsdl /language:c# /n:TestDemo /out:d:\text\TestService.cs D:\text\TestService.wsdl
在d:/text下就会产生一个TestService.cs 文件
注意:D:\text\TestService.wsdl 是wsdl路径,可以是url路径
如果 你想知道WSDL文件是怎么使用的话,直接写WSDL回车就可以,会出显所有的说明
还有一个方法更方便
首先打开Visual Studio 2008,选择菜单"工具"-"外部工具"打开外部工具对话框,如图
,单击“添加”按钮添加新工具,然后在“标题”行中输入"WSDL生成代理类","命令"行中输入"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\wsdl.exe"(wsdl.exe文件的路径),"参数"行中输入"/l:cs
上面是来自http://blog.sina.com.cn/s/blog_48964b120100fz14.html 在这里谢谢了
生成的类文件里会包括 方法使用和怎么样和服务器沟通,我们只要调用 方法就要可以了,
类文件如下
2 // <auto-generated>
3 // 此代码由工具生成。
4 // 运行库版本:2.0.50727.1873
5 //
6 // 对此文件的更改可能会导致不正确的行为,并且如果
7 // 重新生成代码,这些更改将会丢失。
8 // </auto-generated>
9 //------------------------------------------------------------------------------
10
11 //
12 // 此源代码由 wsdl 自动生成, Version=2.0.50727.1432。
13 //
14 namespace WSDLServices
15 {
16 using System.Diagnostics;
17 using System.Web.Services;
18 using System.ComponentModel;
19 using System.Web.Services.Protocols;
20 using System;
21 using System.Xml.Serialization;
22
23
24 /// <remarks/>
25 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
26 [System.Diagnostics.DebuggerStepThroughAttribute()]
27 [System.ComponentModel.DesignerCategoryAttribute("code")]
28 [System.Web.Services.WebServiceBindingAttribute(Name="nciicGetConditionHttpBinding", Namespace="https://http://www.cnblogs.com/ /nciicGetCondition")]
29 public partial class nciicGetCondition : System.Web.Services.Protocols.SoapHttpClientProtocol {
30
31 private System.Threading.SendOrPostCallback nciicDiscernOperationCompleted;
32
33 private System.Threading.SendOrPostCallback nciicCheckChinaOperationCompleted;
34
35 private System.Threading.SendOrPostCallback CallnciicGetConditionOperationCompleted;
36
37 private System.Threading.SendOrPostCallback nciicExactSearchOperationCompleted;
38
39 private System.Threading.SendOrPostCallback nciicCourtOperationCompleted;
40
41 private System.Threading.SendOrPostCallback nciicBirthplaceCompareOperationCompleted;
42
43 private System.Threading.SendOrPostCallback nciicAddrExactSearchOperationCompleted;
44
45 private System.Threading.SendOrPostCallback nciicCheckOperationCompleted;
46
47 private System.Threading.SendOrPostCallback nciicCompareOperationCompleted;
48
49 private System.Threading.SendOrPostCallback nciicCombineSearchOperationCompleted;
50
51 /// <remarks/>
52 public nciicGetCondition() {
53 this.Url = "http://http://www.cnblogs.com/ /nciic_ws/services/nciicGetCondition";
54 }
55
56 /// <remarks/>
57 public event nciicDiscernCompletedEventHandler nciicDiscernCompleted;
58
59 /// <remarks/>
60 public event nciicCheckChinaCompletedEventHandler nciicCheckChinaCompleted;
61
62 /// <remarks/>
63 public event CallnciicGetConditionCompletedEventHandler CallnciicGetConditionCompleted;
64
65 /// <remarks/>
66 public event nciicExactSearchCompletedEventHandler nciicExactSearchCompleted;
67
68 /// <remarks/>
69 public event nciicCourtCompletedEventHandler nciicCourtCompleted;
70
71 /// <remarks/>
72 public event nciicBirthplaceCompareCompletedEventHandler nciicBirthplaceCompareCompleted;
73
74 /// <remarks/>
75 public event nciicAddrExactSearchCompletedEventHandler nciicAddrExactSearchCompleted;
76
77 /// <remarks/>
78 public event nciicCheckCompletedEventHandler nciicCheckCompleted;
79
80 /// <remarks/>
81 public event nciicCompareCompletedEventHandler nciicCompareCompleted;
82
83 /// <remarks/>
84 public event nciicCombineSearchCompletedEventHandler nciicCombineSearchCompleted;
85
86 /// <remarks/>
87 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
88 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
89 public string nciicDiscern([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
90 object[] results = this.Invoke("nciicDiscern", new object[] {
91 inLicense,
92 inConditions});
93 return ((string)(results[0]));
94 }
95
96 /// <remarks/>
97 public System.IAsyncResult BeginnciicDiscern(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
98 return this.BeginInvoke("nciicDiscern", new object[] {
99 inLicense,
100 inConditions}, callback, asyncState);
101 }
102
103 /// <remarks/>
104 public string EndnciicDiscern(System.IAsyncResult asyncResult) {
105 object[] results = this.EndInvoke(asyncResult);
106 return ((string)(results[0]));
107 }
108
109 /// <remarks/>
110 public void nciicDiscernAsync(string inLicense, string inConditions) {
111 this.nciicDiscernAsync(inLicense, inConditions, null);
112 }
113
114 /// <remarks/>
115 public void nciicDiscernAsync(string inLicense, string inConditions, object userState) {
116 if ((this.nciicDiscernOperationCompleted == null)) {
117 this.nciicDiscernOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicDiscernOperationCompleted);
118 }
119 this.InvokeAsync("nciicDiscern", new object[] {
120 inLicense,
121 inConditions}, this.nciicDiscernOperationCompleted, userState);
122 }
123
124 private void OnnciicDiscernOperationCompleted(object arg) {
125 if ((this.nciicDiscernCompleted != null)) {
126 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
127 this.nciicDiscernCompleted(this, new nciicDiscernCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
128 }
129 }
130
131 /// <remarks/>
132 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
133 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
134 public string nciicCheckChina([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
135 object[] results = this.Invoke("nciicCheckChina", new object[] {
136 inLicense,
137 inConditions});
138 return ((string)(results[0]));
139 }
140
141 /// <remarks/>
142 public System.IAsyncResult BeginnciicCheckChina(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
143 return this.BeginInvoke("nciicCheckChina", new object[] {
144 inLicense,
145 inConditions}, callback, asyncState);
146 }
147
148 /// <remarks/>
149 public string EndnciicCheckChina(System.IAsyncResult asyncResult) {
150 object[] results = this.EndInvoke(asyncResult);
151 return ((string)(results[0]));
152 }
153
154 /// <remarks/>
155 public void nciicCheckChinaAsync(string inLicense, string inConditions) {
156 this.nciicCheckChinaAsync(inLicense, inConditions, null);
157 }
158
159 /// <remarks/>
160 public void nciicCheckChinaAsync(string inLicense, string inConditions, object userState) {
161 if ((this.nciicCheckChinaOperationCompleted == null)) {
162 this.nciicCheckChinaOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicCheckChinaOperationCompleted);
163 }
164 this.InvokeAsync("nciicCheckChina", new object[] {
165 inLicense,
166 inConditions}, this.nciicCheckChinaOperationCompleted, userState);
167 }
168
169 private void OnnciicCheckChinaOperationCompleted(object arg) {
170 if ((this.nciicCheckChinaCompleted != null)) {
171 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
172 this.nciicCheckChinaCompleted(this, new nciicCheckChinaCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
173 }
174 }
175
176 /// <remarks/>
177 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestElementName="nciicGetCondition", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseElementName="nciicGetConditionResponse", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
178 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
179 public string CallnciicGetCondition([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense) {
180 object[] results = this.Invoke("CallnciicGetCondition", new object[] {
181 inLicense});
182 return ((string)(results[0]));
183 }
184
185 /// <remarks/>
186 public System.IAsyncResult BeginCallnciicGetCondition(string inLicense, System.AsyncCallback callback, object asyncState) {
187 return this.BeginInvoke("CallnciicGetCondition", new object[] {
188 inLicense}, callback, asyncState);
189 }
190
191 /// <remarks/>
192 public string EndCallnciicGetCondition(System.IAsyncResult asyncResult) {
193 object[] results = this.EndInvoke(asyncResult);
194 return ((string)(results[0]));
195 }
196
197 /// <remarks/>
198 public void CallnciicGetConditionAsync(string inLicense) {
199 this.CallnciicGetConditionAsync(inLicense, null);
200 }
201
202 /// <remarks/>
203 public void CallnciicGetConditionAsync(string inLicense, object userState) {
204 if ((this.CallnciicGetConditionOperationCompleted == null)) {
205 this.CallnciicGetConditionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCallnciicGetConditionOperationCompleted);
206 }
207 this.InvokeAsync("CallnciicGetCondition", new object[] {
208 inLicense}, this.CallnciicGetConditionOperationCompleted, userState);
209 }
210
211 private void OnCallnciicGetConditionOperationCompleted(object arg) {
212 if ((this.CallnciicGetConditionCompleted != null)) {
213 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
214 this.CallnciicGetConditionCompleted(this, new CallnciicGetConditionCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
215 }
216 }
217
218 /// <remarks/>
219 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
220 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
221 public string nciicExactSearch([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
222 object[] results = this.Invoke("nciicExactSearch", new object[] {
223 inLicense,
224 inConditions});
225 return ((string)(results[0]));
226 }
227
228 /// <remarks/>
229 public System.IAsyncResult BeginnciicExactSearch(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
230 return this.BeginInvoke("nciicExactSearch", new object[] {
231 inLicense,
232 inConditions}, callback, asyncState);
233 }
234
235 /// <remarks/>
236 public string EndnciicExactSearch(System.IAsyncResult asyncResult) {
237 object[] results = this.EndInvoke(asyncResult);
238 return ((string)(results[0]));
239 }
240
241 /// <remarks/>
242 public void nciicExactSearchAsync(string inLicense, string inConditions) {
243 this.nciicExactSearchAsync(inLicense, inConditions, null);
244 }
245
246 /// <remarks/>
247 public void nciicExactSearchAsync(string inLicense, string inConditions, object userState) {
248 if ((this.nciicExactSearchOperationCompleted == null)) {
249 this.nciicExactSearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicExactSearchOperationCompleted);
250 }
251 this.InvokeAsync("nciicExactSearch", new object[] {
252 inLicense,
253 inConditions}, this.nciicExactSearchOperationCompleted, userState);
254 }
255
256 private void OnnciicExactSearchOperationCompleted(object arg) {
257 if ((this.nciicExactSearchCompleted != null)) {
258 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
259 this.nciicExactSearchCompleted(this, new nciicExactSearchCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
260 }
261 }
262
263 /// <remarks/>
264 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
265 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
266 public string nciicCourt([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
267 object[] results = this.Invoke("nciicCourt", new object[] {
268 inLicense,
269 inConditions});
270 return ((string)(results[0]));
271 }
272
273 /// <remarks/>
274 public System.IAsyncResult BeginnciicCourt(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
275 return this.BeginInvoke("nciicCourt", new object[] {
276 inLicense,
277 inConditions}, callback, asyncState);
278 }
279
280 /// <remarks/>
281 public string EndnciicCourt(System.IAsyncResult asyncResult) {
282 object[] results = this.EndInvoke(asyncResult);
283 return ((string)(results[0]));
284 }
285
286 /// <remarks/>
287 public void nciicCourtAsync(string inLicense, string inConditions) {
288 this.nciicCourtAsync(inLicense, inConditions, null);
289 }
290
291 /// <remarks/>
292 public void nciicCourtAsync(string inLicense, string inConditions, object userState) {
293 if ((this.nciicCourtOperationCompleted == null)) {
294 this.nciicCourtOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicCourtOperationCompleted);
295 }
296 this.InvokeAsync("nciicCourt", new object[] {
297 inLicense,
298 inConditions}, this.nciicCourtOperationCompleted, userState);
299 }
300
301 private void OnnciicCourtOperationCompleted(object arg) {
302 if ((this.nciicCourtCompleted != null)) {
303 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
304 this.nciicCourtCompleted(this, new nciicCourtCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
305 }
306 }
307
308 /// <remarks/>
309 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
310 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
311 public string nciicBirthplaceCompare([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
312 object[] results = this.Invoke("nciicBirthplaceCompare", new object[] {
313 inLicense,
314 inConditions});
315 return ((string)(results[0]));
316 }
317
318 /// <remarks/>
319 public System.IAsyncResult BeginnciicBirthplaceCompare(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
320 return this.BeginInvoke("nciicBirthplaceCompare", new object[] {
321 inLicense,
322 inConditions}, callback, asyncState);
323 }
324
325 /// <remarks/>
326 public string EndnciicBirthplaceCompare(System.IAsyncResult asyncResult) {
327 object[] results = this.EndInvoke(asyncResult);
328 return ((string)(results[0]));
329 }
330
331 /// <remarks/>
332 public void nciicBirthplaceCompareAsync(string inLicense, string inConditions) {
333 this.nciicBirthplaceCompareAsync(inLicense, inConditions, null);
334 }
335
336 /// <remarks/>
337 public void nciicBirthplaceCompareAsync(string inLicense, string inConditions, object userState) {
338 if ((this.nciicBirthplaceCompareOperationCompleted == null)) {
339 this.nciicBirthplaceCompareOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicBirthplaceCompareOperationCompleted);
340 }
341 this.InvokeAsync("nciicBirthplaceCompare", new object[] {
342 inLicense,
343 inConditions}, this.nciicBirthplaceCompareOperationCompleted, userState);
344 }
345
346 private void OnnciicBirthplaceCompareOperationCompleted(object arg) {
347 if ((this.nciicBirthplaceCompareCompleted != null)) {
348 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
349 this.nciicBirthplaceCompareCompleted(this, new nciicBirthplaceCompareCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
350 }
351 }
352
353 /// <remarks/>
354 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
355 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
356 public string nciicAddrExactSearch([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
357 object[] results = this.Invoke("nciicAddrExactSearch", new object[] {
358 inLicense,
359 inConditions});
360 return ((string)(results[0]));
361 }
362
363 /// <remarks/>
364 public System.IAsyncResult BeginnciicAddrExactSearch(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
365 return this.BeginInvoke("nciicAddrExactSearch", new object[] {
366 inLicense,
367 inConditions}, callback, asyncState);
368 }
369
370 /// <remarks/>
371 public string EndnciicAddrExactSearch(System.IAsyncResult asyncResult) {
372 object[] results = this.EndInvoke(asyncResult);
373 return ((string)(results[0]));
374 }
375
376 /// <remarks/>
377 public void nciicAddrExactSearchAsync(string inLicense, string inConditions) {
378 this.nciicAddrExactSearchAsync(inLicense, inConditions, null);
379 }
380
381 /// <remarks/>
382 public void nciicAddrExactSearchAsync(string inLicense, string inConditions, object userState) {
383 if ((this.nciicAddrExactSearchOperationCompleted == null)) {
384 this.nciicAddrExactSearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicAddrExactSearchOperationCompleted);
385 }
386 this.InvokeAsync("nciicAddrExactSearch", new object[] {
387 inLicense,
388 inConditions}, this.nciicAddrExactSearchOperationCompleted, userState);
389 }
390
391 private void OnnciicAddrExactSearchOperationCompleted(object arg) {
392 if ((this.nciicAddrExactSearchCompleted != null)) {
393 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
394 this.nciicAddrExactSearchCompleted(this, new nciicAddrExactSearchCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
395 }
396 }
397
398 /// <remarks/>
399 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped
400 )]
401 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
402 public string nciicCheck([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
403 object[] results = this.Invoke("nciicCheck", new object[] {
404 inLicense,
405 inConditions});
406 return ((string)(results[0]));
407 }
408
409 /// <remarks/>
410 public System.IAsyncResult BeginnciicCheck(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
411 return this.BeginInvoke("nciicCheck", new object[] {
412 inLicense,
413 inConditions}, callback, asyncState);
414 }
415
416 /// <remarks/>
417 public string EndnciicCheck(System.IAsyncResult asyncResult) {
418 object[] results = this.EndInvoke(asyncResult);
419 return ((string)(results[0]));
420 }
421
422 /// <remarks/>
423 public void nciicCheckAsync(string inLicense, string inConditions) {
424 this.nciicCheckAsync(inLicense, inConditions, null);
425 }
426
427 /// <remarks/>
428 public void nciicCheckAsync(string inLicense, string inConditions, object userState) {
429 if ((this.nciicCheckOperationCompleted == null)) {
430 this.nciicCheckOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicCheckOperationCompleted);
431 }
432 this.InvokeAsync("nciicCheck", new object[] {
433 inLicense,
434 inConditions}, this.nciicCheckOperationCompleted, userState);
435 }
436
437 private void OnnciicCheckOperationCompleted(object arg) {
438 if ((this.nciicCheckCompleted != null)) {
439 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
440 this.nciicCheckCompleted(this, new nciicCheckCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
441 }
442 }
443
444 /// <remarks/>
445 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
446 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
447 public string nciicCompare([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
448 object[] results = this.Invoke("nciicCompare", new object[] {
449 inLicense,
450 inConditions});
451 return ((string)(results[0]));
452 }
453
454 /// <remarks/>
455 public System.IAsyncResult BeginnciicCompare(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
456 return this.BeginInvoke("nciicCompare", new object[] {
457 inLicense,
458 inConditions}, callback, asyncState);
459 }
460
461 /// <remarks/>
462 public string EndnciicCompare(System.IAsyncResult asyncResult) {
463 object[] results = this.EndInvoke(asyncResult);
464 return ((string)(results[0]));
465 }
466
467 /// <remarks/>
468 public void nciicCompareAsync(string inLicense, string inConditions) {
469 this.nciicCompareAsync(inLicense, inConditions, null);
470 }
471
472 /// <remarks/>
473 public void nciicCompareAsync(string inLicense, string inConditions, object userState) {
474 if ((this.nciicCompareOperationCompleted == null)) {
475 this.nciicCompareOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicCompareOperationCompleted);
476 }
477 this.InvokeAsync("nciicCompare", new object[] {
478 inLicense,
479 inConditions}, this.nciicCompareOperationCompleted, userState);
480 }
481
482 private void OnnciicCompareOperationCompleted(object arg) {
483 if ((this.nciicCompareCompleted != null)) {
484 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
485 this.nciicCompareCompleted(this, new nciicCompareCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
486 }
487 }
488
489 /// <remarks/>
490 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", ResponseNamespace="https://http://www.cnblogs.com/ /nciicGetCondition", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
491 [return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable=true)]
492 public string nciicCombineSearch([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inLicense, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string inConditions) {
493 object[] results = this.Invoke("nciicCombineSearch", new object[] {
494 inLicense,
495 inConditions});
496 return ((string)(results[0]));
497 }
498
499 /// <remarks/>
500 public System.IAsyncResult BeginnciicCombineSearch(string inLicense, string inConditions, System.AsyncCallback callback, object asyncState) {
501 return this.BeginInvoke("nciicCombineSearch", new object[] {
502 inLicense,
503 inConditions}, callback, asyncState);
504 }
505
506 /// <remarks/>
507 public string EndnciicCombineSearch(System.IAsyncResult asyncResult) {
508 object[] results = this.EndInvoke(asyncResult);
509 return ((string)(results[0]));
510 }
511
512 /// <remarks/>
513 public void nciicCombineSearchAsync(string inLicense, string inConditions) {
514 this.nciicCombineSearchAsync(inLicense, inConditions, null);
515 }
516
517 /// <remarks/>
518 public void nciicCombineSearchAsync(string inLicense, string inConditions, object userState) {
519 if ((this.nciicCombineSearchOperationCompleted == null)) {
520 this.nciicCombineSearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnnciicCombineSearchOperationCompleted);
521 }
522 this.InvokeAsync("nciicCombineSearch", new object[] {
523 inLicense,
524 inConditions}, this.nciicCombineSearchOperationCompleted, userState);
525 }
526
527 private void OnnciicCombineSearchOperationCompleted(object arg) {
528 if ((this.nciicCombineSearchCompleted != null)) {
529 System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
530 this.nciicCombineSearchCompleted(this, new nciicCombineSearchCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
531 }
532 }
533
534 /// <remarks/>
535 public new void CancelAsync(object userState) {
536 base.CancelAsync(userState);
537 }
538 }
539
540 /// <remarks/>
541 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
542 public delegate void nciicDiscernCompletedEventHandler(object sender, nciicDiscernCompletedEventArgs e);
543
544 /// <remarks/>
545 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
546 [System.Diagnostics.DebuggerStepThroughAttribute()]
547 [System.ComponentModel.DesignerCategoryAttribute("code")]
548 public partial class nciicDiscernCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
549
550 private object[] results;
551
552 internal nciicDiscernCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
553 base(exception, cancelled, userState) {
554 this.results = results;
555 }
556
557 /// <remarks/>
558 public string Result {
559 get {
560 this.RaiseExceptionIfNecessary();
561 return ((string)(this.results[0]));
562 }
563 }
564 }
565
566 /// <remarks/>
567 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
568 public delegate void nciicCheckChinaCompletedEventHandler(object sender, nciicCheckChinaCompletedEventArgs e);
569
570 /// <remarks/>
571 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
572 [System.Diagnostics.DebuggerStepThroughAttribute()]
573 [System.ComponentModel.DesignerCategoryAttribute("code")]
574 public partial class nciicCheckChinaCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
575
576 private object[] results;
577
578 internal nciicCheckChinaCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
579 base(exception, cancelled, userState) {
580 this.results = results;
581 }
582
583 /// <remarks/>
584 public string Result {
585 get {
586 this.RaiseExceptionIfNecessary();
587 return ((string)(this.results[0]));
588 }
589 }
590 }
591
592 /// <remarks/>
593 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
594 public delegate void CallnciicGetConditionCompletedEventHandler(object sender, CallnciicGetConditionCompletedEventArgs e);
595
596 /// <remarks/>
597 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
598 [System.Diagnostics.DebuggerStepThroughAttribute()]
599 [System.ComponentModel.DesignerCategoryAttribute("code")]
600 public partial class CallnciicGetConditionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
601
602 private object[] results;
603
604 internal CallnciicGetConditionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
605 base(exception, cancelled, userState) {
606 this.results = results;
607 }
608
609 /// <remarks/>
610 public string Result {
611 get {
612 this.RaiseExceptionIfNecessary();
613 return ((string)(this.results[0]));
614 }
615 }
616 }
617
618 /// <remarks/>
619 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
620 public delegate void nciicExactSearchCompletedEventHandler(object sender, nciicExactSearchCompletedEventArgs e);
621
622 /// <remarks/>
623 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
624 [System.Diagnostics.DebuggerStepThroughAttribute()]
625 [System.ComponentModel.DesignerCategoryAttribute("code")]
626 public partial class nciicExactSearchCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
627
628 private object[] results;
629
630 internal nciicExactSearchCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
631 base(exception, cancelled, userState) {
632 this.results = results;
633 }
634
635 /// <remarks/>
636 public string Result {
637 get {
638 this.RaiseExceptionIfNecessary();
639 return ((string)(this.results[0]));
640 }
641 }
642 }
643
644 /// <remarks/>
645 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
646 public delegate void nciicCourtCompletedEventHandler(object sender, nciicCourtCompletedEventArgs e);
647
648 /// <remarks/>
649 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
650 [System.Diagnostics.DebuggerStepThroughAttribute()]
651 [System.ComponentModel.DesignerCategoryAttribute("code")]
652 public partial class nciicCourtCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
653
654 private object[] results;
655
656 internal nciicCourtCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
657 base(exception, cancelled, userState) {
658 this.results = results;
659 }
660
661 /// <remarks/>
662 public string Result {
663 get {
664 this.RaiseExceptionIfNecessary();
665 return ((string)(this.results[0]));
666 }
667 }
668 }
669
670 /// <remarks/>
671 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
672 public delegate void nciicBirthplaceCompareCompletedEventHandler(object sender, nciicBirthplaceCompareCompletedEventArgs e);
673
674 /// <remarks/>
675 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
676 [System.Diagnostics.DebuggerStepThroughAttribute()]
677 [System.ComponentModel.DesignerCategoryAttribute("code")]
678 public partial class nciicBirthplaceCompareCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
679
680 private object[] results;
681
682 internal nciicBirthplaceCompareCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
683 base(exception, cancelled, userState) {
684 this.results = results;
685 }
686
687 /// <remarks/>
688 public string Result {
689 get {
690 this.RaiseExceptionIfNecessary();
691 return ((string)(this.results[0]));
692 }
693 }
694 }
695
696 /// <remarks/>
697 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
698 public delegate void nciicAddrExactSearchCompletedEventHandler(object sender, nciicAddrExactSearchCompletedEventArgs e);
699
700 /// <remarks/>
701 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
702 [System.Diagnostics.DebuggerStepThroughAttribute()]
703 [System.ComponentModel.DesignerCategoryAttribute("code")]
704 public partial class nciicAddrExactSearchCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
705
706 private object[] results;
707
708 internal nciicAddrExactSearchCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
709 base(exception, cancelled, userState) {
710 this.results = results;
711 }
712
713 /// <remarks/>
714 public string Result {
715 get {
716 this.RaiseExceptionIfNecessary();
717 return ((string)(this.results[0]));
718 }
719 }
720 }
721
722 /// <remarks/>
723 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
724 public delegate void nciicCheckCompletedEventHandler(object sender, nciicCheckCompletedEventArgs e);
725
726 /// <remarks/>
727 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
728 [System.Diagnostics.DebuggerStepThroughAttribute()]
729 [System.ComponentModel.DesignerCategoryAttribute("code")]
730 public partial class nciicCheckCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
731
732 private object[] results;
733
734 internal nciicCheckCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
735 base(exception, cancelled, userState) {
736 this.results = results;
737 }
738
739 /// <remarks/>
740 public string Result {
741 get {
742 this.RaiseExceptionIfNecessary();
743 return ((string)(this.results[0]));
744 }
745 }
746 }
747
748 /// <remarks/>
749 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
750 public delegate void nciicCompareCompletedEventHandler(object sender, nciicCompareCompletedEventArgs e);
751
752 /// <remarks/>
753 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
754 [System.Diagnostics.DebuggerStepThroughAttribute()]
755 [System.ComponentModel.DesignerCategoryAttribute("code")]
756 public partial class nciicCompareCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
757
758 private object[] results;
759
760 internal nciicCompareCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
761 base(exception, cancelled, userState) {
762 this.results = results;
763 }
764
765 /// <remarks/>
766 public string Result {
767 get {
768 this.RaiseExceptionIfNecessary();
769 return ((string)(this.results[0]));
770 }
771 }
772 }
773
774 /// <remarks/>
775 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
776 public delegate void nciicCombineSearchCompletedEventHandler(object sender, nciicCombineSearchCompletedEventArgs e);
777
778 /// <remarks/>
779 [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
780 [System.Diagnostics.DebuggerStepThroughAttribute()]
781 [System.ComponentModel.DesignerCategoryAttribute("code")]
782 public partial class nciicCombineSearchCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
783
784 private object[] results;
785
786 internal nciicCombineSearchCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
787 base(exception, cancelled, userState) {
788 this.results = results;
789 }
790
791 /// <remarks/>
792 public string Result {
793 get {
794 this.RaiseExceptionIfNecessary();
795 return ((string)(this.results[0]));
796 }
797 }
798 }
799 }
800
801
有了这个类,最后一步就是实现调取数据了,
2 {
3 //授权文件内容建议以后放在数据库或是文件里而且要加密
4 string inliance = @"文件内容";
5
6 //生成的WSDL类()
7 nciicGetCondition objText = new nciicGetCondition();
8
9 //基础URL建议加密和写在文件中
10 objText.Url = "https://www.cnblogs.com/ ";
11
12 //编码
13 objText.RequestEncoding = Encoding.UTF8;
14
15 //创建证书文件
16 X509Certificate objx509 = new X509Certificate(Application.StartupPath + "\\tingting.cer");
17
18 //证书
19 objText.ClientCertificates.Add(objx509);
20
21 //方式可有可无
22 objText.UserAgent = "Client Cert Sample";
23
24 //读XML文件
25 string inConditions = File.ReadAllText(Application.StartupPath + "\\XMLFile1.xml");
26
27 //Text文件
28 this.richTextBox1.Text = objText.nciicCheck(inliance, inConditions);
29
30 }
31 catch (Exception ex)
32 {
33 MessageBox.Show(ex.Message);
34 }
35
到这里我们已经和服务器沟通上了。好,到此,获取数据ing……