Routing requests based on the content of XML fieldsThis useful bit of TrafficScript can be used in a Request rule for routing requests based on the contents of the "Source" field. This is the solution to a request from a ZXTM 3.1 evaluator.
# Only do this for HTTP POSTs...
if( http.getMethod() != "POST" ) break;
$body = http.getRequestBody();
$source = xml.xpath.matchNodeSet( $body, "", "//Source/text()" );
# This sets $source to be
# "/dvrti1RTIDocRoot/portal2/60097.48806.65101.44299/8.pdf"
if( string.contains( $source, "/portal2/" ) ) {
pool.use( "portal2 pool" );
} else if( string.contains( $source, "/qa3x/" ) ) {
pool.use( "qa3x pool" );
}
Stephen Davis
[Zeus] 01 July 2005
Comments:This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Comment from:
Owen Garrett [Zeus Dev Team]
And for reference, here's an example of the SOAP request that they wanted to manage traffic for:
POST / HTTP/1.1
Host: portal.customer.com
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:PartnerAPICallbackOnSynchronizeNotesAction"
Content-length: 1296
<E:Envelope xmlns:E="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:A="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://www.w3.org/2001/XMLSchema-instance"
xmlns:y="http://www.w3.org/2001/XMLSchema"
E:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<E:Body>
<m:OnSynchronizeNotes xmlns:m="urn:PartnerAPI">
<HostSessionID s:type="y:string">123</HostSessionID>
<Source s:type="y:string">/dvrti1RTIDocRoot/portal2/60097.48806.65101.44299/8.pdf</Source>
<Notes s:type="m:OperatedNotesList" A:arrayType="m:OperatedNote[1]">
<item>
<Ver s:type="y:int">1</Ver>
<Operation s:type="m:OperationCode">added</Operation>
<Id s:type="y:int">1</Id>
<Page s:type="y:int">1</Page>
<Type s:type="m:NoteType">Text</Type>
<Time s:type="y:dateTime">2005-04-06T21:49:03Z</Time>
<CTime s:type="y:dateTime">2005-04-06T21:49:03Z</CTime>
<Author s:type="m:NoteAuthor">
<F s:type="y:string">John</F>
<L s:type="y:string">Reviewer1</L>
<Aid s:type="y:string">User01</Aid>
</Author>
<Anchor s:type="m:WPoint">
<Xcoord s:type="y:float">2378.3252</Xcoord>
<Ycoord s:type="y:float">2948.76855</Ycoord>
</Anchor>
<PageSize s:type="m:WSize">
<Xsize s:type="y:float">20400</Xsize>
<Ysize s:type="y:float">13200</Ysize>
</PageSize>
<Text s:type="y:string">test callback</Text>
</item>
</Notes>
</m:OnSynchronizeNotes>
</E:Body>
</E:Envelope>
They wanted to route traffic to one of two pools based on the value of the Source node in the XML document. |
Recent Articles
Other Resources
|


