INetCommand.Start

Syntax

Start(Var Value: Variant);

Parameters

Value. Data or request sent to network resource for processing.

Description

The Start method initializes sending of the request to network resource.

Comments

When executing POST requests, in the Value parameter specify the request to be sent in the body of the POST request and to be handled by the server.

On executing GET requests in the Value parameter the empty string can be sent and execution parameters are specified in network resource URL string.

On finishing request execution, the result will be available in the Result property.

Example

Executing the example requires the deployed Foresight Analytics Platform BI server.

Add a link to the Net system assembly.

Sub UserProc;
Var
    Service: INetHttpService;
    Cmd: INetCommand;
    HttpCmd: INetHttpCommand;
    Request: Variant;
    Response, Id: string;
    IdPos: Integer;
Begin
    Service := New NetHttpService.Create;
    Service.Url := "http://localhost:9090/axis2/services/PP.SOM.Som";
    // Web service connection
    Cmd := Service.Connect;
    HttpCmd := Cmd As INetHttpCommand;
    HttpCmd.Command := NetHttpCommandType.Post;
    HttpCmd.AcceptLanguage := "ru";
    // Repository connection
    Request := "<OpenMetabase>" +
        "<tDef><id>WAREHOUSE</id></tDef>" +
        "<tCreds><user><id>User</id></user><pass>Password</pass></tCreds>" +
        "</OpenMetabase>" ;
    Cmd.Start(Request);
    Response := Cmd.Result As String;
    IdPos := Response.IndexOf("<id>");
    Id := Response.SubString(IdPos + 4, Response.IndexOf("</id>") - IdPos - 4);
    Debug.WriteLine("Response: " + Response);
    Debug.WriteLine("Moniker: " + Id);
    Debug.WriteLine("ContentType: " + HttpCmd.ContentType);
    //...
    // Further work with repository
    //...
    // Disconnect from repository
    Request := "<CloseMetabase><tMb><id>" + id + "</id></tMb></CloseMetabase>";
    Cmd.Start(Request);
    Response := Cmd.Result As String;
    Debug.WriteLine("Response: " + Response);
End Sub UserProc;

On executing the example, BI server connection is established. A SOAP request to open a repository connection will be sent to BI server, the obtained connection moniker will be displayed in the development environment console. After that the request to open repository connection is sent.

The example of JSON request execution:

Sub UserProc;
Var
    Service: INetHttpService;
    Cmd: INetCommand;
    HttpCmd: INetHttpCommand;
    Request: Variant;
    Response, Id: String;
    IdPos: Integer;
Begin
    Service := New NetHttpService.Create;
    Service.Url := "http://localhost:9090/axis2/services/PP.SOM.Som";
    Cmd := Service.Connect;
    HttpCmd := Cmd As INetHttpCommand;
    HttpCmd.Command := NetHttpCommandType.Post;
    HttpCmd.Headers.Add("Content-Type: application/json;charset=utf-8");
    HttpCmd.OuterBody := True;
    Request := "{" +
    """OpenMetabase"" :" +
    "{" +
    """tDef"" :" +
        "{" +
        """id"" : ""WAREHOUSE""" +
        "}," +
    """tCreds"" :" +
        "{" +
        """user"" :" +
        "{" +
        """id"" : ""User""" +
        "} ," +
        """pass"" : ""Password""" +
        "}," +
    """tArg"" : """"" +
    "}" +
    "}" ;
    Cmd.Start(Request);
    Response := Cmd.Result As String;
    IdPos := Response.IndexOf("""id"":");
    Id := Response.SubString(IdPos + 7, Response.IndexOf('"', IdPos + 7) - IdPos - 7);
    Debug.WriteLine("Response: " + Response);
    Debug.WriteLine("Moniker: " + Id);
    Debug.WriteLine("ContentType: " + HttpCmd.ContentType);
    //...
    // Further work with repository
    //...
    // Disconnect from repository
    Request := "{" +
    """CloseMetabase"" :" +
    "{" +
    """tMb"" :" +
        "{" +
        """id"" :" + "" + Id + "" +
        "}" +
    "}" +
    "}" ;
    Cmd.Start(Request);
    Response := Cmd.Result As String;
    Debug.WriteLine("Response: " + Response);
End Sub UserProc;

This example also connects to and then disconnects from the repository.

See also:

INetCommand