| 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 ) ); | 
|   *] | 
| } |