WCF_CLIENT - клиент Web-сервиса (вторая версия)
Я довольно долго и успешно пользовался микрософтовскими клиентами к web-сервисам в стиле NET 2.0. Последний (на момент написания этой заметки) мой электронный магазин на стандартном микрософтовском клиенте (в стиле NET 2.0) лежит тут http://emex.vb-net.com/. Это фактически онлайновый намордник на web-сервис, предоставляемый сайтом http://emex.ru/. Основной функционал этого магазина скрыт конечно не в части, видимой пользователелю, а в админке.
Но с точки зрения клиента web-сервиса в стиле .NET 2.0 это всего навсего примерно вот такой код:
1: Try
2: Dim CacheArr As New Collections.Generic.List(Of Global.ru.emex.ws.DetailItem)
3: Button1.Enabled = False
4: Dim List As Global.ru.emex.ws.DetailItem()
5: Using X As New Global.ru.emex.ws.EmExService
6: If DropDownList1.SelectedItem.Value = "Любой" Then
7: List = X.FindDetailAdv(System.Configuration.ConfigurationManager.AppSettings("EmexLogin"), System.Configuration.ConfigurationManager.AppSettings("EmexPass"), "", TextBox1.Text, True)
8: Else
9: List = X.FindDetailAdv(System.Configuration.ConfigurationManager.AppSettings("EmexPass"), System.Configuration.ConfigurationManager.AppSettings("EmexLogin"), DropDownList1.SelectedItem.Value, TextBox1.Text, True)
10: End If
11: If List IsNot Nothing Then
12: If List.Count > 0 Then
13: NoDetails.Visible = False
14: 'записали в кеш результат отбора
15: For Each Y As Global.ru.emex.ws.DetailItem In List
16: CacheArr.Add(Y)
17: Next
18: Session("CacheArr") = CacheArr
19: DataList1.DataSource = List
20: DataList1.DataBind()
21: Else
22: NoDetails.Visible = True
23: End If
24: End If
25: End Using
26: Catch ex As Exception
27: Lerr1.Text = ex.Message
28: Finally
29: Button1.Enabled = True
30: End Try
При использовании стандартной микрософтовской WCF-обвязки в стиле NET 3.5 добавляется всего лишь одна строка кода и меняется строка вызова сервиса:
+ Dim Service1 As New Wcf_Client_EmExService.EmExServiceSoapClient("EmExServiceSoap")
7: List = Service1.FindDetailAdv(System.Configuration.ConfigurationManager.AppSettings("EmexLogin"), System.Configuration.ConfigurationManager.AppSettings("EmexPass"), "", TextBox1.Text, True)
При добавлении к проекту Service Reference взамен Web-reference меняется и внешний вид проекта.
И я бы, наверное, пользовался бы и дальше этим микрософтовским сервисом пока мне не потребовалось обратиться к web-сервисам, сделанным на JAX-WS. На нем, видимо, сделан даже популярнейший российский платежный сервис http://www.assist.ru/.
И здесь выяснилось пару интересных моментов. Я обнаружил, что отправляя запрос стандартным WCF-клиентом, он не добавляет перед SOAP-конвертом тега <?xml - из-за чего сервис Ассиста не отвечает. Это хорошо видно на следующих скринах - как только я добавил тег <?xml - сервис ассиста стал отвечать:
Вторая проблема, которая у меня возникла - это логирование. Более ли менее бепроблемно можно наладить логгирование запросов в WCF только для тела запроса. Можно сделать вот такой класс:
1: Imports Microsoft.VisualBasic
2:
3: Public Class MyBehavior
4: Implements ServiceModel.Description.IEndpointBehavior
5:
6: Public Sub AddBindingParameters(ByVal endpoint As System.ServiceModel.Description.ServiceEndpoint, ByVal bindingParameters As System.ServiceModel.Channels.BindingParameterCollection) Implements System.ServiceModel.Description.IEndpointBehavior.AddBindingParameters
7:
8: End Sub
9:
10: Public Sub ApplyClientBehavior(ByVal endpoint As System.ServiceModel.Description.ServiceEndpoint, ByVal clientRuntime As System.ServiceModel.Dispatcher.ClientRuntime) Implements System.ServiceModel.Description.IEndpointBehavior.ApplyClientBehavior
11: Dim inspector As New MyInspector()
12: clientRuntime.MessageInspectors.Add(inspector)
13: End Sub
14:
15: Public Sub ApplyDispatchBehavior(ByVal endpoint As System.ServiceModel.Description.ServiceEndpoint, ByVal endpointDispatcher As System.ServiceModel.Dispatcher.EndpointDispatcher) Implements System.ServiceModel.Description.IEndpointBehavior.ApplyDispatchBehavior
16:
17: End Sub
18:
19: Public Sub Validate(ByVal endpoint As System.ServiceModel.Description.ServiceEndpoint) Implements System.ServiceModel.Description.IEndpointBehavior.Validate
20:
21: End Sub
22: End Class
23:
24:
25: Public Class MyInspector
26: Implements ServiceModel.Dispatcher.IClientMessageInspector
27:
28: Public Sub AfterReceiveReply(ByRef reply As System.ServiceModel.Channels.Message, ByVal correlationState As Object) Implements System.ServiceModel.Dispatcher.IClientMessageInspector.AfterReceiveReply
29: Dim Dump As String = ""
30: Try
31: Dim reader As System.Xml.XmlDictionaryReader = reply.GetReaderAtBodyContents()
32: While Not reader.EOF
33: Dump &= reader.ReadOuterXml()
34: End While
35: reader.Close()
36: Catch ex As System.Exception
37: 'This message cannot support the operation because it has been read.
38: End Try
39: End Sub
40:
41: Public Function BeforeSendRequest(ByRef request As System.ServiceModel.Channels.Message, ByVal channel As System.ServiceModel.IClientChannel) As Object Implements System.ServiceModel.Dispatcher.IClientMessageInspector.BeforeSendRequest
42: Try
43: Dim newMessage As System.ServiceModel.Channels.Message
44: Dim msgbuf As System.ServiceModel.Channels.MessageBuffer = request.CreateBufferedCopy(Integer.MaxValue)
45: Dim tmpMessage As System.ServiceModel.Channels.Message = msgbuf.CreateMessage
46: Dim document = New System.Xml.XmlDocument()
47: '
48: Using dictreader = tmpMessage.GetReaderAtBodyContents()
49: document.Load(dictreader)
50: End Using
51: '
52: 'Здесь уже можно сохранить документ в базу
53: 'А можно сформировать новое сообщения
54: '
55: Dim stream = New IO.MemoryStream()
56: Using writer = System.Xml.XmlWriter.Create(stream)
57: document.Save(writer)
58: writer.Flush()
59: stream.Position = 0
60: Dim reader = System.Xml.XmlReader.Create(stream)
61: newMessage = System.ServiceModel.Channels.Message.CreateMessage(request.Version, Nothing, reader)
62: newMessage.Headers.CopyHeadersFrom(request)
63: newMessage.Properties.CopyProperties(request.Properties)
64: End Using
65: request = newMessage
66: Return Nothing
67: Catch ex As Exception
68: '
69: End Try
70: End Function
71: End Class
И подключить его к WCF-клиенту.
8: Service1.Endpoint.Behaviors.Add(New MyBehavior)
Однако к полному трафику (с учетом заголовка SOAP) подступиться сложнее. Ведь как правило он зашифрован (на скринах видно как незафрованный трафик Emex'а просмотреть легко, но у обращений к Assist'у легко увидеть только тело запроса):
Поэтому для логгирования приходится пользоваться только теми возможностями, которые заведомо встроены в WCF. Для этого придется разобраться в нескольких секциях конфигурации (для примера ниже показано подключение одного стандартного листенера и двух моих собственных, с именами классов WcfListener1 (namespace vbnet2009) из сборки WcfListeners, Version=1.0.0.0 и одного стандратного листенера ServiceModelTraceListener из сборки System.Diagnostics.XmlWriterTraceListener:
1: <system.diagnostics>
2: <sources>
3: <source name="System.ServiceModel.MessageLogging" switchValue="Verbose,ActivityTracing" >
4: <listeners>
5: <add name="WcfListener" initializeData="c:\messages_svclog4.txt" type="vbnet2009.WcfListener, WcfListeners, Version=1.0.0.0"
6: traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
7: <filter type="" />
8: </add>
9: <add name="WcfListener1" initializeData="c:\messages_svclog5.txt" type="vbnet2009.WcfListener1, WcfListeners, Version=1.0.0.0"
10: traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
11: <filter type="" />
12: </add>
13: </listeners>
14: </source>
15: <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
16: <listeners>
17: <add type="vbnet2009.WcfListener1, WcfListeners, Version=1.0.0.0" name="WcfListener1">
18: <filter type="" />
19: </add>
20: <add type="vbnet2009.WcfListener, WcfListeners, Version=1.0.0.0" name="WcfListener">
21: <filter type="" />
22: </add>
23: <add name="ServiceModelTraceListener">
24: <filter type="" />
25: </add>
26: </listeners>
27: </source>
28: </sources>
29: <sharedListeners>
30: <add initializeData="c:\messages_svclog6.txt"
31: type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
32: name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
33: <filter type="" />
34: </add>
35: </sharedListeners>
36: </system.diagnostics>
...
149: <system.serviceModel>
150: <diagnostics>
151: <messageLogging
152: logEntireMessage="true"
153: logMalformedMessages="true"
154: logMessagesAtServiceLevel="true"
155: logMessagesAtTransportLevel="true"
156: maxMessagesToLog="3000"
157: maxSizeOfMessageToLog="2000"/>
158: </diagnostics>
....
Стандартный листенер ведет журнал в файлы и микрософт поставляет свой просмотровщик этого файла (хотя обычным XML инструментом типа Altova журнал трассировки просматривать даже удобнее). Но в принципе, в комплектацию WCF кроме просмотровщика логов также входит построитель вышеуказанной конфигурации листенеров:
Увы, все это помогает мало, когда надо сделать нормальный трассировщик запросов, который будет выводить трассу на WEB-формы. Потратив запланированное на эту задачу время - я так и не сумел понять как мне подколючить свой трассировщик, чтобы он трассировал запросы с учетом SOAP-конферта и ничего при этом не писал на диск.
Но хуже технологических возможностей по подключению трассировщика было то, что я собственно увидел в журналах WCF - это многочисленные записи падения по разным причинам микрософтовского WCF-клиента:
Зачем мне такой WCF-клиент? Даже если его будет вруливать мне сам дьявол (в лице Билла Гейтса)?
К сказанному остается добавить, что я многократно сталкивался - когда WSDL часто составляют вручную (с некоторыми незначительными погрешностями), из-за чего импорт его обычным способом (через форму Add Service Reference) становится невозможным - нет даже никаких сообщений об ошибках. Подробнее сообщения об ошибках можно посмотреть при помощи SVCUTIL - но что с того? Использовать стандартный микрософтовский клиент Windows Communication Foundation уже не получится никак - даже если не нужна трассировка, перекодировка, обращение к web-сервисам других платформ и прочее на что он вообще неспособен.
Все сказанное и привело меня к отказу от стандартного микрософтовского клиента Windows Communication Foundation и замене его несколькими строчками собственного кода с более широкими возможностями чем WCF-клиент.
Вызывается мой клиент предельно просто (для примера вот вызов для курсов валют Assist):
1: Dim RequestXML As String = _
2: "<?xml version='1.0' encoding='windows-1251' standalone='no'?>" & vbCrLf & _
3: "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>" & vbCrLf & _
4: "<s:Body>" & vbCrLf & _
5: "<q1:GetRate xmlns:q1='http://www.assist.ru/message/'>" & vbCrLf & _
6: "<shop_id xsi:type='xsd:int' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns=''>" & System.Configuration.ConfigurationManager.AppSettings("AssistShop_id") & "</shop_id>" & vbCrLf & _
7: "<login xsi:type='xsd:string' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns=''>" & System.Configuration.ConfigurationManager.AppSettings("AssistLogin") & "</login>" & vbCrLf & _
8: "<password xsi:type='xsd:string' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns=''>" & System.Configuration.ConfigurationManager.AppSettings("AssistPassword") & "</password>" & vbCrLf & _
9: "<currency xsi:type='xsd:string' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns=''>USD</currency>" & vbCrLf & _
10: "<date xsi:type='xsd:string' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns=''>" & Now.ToShortDateString & "</date>" & vbCrLf & _
11: "</q1:GetRate>" & vbCrLf & _
12: "</s:Body>" & vbCrLf & _
13: "</s:Envelope>"
14:
15: Dim ResponseXML As String = VBNET2009.Wcf_Client.PostRequest_ASCII(VBNET2009.Wcf_Client.PostRequestEncode.ASCII, "https://secure.assist.ru/rate/rateusd.cfm?format=4", RequestXML)
16: Dim NameSpaceParcer As New VBNET2009.ParceNamespace(ResponseXML)
17: Dim Result As System.Xml.XmlNode = NameSpaceParcer.XML.SelectSingleNode("/SOAP-ENV:Envelope/SOAP-ENV:Body/ASS-NS:GetRateResponse/return/rate", NameSpaceParcer.NamespaceManager)
18:
19: Lerr1.Text = Result.InnerText
Предполагается, что ответ будет примерно такой:
1: Dim SOAP_Response_Example As String = _
2: "<?xml version='1.0' encoding='windows-1251' standalone='no'?>" & _
3: "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" " & _
4: "SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" " & _
5: "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " & _
6: "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" >" & _
7: "<SOAP-ENV:Body SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" & _
8: "<ASS-NS:GetRateResponse xmlns:ASS-NS=""http://www.assist.ru/message/"">" & _
9: "<return xmlns:si=""http://www.assist.ru/type/"" xsi:type=""si:SOAPStruct"">" & _
10: "<currency xsi:type=""xsd:string"">USD</currency>" & _
11: "<date xsi:type=""xsd:string"">24.09.2010</date>" & _
12: "<rate xsi:type=""xsd:string"">31.0031</rate>" & _
13: "</return>" & _
14: "</ASS-NS:GetRateResponse>" & _
15: "</SOAP-ENV:Body>" & _
16: "</SOAP-ENV:Envelope>"
И вот собственно код моего клиента WCF-сервиса. Он состоит из (почти) полиморфной функции, которая отсылает POST в различных кодировках (ее легко и переделать) и вторая часть состоит в сборе NameSpace'ов из ответа сервиса. Когда я понял что этого кода нет в библиотеке .NET - я был просто в шоке. Вручную выковыривать неймспейсы из ответа? Увольте от такого счастья.
Поэтому я решил включить функцию для сбора неймспейсов в SOAP-ответе свою библиотеку, замещающую микрософтовский WCF-клиент (Класс ParceNamespace - это второй функциональной фрагмент моего кода).
1: Public Class Wcf_Client
2:
3: Public Enum GetEncode
4: ASCII = 1
5: UTF7 = 2
6: UTF8 = 3
7: UTF16 = 4
8: UTF32 = 5
9: End Enum
10:
11: Public Enum PostEncode
12: ASCII_Windows1251 = 1
13: UTF8 = 2
14: UTF16 = 3
15: ISO_8859_5 = 4
16: End Enum
17:
18: 'редирект с POST-параметрами
19: Public Shared Sub PostRedirect(ByVal Coding As PostEncode, ByVal URL As String, _
20: Optional ByVal PostName1 As String = "", Optional ByVal PostValue1 As String = "", _
21: Optional ByVal PostName2 As String = "", Optional ByVal PostValue2 As String = "", _
22: Optional ByVal PostName3 As String = "", Optional ByVal PostValue3 As String = "", _
23: Optional ByVal PostName4 As String = "", Optional ByVal PostValue4 As String = "", _
24: Optional ByVal PostName5 As String = "", Optional ByVal PostValue5 As String = "", _
25: Optional ByVal PostName6 As String = "", Optional ByVal PostValue6 As String = "", _
26: Optional ByVal PostName7 As String = "", Optional ByVal PostValue7 As String = "", _
27: Optional ByVal PostName8 As String = "", Optional ByVal PostValue8 As String = "", _
28: Optional ByVal PostName9 As String = "", Optional ByVal PostValue9 As String = "", _
29: Optional ByVal PostName10 As String = "", Optional ByVal PostValue10 As String = "", _
30: Optional ByVal PostName11 As String = "", Optional ByVal PostValue11 As String = "", _
31: Optional ByVal PostName12 As String = "", Optional ByVal PostValue12 As String = "", _
32: Optional ByVal PostName13 As String = "", Optional ByVal PostValue13 As String = "", _
33: Optional ByVal PostName14 As String = "", Optional ByVal PostValue14 As String = "", _
34: Optional ByVal PostName15 As String = "", Optional ByVal PostValue15 As String = "", _
35: Optional ByVal PostName16 As String = "", Optional ByVal PostValue16 As String = "", _
36: Optional ByVal PostName17 As String = "", Optional ByVal PostValue17 As String = "", _
37: Optional ByVal PostName18 As String = "", Optional ByVal PostValue18 As String = "", _
38: Optional ByVal PostName19 As String = "", Optional ByVal PostValue19 As String = "", _
39: Optional ByVal PostName20 As String = "", Optional ByVal PostValue20 As String = "")
40: Dim POST_Data As String = PreparePostForm(PostName1, PostValue1, _
41: PostName2, PostValue2, _
42: PostName3, PostValue3, _
43: PostName4, PostValue4, _
44: PostName5, PostValue5, _
45: PostName6, PostValue6, _
46: PostName7, PostValue7, _
47: PostName8, PostValue8, _
48: PostName9, PostValue9, _
49: PostName10, PostValue10, _
50: PostName11, PostValue11, _
51: PostName12, PostValue12, _
52: PostName13, PostValue13, _
53: PostName14, PostValue14, _
54: PostName15, PostValue15, _
55: PostName16, PostValue16, _
56: PostName17, PostValue17, _
57: PostName18, PostValue18, _
58: PostName19, PostValue19, _
59: PostName20, PostValue20)
60: PostRedirectStr(Coding, URL, POST_Data)
61: End Function
62:
63: 'Редирект браузера методом POST (молча, ошибки обрабатываются извне этого кода)
64: Public Shared Sub PostRedirectStr(ByVal Coding As PostEncode, ByVal URL As String, ByVal POST_Data As String)
65: Dim Charset As String = ""
66: If Coding = PostEncode.ASCII_Windows1251 Then
67: Charset = "Windows-1251"
68: ElseIf Coding = PostEncode.ISO_8859_5 Then
69: Charset = "ISO-8859-5"
70: ElseIf Coding = PostEncode.UTF8 Then
71: Charset = "UTF-8"
72: ElseIf Coding = PostEncode.UTF16 Then
73: Charset = "UTF-16"
74: End If
75: '
76: Dim Str1 As String = "<html>" & vbCrLf & _
77: "<head>" & vbCrLf & _
78: "<meta http-equiv='Content-Type' content='text/html; charset=" & Charset & "'>" & vbCrLf & _
79: "</head>" & vbCrLf & _
80: "<body>" & vbCrLf & _
81: "<form name='vbnet2009' action='" & URL & "' method='post' accept-charset='" & Charset & "'>" & vbCrLf & _
82: POST_Data & vbCrLf & _
83: "<input type='submit' style='width:1px;height:1px;' />" & vbCrLf & _
84: "</form>" & vbCrLf & _
85: "<script language='javascript' type='text/javascript'>" & vbCrLf & _
86: "document.forms[0].submit();" & vbCrLf & _
87: "</script>" & vbCrLf & _
88: "</body>" & vbCrLf & _
89: "</html>"
90: '
91: Dim byteArray As Byte()
92: If Coding = PostEncode.ASCII_Windows1251 Then
93: byteArray = System.Text.Encoding.GetEncoding("Windows-1251").GetBytes(Str1)
94: HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("Windows-1251")
95: ElseIf Coding = PostEncode.ISO_8859_5 Then
96: byteArray = System.Text.Encoding.GetEncoding("ISO-8859-5").GetBytes(Str1)
97: HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-5")
98: ElseIf Coding = PostEncode.UTF8 Then
99: byteArray = System.Text.Encoding.UTF8.GetBytes(Str1)
100: HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8
101: ElseIf Coding = PostEncode.UTF16 Then
102: byteArray = System.Text.Encoding.Unicode.GetBytes(Str1)
103: HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode
104: End If
105: HttpContext.Current.Response.Charset = Charset
106: HttpContext.Current.Response.BinaryWrite(byteArray)
107: End Sub
108:
109:
110: 'страничка с парметрами POST считывается в переменную
111: Public Shared Function PostRequest(ByVal Coding As GetEncode, ByVal URL As String, _
112: Optional ByVal PostName1 As String = "", Optional ByVal PostValue1 As String = "", _
113: Optional ByVal PostName2 As String = "", Optional ByVal PostValue2 As String = "", _
114: Optional ByVal PostName3 As String = "", Optional ByVal PostValue3 As String = "", _
115: Optional ByVal PostName4 As String = "", Optional ByVal PostValue4 As String = "", _
116: Optional ByVal PostName5 As String = "", Optional ByVal PostValue5 As String = "", _
117: Optional ByVal PostName6 As String = "", Optional ByVal PostValue6 As String = "", _
118: Optional ByVal PostName7 As String = "", Optional ByVal PostValue7 As String = "", _
119: Optional ByVal PostName8 As String = "", Optional ByVal PostValue8 As String = "", _
120: Optional ByVal PostName9 As String = "", Optional ByVal PostValue9 As String = "", _
121: Optional ByVal PostName10 As String = "", Optional ByVal PostValue10 As String = "", _
122: Optional ByVal PostName11 As String = "", Optional ByVal PostValue11 As String = "", _
123: Optional ByVal PostName12 As String = "", Optional ByVal PostValue12 As String = "", _
124: Optional ByVal PostName13 As String = "", Optional ByVal PostValue13 As String = "", _
125: Optional ByVal PostName14 As String = "", Optional ByVal PostValue14 As String = "", _
126: Optional ByVal PostName15 As String = "", Optional ByVal PostValue15 As String = "", _
127: Optional ByVal PostName16 As String = "", Optional ByVal PostValue16 As String = "", _
128: Optional ByVal PostName17 As String = "", Optional ByVal PostValue17 As String = "", _
129: Optional ByVal PostName18 As String = "", Optional ByVal PostValue18 As String = "", _
130: Optional ByVal PostName19 As String = "", Optional ByVal PostValue19 As String = "", _
131: Optional ByVal PostName20 As String = "", Optional ByVal PostValue20 As String = "")
132: Dim POST_Data As String = PreparePostParm(PostName1, PostValue1, _
133: PostName2, PostValue2, _
134: PostName3, PostValue3, _
135: PostName4, PostValue4, _
136: PostName5, PostValue5, _
137: PostName6, PostValue6, _
138: PostName7, PostValue7, _
139: PostName8, PostValue8, _
140: PostName9, PostValue9, _
141: PostName10, PostValue10, _
142: PostName11, PostValue11, _
143: PostName12, PostValue12, _
144: PostName13, PostValue13, _
145: PostName14, PostValue14, _
146: PostName15, PostValue15, _
147: PostName16, PostValue16, _
148: PostName17, PostValue17, _
149: PostName18, PostValue18, _
150: PostName19, PostValue19, _
151: PostName20, PostValue20)
152: Return PostRequestStr(Coding, URL, POST_Data)
153: End Function
154:
155: 'Запрос странички методом POST (молча, ошибки обрабатываются извне этого кода)
156: Public Shared Function PostRequestStr(ByVal Coding As GetEncode, ByVal URL As String, ByVal POST_Data As String, Optional ByVal ResponseEncoding As String = "windows-1251") As String
157: Dim byteArray As Byte()
158: If Coding = GetEncode.ASCII Then
159: byteArray = System.Text.Encoding.ASCII.GetBytes(POST_Data)
160: ElseIf Coding = GetEncode.UTF16 Then
161: byteArray = System.Text.Encoding.Unicode.GetBytes(POST_Data)
162: ElseIf Coding = GetEncode.UTF8 Then
163: byteArray = System.Text.Encoding.UTF8.GetBytes(POST_Data)
164: ElseIf Coding = GetEncode.UTF7 Then
165: byteArray = System.Text.Encoding.UTF7.GetBytes(POST_Data)
166: ElseIf Coding = GetEncode.UTF32 Then
167: byteArray = System.Text.Encoding.UTF32.GetBytes(POST_Data)
168: End If
169: '========== System.NotSupportedException The URI prefix is not recognized.
170: Dim request As Net.HttpWebRequest = Net.HttpWebRequest.Create(URL)
171: request.Method = "POST"
172: request.ContentType = "application/x-www-form-urlencoded"
173: request.ContentLength = byteArray.Length
174: '========== System.Net.WebExceptionStatus.Timeout Unable to connect to the remote server
175: Dim POST_Stream As IO.Stream = request.GetRequestStream()
176: POST_Stream.Write(byteArray, 0, byteArray.Length)
177: POST_Stream.Close()
178: '
179: 'ждем
180: '========== System.Net.WebException.Timeout
181: '========== System.Net.WebException = "The remote server returned an error: (404) Not Found."
182: Dim response As Net.HttpWebResponse = request.GetResponse()
183: Dim GET_Stream As IO.Stream = response.GetResponseStream()
184: Dim reader As IO.StreamReader
185: If Coding = GetEncode.ASCII Then
186: reader = New IO.StreamReader(GET_Stream, System.Text.ASCIIEncoding.GetEncoding(ResponseEncoding))
187: ElseIf Coding = GetEncode.UTF16 Then
188: reader = New IO.StreamReader(GET_Stream, System.Text.UnicodeEncoding.GetEncoding(ResponseEncoding))
189: ElseIf Coding = GetEncode.UTF8 Then
190: reader = New IO.StreamReader(GET_Stream, System.Text.UTF8Encoding.GetEncoding(ResponseEncoding))
191: ElseIf Coding = GetEncode.UTF7 Then
192: reader = New IO.StreamReader(GET_Stream, System.Text.UTF7Encoding.GetEncoding(ResponseEncoding))
193: ElseIf Coding = GetEncode.UTF32 Then
194: reader = New IO.StreamReader(GET_Stream, System.Text.UTF32Encoding.GetEncoding(ResponseEncoding))
195: End If
196: Dim HTML As String = reader.ReadToEnd
197: reader.Close()
198: GET_Stream.Close()
199: response.Close()
200: Return HTML
201: End Function
202:
203: Shared Function PreparePostParm(Optional ByVal PostName1 As String = "", Optional ByVal PostValue1 As String = "", _
204: Optional ByVal PostName2 As String = "", Optional ByVal PostValue2 As String = "", _
205: Optional ByVal PostName3 As String = "", Optional ByVal PostValue3 As String = "", _
206: Optional ByVal PostName4 As String = "", Optional ByVal PostValue4 As String = "", _
207: Optional ByVal PostName5 As String = "", Optional ByVal PostValue5 As String = "", _
208: Optional ByVal PostName6 As String = "", Optional ByVal PostValue6 As String = "", _
209: Optional ByVal PostName7 As String = "", Optional ByVal PostValue7 As String = "", _
210: Optional ByVal PostName8 As String = "", Optional ByVal PostValue8 As String = "", _
211: Optional ByVal PostName9 As String = "", Optional ByVal PostValue9 As String = "", _
212: Optional ByVal PostName10 As String = "", Optional ByVal PostValue10 As String = "", _
213: Optional ByVal PostName11 As String = "", Optional ByVal PostValue11 As String = "", _
214: Optional ByVal PostName12 As String = "", Optional ByVal PostValue12 As String = "", _
215: Optional ByVal PostName13 As String = "", Optional ByVal PostValue13 As String = "", _
216: Optional ByVal PostName14 As String = "", Optional ByVal PostValue14 As String = "", _
217: Optional ByVal PostName15 As String = "", Optional ByVal PostValue15 As String = "", _
218: Optional ByVal PostName16 As String = "", Optional ByVal PostValue16 As String = "", _
219: Optional ByVal PostName17 As String = "", Optional ByVal PostValue17 As String = "", _
220: Optional ByVal PostName18 As String = "", Optional ByVal PostValue18 As String = "", _
221: Optional ByVal PostName19 As String = "", Optional ByVal PostValue19 As String = "", _
222: Optional ByVal PostName20 As String = "", Optional ByVal PostValue20 As String = "") As String
223: Dim POST_Data As New Text.StringBuilder
224: If PostName20 <> "" Then
225: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
226: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
227: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
228: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
229: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
230: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
231: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
232: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
233: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
234: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
235: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
236: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
237: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
238: POST_Data.Append((PostName14) & "=" & (PostValue14) & "&")
239: POST_Data.Append((PostName15) & "=" & (PostValue15) & "&")
240: POST_Data.Append((PostName16) & "=" & (PostValue16) & "&")
241: POST_Data.Append((PostName17) & "=" & (PostValue17) & "&")
242: POST_Data.Append((PostName18) & "=" & (PostValue18) & "&")
243: POST_Data.Append((PostName19) & "=" & (PostValue19) & "&")
244: POST_Data.Append((PostName20) & "=" & (PostValue20))
245: ElseIf PostName19 <> "" Then
246: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
247: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
248: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
249: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
250: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
251: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
252: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
253: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
254: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
255: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
256: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
257: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
258: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
259: POST_Data.Append((PostName14) & "=" & (PostValue14) & "&")
260: POST_Data.Append((PostName15) & "=" & (PostValue15) & "&")
261: POST_Data.Append((PostName16) & "=" & (PostValue16) & "&")
262: POST_Data.Append((PostName17) & "=" & (PostValue17) & "&")
263: POST_Data.Append((PostName18) & "=" & (PostValue18) & "&")
264: POST_Data.Append((PostName19) & "=" & (PostValue19))
265: ElseIf PostName18 <> "" Then
266: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
267: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
268: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
269: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
270: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
271: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
272: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
273: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
274: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
275: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
276: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
277: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
278: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
279: POST_Data.Append((PostName14) & "=" & (PostValue14) & "&")
280: POST_Data.Append((PostName15) & "=" & (PostValue15) & "&")
281: POST_Data.Append((PostName16) & "=" & (PostValue16) & "&")
282: POST_Data.Append((PostName17) & "=" & (PostValue17) & "&")
283: POST_Data.Append((PostName18) & "=" & (PostValue18))
284: ElseIf PostName17 <> "" Then
285: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
286: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
287: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
288: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
289: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
290: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
291: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
292: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
293: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
294: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
295: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
296: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
297: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
298: POST_Data.Append((PostName14) & "=" & (PostValue14) & "&")
299: POST_Data.Append((PostName15) & "=" & (PostValue15) & "&")
300: POST_Data.Append((PostName16) & "=" & (PostValue16) & "&")
301: POST_Data.Append((PostName17) & "=" & (PostValue17))
302: ElseIf PostName16 <> "" Then
303: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
304: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
305: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
306: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
307: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
308: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
309: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
310: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
311: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
312: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
313: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
314: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
315: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
316: POST_Data.Append((PostName14) & "=" & (PostValue14) & "&")
317: POST_Data.Append((PostName15) & "=" & (PostValue15) & "&")
318: POST_Data.Append((PostName16) & "=" & (PostValue16))
319: ElseIf PostName15 <> "" Then
320: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
321: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
322: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
323: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
324: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
325: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
326: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
327: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
328: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
329: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
330: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
331: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
332: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
333: POST_Data.Append((PostName14) & "=" & (PostValue14) & "&")
334: POST_Data.Append((PostName15) & "=" & (PostValue15))
335: ElseIf PostName14 <> "" Then
336: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
337: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
338: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
339: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
340: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
341: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
342: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
343: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
344: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
345: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
346: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
347: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
348: POST_Data.Append((PostName13) & "=" & (PostValue13) & "&")
349: POST_Data.Append((PostName14) & "=" & (PostValue14))
350: ElseIf PostName13 <> "" Then
351: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
352: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
353: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
354: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
355: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
356: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
357: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
358: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
359: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
360: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
361: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
362: POST_Data.Append((PostName12) & "=" & (PostValue12) & "&")
363: POST_Data.Append((PostName13) & "=" & (PostValue13))
364: ElseIf PostName12 <> "" Then
365: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
366: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
367: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
368: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
369: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
370: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
371: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
372: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
373: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
374: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
375: POST_Data.Append((PostName11) & "=" & (PostValue11) & "&")
376: POST_Data.Append((PostName12) & "=" & (PostValue12))
377: ElseIf PostName11 <> "" Then
378: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
379: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
380: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
381: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
382: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
383: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
384: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
385: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
386: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
387: POST_Data.Append((PostName10) & "=" & (PostValue10) & "&")
388: POST_Data.Append((PostName11) & "=" & (PostValue11))
389: ElseIf PostName10 <> "" Then
390: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
391: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
392: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
393: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
394: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
395: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
396: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
397: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
398: POST_Data.Append((PostName9) & "=" & (PostValue9) & "&")
399: POST_Data.Append((PostName10) & "=" & (PostValue10))
400: ElseIf PostName9 <> "" Then
401: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
402: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
403: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
404: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
405: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
406: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
407: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
408: POST_Data.Append((PostName8) & "=" & (PostValue8) & "&")
409: POST_Data.Append((PostName9) & "=" & (PostValue9))
410: ElseIf PostName8 <> "" Then
411: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
412: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
413: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
414: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
415: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
416: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
417: POST_Data.Append((PostName7) & "=" & (PostValue7) & "&")
418: POST_Data.Append((PostName8) & "=" & (PostValue8))
419: ElseIf PostName7 <> "" Then
420: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
421: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
422: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
423: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
424: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
425: POST_Data.Append((PostName6) & "=" & (PostValue6) & "&")
426: POST_Data.Append((PostName7) & "=" & (PostValue7))
427: ElseIf PostName6 <> "" Then
428: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
429: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
430: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
431: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
432: POST_Data.Append((PostName5) & "=" & (PostValue5) & "&")
433: POST_Data.Append((PostName6) & "=" & (PostValue6))
434: ElseIf PostName5 <> "" Then
435: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
436: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
437: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
438: POST_Data.Append((PostName4) & "=" & (PostValue4) & "&")
439: POST_Data.Append((PostName5) & "=" & (PostValue5))
440: ElseIf PostName4 <> "" Then
441: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
442: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
443: POST_Data.Append((PostName3) & "=" & (PostValue3) & "&")
444: POST_Data.Append((PostName4) & "=" & (PostValue4))
445: ElseIf PostName3 <> "" Then
446: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
447: POST_Data.Append((PostName2) & "=" & (PostValue2) & "&")
448: POST_Data.Append((PostName3) & "=" & (PostValue3))
449: ElseIf PostName2 <> "" Then
450: POST_Data.Append((PostName1) & "=" & (PostValue1) & "&")
451: POST_Data.Append((PostName2) & "=" & (PostValue2))
452: ElseIf PostName1 <> "" Then
453: POST_Data.Append((PostName1) & "=" & (PostValue1))
454: Else
455: POST_Data.AppendLine()
456: End If
457: POST_Data.Append(vbCrLf & vbCrLf)
458: Return POST_Data.ToString
459: End Function
460:
461: Shared Function PreparePostForm(Optional ByVal PostName1 As String = "", Optional ByVal PostValue1 As String = "", _
462: Optional ByVal PostName2 As String = "", Optional ByVal PostValue2 As String = "", _
463: Optional ByVal PostName3 As String = "", Optional ByVal PostValue3 As String = "", _
464: Optional ByVal PostName4 As String = "", Optional ByVal PostValue4 As String = "", _
465: Optional ByVal PostName5 As String = "", Optional ByVal PostValue5 As String = "", _
466: Optional ByVal PostName6 As String = "", Optional ByVal PostValue6 As String = "", _
467: Optional ByVal PostName7 As String = "", Optional ByVal PostValue7 As String = "", _
468: Optional ByVal PostName8 As String = "", Optional ByVal PostValue8 As String = "", _
469: Optional ByVal PostName9 As String = "", Optional ByVal PostValue9 As String = "", _
470: Optional ByVal PostName10 As String = "", Optional ByVal PostValue10 As String = "", _
471: Optional ByVal PostName11 As String = "", Optional ByVal PostValue11 As String = "", _
472: Optional ByVal PostName12 As String = "", Optional ByVal PostValue12 As String = "", _
473: Optional ByVal PostName13 As String = "", Optional ByVal PostValue13 As String = "", _
474: Optional ByVal PostName14 As String = "", Optional ByVal PostValue14 As String = "", _
475: Optional ByVal PostName15 As String = "", Optional ByVal PostValue15 As String = "", _
476: Optional ByVal PostName16 As String = "", Optional ByVal PostValue16 As String = "", _
477: Optional ByVal PostName17 As String = "", Optional ByVal PostValue17 As String = "", _
478: Optional ByVal PostName18 As String = "", Optional ByVal PostValue18 As String = "", _
479: Optional ByVal PostName19 As String = "", Optional ByVal PostValue19 As String = "", _
480: Optional ByVal PostName20 As String = "", Optional ByVal PostValue20 As String = "") As String
481: Dim POST_Data As New Text.StringBuilder
482: If PostName20 <> "" Then
483: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
484: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
485: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
486: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
487: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
488: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
489: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
490: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
491: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
492: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
493: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
494: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
495: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
496: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
497: POST_Data.Append("<input type='hidden' name='" & (PostName15) & "' value='" & (PostValue15) & "' />" & vbCrLf)
498: POST_Data.Append("<input type='hidden' name='" & (PostName16) & "' value='" & (PostValue16) & "' />" & vbCrLf)
499: POST_Data.Append("<input type='hidden' name='" & (PostName17) & "' value='" & (PostValue17) & "' />" & vbCrLf)
500: POST_Data.Append("<input type='hidden' name='" & (PostName18) & "' value='" & (PostValue18) & "' />" & vbCrLf)
501: POST_Data.Append("<input type='hidden' name='" & (PostName19) & "' value='" & (PostValue19) & "' />" & vbCrLf)
502: POST_Data.Append("<input type='hidden' name='" & (PostName20) & "' value='" & (PostValue20) & "' />" & vbCrLf)
503: ElseIf PostName19 <> "" Then
504: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
505: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
506: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
507: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
508: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
509: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
510: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
511: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
512: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
513: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
514: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
515: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
516: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
517: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
518: POST_Data.Append("<input type='hidden' name='" & (PostName15) & "' value='" & (PostValue15) & "' />" & vbCrLf)
519: POST_Data.Append("<input type='hidden' name='" & (PostName16) & "' value='" & (PostValue16) & "' />" & vbCrLf)
520: POST_Data.Append("<input type='hidden' name='" & (PostName17) & "' value='" & (PostValue17) & "' />" & vbCrLf)
521: POST_Data.Append("<input type='hidden' name='" & (PostName18) & "' value='" & (PostValue18) & "' />" & vbCrLf)
522: POST_Data.Append("<input type='hidden' name='" & (PostName19) & "' value='" & (PostValue19) & "' />" & vbCrLf)
523: ElseIf PostName18 <> "" Then
524: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
525: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
526: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
527: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
528: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
529: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
530: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
531: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
532: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
533: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
534: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
535: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
536: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
537: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
538: POST_Data.Append("<input type='hidden' name='" & (PostName15) & "' value='" & (PostValue15) & "' />" & vbCrLf)
539: POST_Data.Append("<input type='hidden' name='" & (PostName16) & "' value='" & (PostValue16) & "' />" & vbCrLf)
540: POST_Data.Append("<input type='hidden' name='" & (PostName17) & "' value='" & (PostValue17) & "' />" & vbCrLf)
541: POST_Data.Append("<input type='hidden' name='" & (PostName18) & "' value='" & (PostValue18) & "' />" & vbCrLf)
542: ElseIf PostName17 <> "" Then
543: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
544: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
545: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
546: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
547: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
548: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
549: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
550: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
551: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
552: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
553: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
554: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
555: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
556: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
557: POST_Data.Append("<input type='hidden' name='" & (PostName15) & "' value='" & (PostValue15) & "' />" & vbCrLf)
558: POST_Data.Append("<input type='hidden' name='" & (PostName16) & "' value='" & (PostValue16) & "' />" & vbCrLf)
559: POST_Data.Append("<input type='hidden' name='" & (PostName17) & "' value='" & (PostValue17) & "' />" & vbCrLf)
560: ElseIf PostName16 <> "" Then
561: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
562: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
563: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
564: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
565: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
566: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
567: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
568: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
569: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
570: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
571: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
572: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
573: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
574: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
575: POST_Data.Append("<input type='hidden' name='" & (PostName15) & "' value='" & (PostValue15) & "' />" & vbCrLf)
576: POST_Data.Append("<input type='hidden' name='" & (PostName16) & "' value='" & (PostValue16) & "' />" & vbCrLf)
577: ElseIf PostName15 <> "" Then
578: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
579: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
580: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
581: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
582: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
583: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
584: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
585: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
586: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
587: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
588: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
589: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
590: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
591: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
592: POST_Data.Append("<input type='hidden' name='" & (PostName15) & "' value='" & (PostValue15) & "' />" & vbCrLf)
593: ElseIf PostName14 <> "" Then
594: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
595: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
596: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
597: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
598: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
599: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
600: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
601: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
602: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
603: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
604: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
605: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
606: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
607: POST_Data.Append("<input type='hidden' name='" & (PostName14) & "' value='" & (PostValue14) & "' />" & vbCrLf)
608: ElseIf PostName13 <> "" Then
609: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
610: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
611: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
612: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
613: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
614: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
615: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
616: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
617: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
618: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
619: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
620: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
621: POST_Data.Append("<input type='hidden' name='" & (PostName13) & "' value='" & (PostValue13) & "' />" & vbCrLf)
622: ElseIf PostName12 <> "" Then
623: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
624: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
625: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
626: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
627: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
628: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
629: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
630: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
631: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
632: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
633: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
634: POST_Data.Append("<input type='hidden' name='" & (PostName12) & "' value='" & (PostValue12) & "' />" & vbCrLf)
635: ElseIf PostName11 <> "" Then
636: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
637: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
638: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
639: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
640: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
641: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
642: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
643: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
644: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
645: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
646: POST_Data.Append("<input type='hidden' name='" & (PostName11) & "' value='" & (PostValue11) & "' />" & vbCrLf)
647: ElseIf PostName10 <> "" Then
648: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
649: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
650: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
651: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
652: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
653: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
654: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
655: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
656: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
657: POST_Data.Append("<input type='hidden' name='" & (PostName10) & "' value='" & (PostValue10) & "' />" & vbCrLf)
658: ElseIf PostName9 <> "" Then
659: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
660: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
661: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
662: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
663: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
664: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
665: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
666: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
667: POST_Data.Append("<input type='hidden' name='" & (PostName9) & "' value='" & (PostValue9) & "' />" & vbCrLf)
668: ElseIf PostName8 <> "" Then
669: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
670: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
671: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
672: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
673: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
674: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
675: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
676: POST_Data.Append("<input type='hidden' name='" & (PostName8) & "' value='" & (PostValue8) & "' />" & vbCrLf)
677: ElseIf PostName7 <> "" Then
678: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
679: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
680: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
681: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
682: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
683: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
684: POST_Data.Append("<input type='hidden' name='" & (PostName7) & "' value='" & (PostValue7) & "' />" & vbCrLf)
685: ElseIf PostName6 <> "" Then
686: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
687: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
688: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
689: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
690: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
691: POST_Data.Append("<input type='hidden' name='" & (PostName6) & "' value='" & (PostValue6) & "' />" & vbCrLf)
692: ElseIf PostName5 <> "" Then
693: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
694: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
695: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
696: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
697: POST_Data.Append("<input type='hidden' name='" & (PostName5) & "' value='" & (PostValue5) & "' />" & vbCrLf)
698: ElseIf PostName4 <> "" Then
699: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
700: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
701: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
702: POST_Data.Append("<input type='hidden' name='" & (PostName4) & "' value='" & (PostValue4) & "' />" & vbCrLf)
703: ElseIf PostName3 <> "" Then
704: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
705: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
706: POST_Data.Append("<input type='hidden' name='" & (PostName3) & "' value='" & (PostValue3) & "' />" & vbCrLf)
707: ElseIf PostName2 <> "" Then
708: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
709: POST_Data.Append("<input type='hidden' name='" & (PostName2) & "' value='" & (PostValue2) & "' />" & vbCrLf)
710: ElseIf PostName1 <> "" Then
711: POST_Data.Append("<input type='hidden' name='" & (PostName1) & "' value='" & (PostValue1) & "' />" & vbCrLf)
712: Else
713: POST_Data.AppendLine()
714: End If
715: Return POST_Data.ToString
716: End Function
717: End Class
718:
719: Public Class ParceNamespace
720:
721: Dim _XML As New System.Xml.XmlDocument
722: Public ReadOnly Property XML() As System.Xml.XmlDocument
723: Get
724: Return _XML
725: End Get
726: End Property
727:
728: Dim _NamespaceManager As System.Xml.XmlNamespaceManager
729: Public ReadOnly Property NamespaceManager() As System.Xml.XmlNamespaceManager
730: Get
731: Return _NamespaceManager
732: End Get
733: End Property
734:
735:
736: Public Sub New(ByVal ResponseXML As String)
737: _XML.LoadXml(ResponseXML)
738: Dim AllNameSpace As New System.Collections.Specialized.NameValueCollection
739: For I As Integer = 1 To 20
740: Dim XpatchBuilder As New System.Text.StringBuilder
741: XpatchBuilder.Append("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*", 0, I * 2)
742: Dim CurrentNodeList As System.Xml.XmlNodeList = _XML.SelectNodes(XpatchBuilder.ToString)
743: If CurrentNodeList IsNot Nothing Then
744: If CurrentNodeList.Count > 0 Then
745: For Each CurrentNode As System.Xml.XmlNode In CurrentNodeList
746: If CurrentNode.Attributes IsNot Nothing Then
747: If CurrentNode.Attributes.Count > 0 Then
748: For Each CurrentAttr As System.Xml.XmlAttribute In CurrentNode.Attributes
749: If CurrentAttr.Prefix = "xmlns" Then
750: AllNameSpace.Add(CurrentAttr.LocalName, CurrentAttr.Value)
751: End If
752: Next
753: End If
754: End If
755: Next
756: Else
757: Exit For
758: End If
759: End If
760: Next
761: For i As Integer = 0 To AllNameSpace.Count - 1
762: _XML.NameTable.Add(AllNameSpace.Keys(i))
763: Next
764: _NamespaceManager = New System.Xml.XmlNamespaceManager(_XML.NameTable)
765: For i As Integer = 0 To AllNameSpace.Count - 1
766: _NamespaceManager.AddNamespace(AllNameSpace.Keys(i), AllNameSpace.Get(i))
767: Next
768: End Sub
769:
770: End Class
Вы можете использовать эту мою библиотеку и для простых POST-запросов, не связанных с WCF-сервисами, например вот так:
HTML = VBNET2009.Wcf_Client.PostRequest(VBNET2009.Wcf_Client.PostRequestEncode.UTF8, "//www.vb-net.com/posttest.ashx", "FirstPostParm", "1234567", "SecondPostParm", "abcdef") 'до двадцати POST-параметров
Наконец, библиотека содержит третий фрагмент - для редиректа браузера на новый URL с передачей POST-параметорв. Если вышеописанные способы использования библиотеки подразумевали считывание ответа WCF-сервиса в свою программу (и сервис для анализа ответа) - то функционал Редиректа напрямую не связан с WCF. Он нужен для межсайтовых переходов и у меня такая потребность уже несколько раз возникла именно в прогах с вышеописанным WCF-клиентом. Кроме того, для редиректов с передачей POST-параметров используется точно такой же внешний интерфейс, как и для считывания ответа WCF-сервиса и простых POST-запросов. Поэтому отправку POST с редикретом на новый ресурс я включил именно в эту библиотеку.
В принципе сам по себе редирект можно было выполнить достаточно просто, включив в любое место хандлера примерно вот такой код:
1: context.Current.Response.Status = "307 Temporary Redirect"
2: context.Current.Response.AddHeader("Location", "//www.vb-net.com/requesttest.ashx")
Но фишка заключается в том, что спецификация браузера описывет порядок действий браузера так, что редирект будет все равно выполнен методом GET (то есть без POST-параметров), даже при запросе редиректа по коду 307. Поэтому (как вы видите в строке 86) я выполнил в этом коде редирект именно с помощью JavaScript (при этом внешний интефейс выова редиректа с POST-параметрами такой же, как и и для простых POST-запросов и обращений к WCF-клиенту):
HTML = VBNET2009.Wcf_Client.PostRedirect(VBNET2009.Wcf_Client.PostRedirectEncode.UTF8, "//www.vb-net.com/posttest.ashx", "FirstPostParm", "1234567", "SecondPostParm", "abcdef") 'до двадцати POST-параметров
В принципе, этот софт по отдельным фрагментам кода существует у меня где-то с 2008-году (а отдельные его фрагменты с 2005-го года). В 2010-м году мне плотно окунуться в сервисы на JAX-WS - и я опубликовал сначала эту старую версию (а заодно для себя освежил все свои идеи по теме WCF-клиентов). Однако, немного покрутив свой старый софт, я понял что новым задачам он соответствует не вполне. И я сделал вторую версию, с которой вы можете познакомиться здесь.
В откомпилированном виде вы можете сгрузить мой OpenSource код отсюда .
Еще вы можете почитать у меня на сайте:
- Организация SSL транспортного уровня по программно загружаемому клиентскому сертификату.
- Как сделать SOAP/WSDL-вебсервис на ASP.NET/MONO для вызова его из FLEX
- SOAP/WSDL vs XML data exchange - сравнение механизмов обмена данными по SOAP-WSDL c XML и другие механизмы обмена данными между приложениями (TEXT, JSON, SOCKET, FTP/ZIP и др) .
|