OpenResponse Method

Official Content
This documentation is valid for:

When used with the XmlWriter extended data type, it writes an XML in the http response´s body. When used with the XmlReader extended data type, it is used in any object to have the information returned by a request read as XML.

Syntax

XmlDataType.OpenResponse(HttpRequest)

Where XmlDataType is XmlReader or XmlWriter extended data type.

Example

Client program:

// &Client is HttpClient type

// &Writer is XMLWriter type

// &Reader is XMLReader type

// Define the host and the the port where make the request

   &client.host = "localhost"

   &client.port = 88

 

// Adding the XML to request

&Writer.openRequest(&Client)

&Writer.WriteStartElement("Parameters")

&Writer.WriteElement("a", &A)

&Writer.WriteElement("b", &B)

&Writer.WriteEndElement()

&Writer.Close()

// Make POST to the WebProc

&Client.Execute("POST", "/servlet/awebproc")

// Read the XML than return and loaded in the internal variables

&Reader.OpenResponse(&Client)

&Reader.Read()

&Reader.Read()

&a = Val(&Reader.Value)

&Reader.Read()   

&b = Val(&Reader.Value)

&Reader.Close()

Program server (WebProc):

// &Request is HttpRequest type // &Response is HttpResponse type // &Writer is XMLWriter type // &Reader is XMLReader type

// Read the XML's parameters

&Reader.OpenRequest(&Request) &Reader.Read() &Reader.Read() &a = Val(&Reader.Value) &reader.read()    &b = Val(&Reader.Value) &Reader.Close()

// Add 1 to each value

&a = &a + 1 &b = &b + 1

// Write parameters into response

&Writer.OpenResponse(&Response) &Writer.WriteStartElement("Parameters") &Writer.WriteElement("a", &A) &Writer.WriteElement("b", &B) &Writer.WriteEndElement() &Writer.Close()

Scope

Extended Data Types: XmlWriter, XmlReader
Languages: .NET, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)

See Also

ExcelDocument WordDocument XmlWriter XmlReader