BaseSystem.cs
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.ComponentModel;
using System.Data;
using System.Net;
namespace BizFacade
{
using Comm;
/// <summary>
/// BaseSystem ժҪ˵
/// </summary>
public class BaseSystem
{
protected System.Net.CookieContainer Cookies;
protected System.Uri webServiceUri;
public BaseSystem()
{
}
protected void SetCookiesUriHaveCookie(System.Web.Services.Protocols.SoapHttpClientProtocol ws)
{
if (Cookies == null)
Cookies = new System.Net.CookieContainer();
ws.CookieContainer = Cookies;
ws.Timeout = -1;
}
protected void SetCookiesUri(System.Web.Services.Protocols.SoapHttpClientProtocol ws)
{
if (Cookies == null)
Cookies = new System.Net.CookieContainer();
ws.CookieContainer = Cookies;
ws.Timeout = -1;
// Set the Url on the ws
if (webServiceUri == null)
webServiceUri = new Uri(ws.Url);
else
ws.Url = webServiceUri.AbsoluteUri;
}
protected bool DealRedirect(WebException we, System.Web.Services.Protocols.SoapHttpClientProtocol ws)
{
// We need an HttpWebResponse if we expect to
// check the HTTP status code.
if (we.Response.GetType() == typeof(HttpWebResponse))
{
HttpWebResponse HttpResponse;
HttpResponse = (HttpWebResponse)we.Response;
if (HttpResponse.StatusCode == HttpStatusCode.Found)
{
// This is a "302 Found" response. Prompt the user
// to see if it is okay to redirect.
string str = HttpResponse.Headers["Location"];
webServiceUri = new Uri(webServiceUri, HttpResponse.Headers["Location"]);
return true;
}
}
return false;
}
public bool TestServiceUrl(string ServiceUrl)
{
BaseSvc.BaseSvc ws = new BaseSvc.BaseSvc();
ws.Url = ServiceUrl;
return ws.TestServiceUrl();
}
public string GetServiceUrl()
{
BaseSvc.BaseSvc ws = new BaseSvc.BaseSvc();
return ws.Url;
}
public string GetServiceVersion()
{
BaseSvc.BaseSvc ws = new BaseSvc.BaseSvc();
return ws.GetServiceVersion();
}
}
}