Persistent HTTP (phttp://)

A-Stack supports phttp protocol Handler, that can be used for persistent HTTP connections

PHTTP Protocol Handler Flow:


PHTTP Protocol Handler Installation: 

Date
Download Locaiton
Version
08/01/2018Download1.1.0
08/08/2018Download1.1.1
08/09/2018Download1.1.2

PHTTP Setup Instructions

  1. Unzip the downloaded zip file
  2. Copy the sff.bundle.ext.phttp-{version}.jar from this location to the sff.auto.launch folder which is present in your A-Stack Prime folder.


PHTTP Protocol Parameters:

The table below lists all the parameters of Phttp protocol handler and their description

Parameter Name

Parameter Description

URL


The http/https URL of persistent http connection.

Payload

The Payload of the Post Invoke.


Usage of Phttp protocol handler:

  • Phttp Get:  the facet given below in for A-Stack Version 1.0.5 or greater.

    PHTTP GET Facet
    <ThingFacet Name="PhttpConnectionFacet">
        <String Format="$ObjectFormat(xml)" KnownBy="PhttpConnectionAction" Name="ReceivedData" update="auto"/>
        <String Name="URL"/>
        <Action Name="PhttpConnectionAction">
            <Workflow Limit="1" Live="1" Timeout="-1">
                <Task name="Main" while="true">
                    <Event as="ActionArgument" name="Argument"/>
                    <Invoke get="phttp://?URL=[%:Event.Argument.URL.Value:%]&amp;" name="InvokePhttpSubscription" scope="process" waitFor="Argument">
                        <Headers/>
                        <Cookie/>
                    </Invoke>
                    <Output As="ActionResult" Name="Result">
                        <Value>
                            <ReceivedData>
                                <Include>
    								Invoke.InvokePhttpSubscription.Message.Value
                                </Include>
                            </ReceivedData>
                        </Value>
                    </Output>
                </Task>
            </Workflow>
        </Action>
    </ThingFacet>   
    PHTTP GET Query
    <Query>
        <DeleteAll>
            <PhttpGetModel>
                <phttpID ne=""/>
            </PhttpGetModel>
        </DeleteAll>
        <Create>
            <PhttpGetModel>
                <ReceivedData>$Null()</ReceivedData>
                <URL>http://localhost:9090/stream</URL>
            </PhttpGetModel>
        </Create>
    </Query>
    PHTTP POST Facet
    <ThingFacet Name="PhttpPostConnectionFacet">
        <String Format="$ObjectFormat(xml)" KnownBy="PhttpPostConnectionAction" Name="ReceivedData" update="auto"/>
        <String Name="URL"/>
    	<String Name="Payload"/>
        <Action Name="PhttpPostConnectionAction">
            <Workflow Limit="1" Live="1" Timeout="-1">
                <Task name="Main" while="true">
                    <Event as="ActionArgument" name="Argument"/>
                    <Invoke name="InvokePhttpSubscription" post="phttp://?URL=[%:Event.Argument.URL.Value:%]&amp;" scope="process" waitFor="Argument">
                        <Headers/>
                        <Cookie/>
                        <Message>
                            <Value>[%:Event.Argument.Payload.Value:%]</Value>
                        </Message>
                    </Invoke>
                    <Output As="ActionResult" Name="Result">
                        <Value>
                            <ReceivedData>
                                <Include>
    								Invoke.InvokePhttpSubscription.Message.Value
                                </Include>
                            </ReceivedData>
                        </Value>
                    </Output>
                </Task>
            </Workflow>
        </Action>
    </ThingFacet>   
    PHTTP POST Query
    <Query>
        <DeleteAll>
            <PhttpPostModel>
                <phttpID ne=""/>
            </PhttpPostModel>
        </DeleteAll>
        <Create>
            <PhttpPostModel>
                <ReceivedData>$Null()</ReceivedData>
    			<Payload>Hello World</Payload>
                <URL>http://localhost:7070/stream</URL>
            </PhttpPostModel>
        </Create>
    </Query>


PHTTP Invoke Output Format: The output message of phttp Invoke is an xml structure as shown below


PHTTP Invoke Output Format
 <ReceivedData Value="" Version="1">
        <Known>
          <Header>
            <Content-Type>text/event-stream</Content-Type>
            <Cache-Control>no-cache</Cache-Control>
            <Connection>keep-alive</Connection>
            <Date>Fri, 02 Dec 2016 18:43:09 GMT</Date>
            <Transfer-Encoding>chunked</Transfer-Encoding>
          </Header>
          <Message>
            <Value>
              <Data>data: Fri Dec 02 2016 10:43:20 GMT-0800 (PST)</Data>
            </Value>
          </Message>
          <Status>200 OK</Status>
          <Version>HTTP/1.1</Version>
        </Known>
      </ReceivedData>