Здравие. Пытаюсь написать программу на Vb .net, которая будет проверять отслежку почты России, используя их Soap api
http://voh.russianpost.ru:8080... story?wsdl .
Есть исходник на Python
Python |
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
| from prettytable import PrettyTable
from suds.client import Client
import argparse
import re
import sys
def barcode_type(s):
s = s.upper()
if not re.match('^[A-Z]{2}\d{9}[A-Z]{2}$', s):
raise argparse.ArgumentTypeError('wrong barcode')
return s
parser = argparse.ArgumentParser(description='Show tracking info from Russian Post service.')
parser.add_argument('barcode', type=barcode_type, help='item barcode in international format')
args = parser.parse_args()
try:
client = Client('http://voh.russianpost.ru:8080/niips-operationhistory-web/OperationHistory?wsdl')
history = client.service.GetOperationHistory(Barcode=args.barcode, MessageType=0)
except Exception as e:
sys.exit(e)
table = PrettyTable(['Date', 'Operation', 'Address', 'Weight'])
for row in history:
date = operation = address = weight = ''
try:
date = row.OperationParameters.OperDate
except:
pass
try:
operation = row.OperationParameters.OperType.Name
operation += ' (' + row.OperationParameters.OperAttr.Name + ')'
except:
pass
try:
address = row.AddressParameters.OperationAddress.Description
address = row.AddressParameters.OperationAddress.Index + ' ' + address
except:
pass
try:
weight = row.ItemParameters.Mass
weight /= 1000.0
except:
pass
table.add_row([
date,
operation,
address,
weight,
])
if hasattr(table, 'align'):
table.align = 'l'
else:
for field in table.fields:
table.set_field_align(field, 'l')
print table.get_string() |
|
Вот мои наброски
PureBasic |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| Dim header As ServiceReference1.AuthorizationHeader
header = New ServiceReference1.AuthorizationHeader()
header.login = ""
header.password = ""
Dim request As ServiceReference1.OperationHistoryRequest
request = New ServiceReference1.OperationHistoryRequest()
request.Barcode = TextBox1.Text
request.MessageType = 0
Dim client As ServiceReference1.OperationHistoryInterfaceClient
client = New ServiceReference1.OperationHistoryInterfaceClient()
Dim status As String
Dim location As String
Dim dateTime As String
Dim records As List(Of ServiceReference1.OperationHistoryRecord)
records = New List(Of ServiceReference1.OperationHistoryRecord)(client.GetOperationHistory(header, request))
For Each rec As ServiceReference1.OperationHistoryRecord In records
location = rec.AddressParameters.OperationAddress.Description
dateTime = rec.OperationParameters.OperDate.ToString() |
|
Запустив у себя, программа выдает ошибку авторизации. На питоне ее нет. Если удалить ServiceReference1.AuthorizationHeader, то в строке
PureBasic |
1
| records = New List(Of ServiceReference1.OperationHistoryRecord)(client.GetOperationHistory(header, request)) |
|
надо будет также header удалять, но тогда возникает ошибка в том, что нужно 2 параметр. Как обойти авторизацию не пойму