yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method TestDataConnect (
  String DataName
) as String
{
  Description: 'Test Data Connect'
  TextBody:
  [*
     //Administrator Jul-6-2023 (created)
    parms := this.GetDataConnectParms( DataName );
    address := parms.Element( 0 );
    url := parms.Element( 1 );
    port := parms.Element( 2 );
    bodynumber := parms.Element( 3 );
    
    // for HTTPS requests:
    i := HTTPInterface::Create( address, [Number]port);
    //i := HTTPInterface::Create( address ,443);
    info( parms.ToString( "***" ) );
    
    i.URL(url);
    i.SSL(false);
    //i.SSL(true);
    //i.SSLKeystore('MyKeystore'); // created in the Config Utility
    
    i.PostMethod(true); //it's a POST method
    postrequestbody := JSON::Object()
                        .Add( "serviceInterfaceCode", "ESBOTDH000" + bodynumber )
                        .Add( "fromSystemCode", "OTDH000" + bodynumber )
                        .Add( "toInterfaceCode", "QIDH000" + bodynumber )
                        .Add( "ouZone", "OU_TMSH" )
                        .Add( "uuid", "1617355496bb588e353e80147eea5f45" )
                        .Add( "requestTime", DateTime::Now().Format( "Y-M2-D2 H:m:s" ) )
                        .Add( "dataType", "JSON" )
                        .Add( "data", JSON::Object()
                                      .Add( "pageIndex", "1" ) ).Build();
    
    info( DateTime::Now().Format( "Y-M2-D2 H:m:s" ) );
    postrequestbodystring := postrequestbody.AsString();
    i.Call(postrequestbodystring); // Call's argument is for POST method's content.
    htmlresult := i.Result();
    info( htmlresult );
    
    result := this.GetStatusFromJson( JSON::Parse( htmlresult ), DataName );
    
    return result;
  *]
}