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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Quintiq file version 2.0
#parent: #root
Method MessageSendViaSOAP (LibDMF_SystemOnChannel soc_i, NamedValueTree nvt_i)
{
  TextBody:
  [*
    // Send via SOAP
    soapInterface := LibDMF_SOAPClient::CreateInterface();
    
    event := null( Object );
    root  := this.CommunicationChannelRoot();
    
    // Target-dataset
    globalparam := root.GlobalParameters();
    datasetKind := globalparam.DM_DatasetKind();
    datasetPath := globalparam.DM_DatasetFolder();
    datasetName := globalparam.DM_DatasetName();
    host        := globalparam.DM_Host();
    port        := globalparam.DM_Port();
    
    // SOAPReceiver
    receiverKind := datasetKind;
    receiverName := LibDMF_CommunicationChannel::DatasetNameSOAPReceiver();
    
    // If there is no SystemOnChannel then assume that the call must be send to the SOAPReceiver of the DataManager
    // and use the settings as provided in the LibDMF_GlobalParameters. This should point to dataset SOAPReceiver.
    // Otherwise use the settings of the SystemOnChannel (especially the DatasetKind is important).
    if( not isnull( soc_i ) )
    {
      // Target-dataset
      datasetKind := soc_i.DatasetKind();
      datasetPath := soc_i.DatasetPath();
      datasetName := soc_i.DatasetName();
      host        := soc_i.HostName();
      port        := soc_i.PortNr();
    
      // Update the SOAPReceiver dataset kind
      receiverKind := datasetKind;
    
      event := root.EventGetLast( datasetKind, datasetName );
    
      // If a requesting dataset has been registered, then use thát dataset as target.
      // Make sure to get the event first, otherwise it will be null (because of the change in datasetKind and -Name).
      if( soc_i.HasRequestingDataset() )
      {
        datasetKind := soc_i.RequestingDatasetKind();
        datasetName := soc_i.RequestingDatasetName();
    
        // Reset after use.
        soc_i.ResetRequestingDataset();
      }
    }
    
    // If the recipient's hostname is the same with the current machine's hostname, change it to 'localhost' instead.
    // A temporary workaround as SOAP is unable to send to the same machine using absolute hostname.
    host := ifexpr( host = OS::ComputerName(), "localhost", host );
    
    // Set the SOAP settings
    LibDMF_Util::SetSOAPClientInterfaceConfiguration( soapInterface, host, port, "SOAPServer", "ReceiveMessage", receiverKind, receiverName );
    
    // Turn the NVT into a message (i.e. the payload of the SOAP-call).
    message := LibDMF_CommunicationChannel::NVTSerialize( nvt_i );
    
    root.EventLogActivity( event,
                           "Sending message asynchronously via SOAP" );
    
    // Do the call asynchronous.
    soapInterface.ASync_ReceiveMessage( datasetKind, datasetPath, datasetName, message, this, root.EventGetID( event ) );
  *]
}