Menu

[r11]: / trunk / SWFInvestigator / src / utils / AMFTransmitter.mxml  Maximize  Restore  History

Download this file

171 lines (151 with data), 6.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="utf-8"?>
<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:ParamHandlers="ParamHandlers.*"
width="801" height="581" title="AMF Transmitter" close="closePopUp()" backgroundColor="#60f3ea" showStatusBar="false">
<fx:Script>
<![CDATA[
/****************************************************************************
* ADOBE SYSTEMS INCORPORATED
* Copyright 2012 Adobe Systems Incorporated and it’s licensors
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file
* in accordance with the terms of the license agreement accompanying it.
* ****************************************************************************/
import osUtils.FileActionEvent;
import osUtils.FileActions;
import ParamHandlers.ObjectParser;
import ParamHandlers.ParamCollection;
import flash.net.registerClassAlias;
import mx.rpc.AbstractOperation;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.mxml.RemoteObject;
private var responseData:*;
private var fActions:FileActions;
/**
* @private
* This function parses the response from the AMF call and displays it in the text field.
*
* @param e The ResultEvent from the AMF call.
*/
private function parseResponse(e:ResultEvent):void {
if (typeof(e.result) == "boolean") {
if (e.result) {
this.amfOutput.text = "The call returned true!";
} else {
this.amfOutput.text = "The call returned false."
}
} else if (typeof(e.result) == "number") {
this.amfOutput.text = "The call returned the number: " + e.result;
} else if (typeof(e.result) == "string") {
this.amfOutput.text = "The call returned the string: " + e.result;
} else if (typeof(e.result) == "xml") {
this.amfOutput.text = e.result.toString();
} else {
var outputData:String = "";
this.responseData = e.result.source;
var OParser:ObjectParser = new ObjectParser()
outputData += OParser.arrayToString(this.responseData);
this.amfOutput.text = outputData;
}
this.statusOutput.text = "Success!";
}
/**
* @private
* This function is called when the AMF call issues a FaultEvent.
*
* @param e The FaultEvent from the AMF call
*/
private function showFault(e:FaultEvent):void {
this.amfOutput.text = e.messageId.toString() + ": " + e.message;
this.statusOutput.text = "Failed!";
}
/**
* @private
* This function will send the AMF request to the remote server based on the entered information.
*/
private function sendRequest():void {
var ro:RemoteObject = new RemoteObject(this.roDestination.text);
ro.endpoint = this.roEndpoint.text;
var params:Array = this.sendDG.getFuncParams();
var returnedData:Object;
ro.addEventListener(ResultEvent.RESULT,parseResponse);
ro.addEventListener(FaultEvent.FAULT,showFault);
if (this.roUsername && this.roUsername.text.length > 0) {
if (this.remoteCreds.selected) {
ro.setRemoteCredentials(this.roUsername.text,this.roPassword.text);
} else {
ro.setCredentials(this.roUsername.text, this.roPassword.text);
}
}
var roOp:AbstractOperation = ro.getOperation(this.roFunction.text);
if (params.length > 0) {
roOp.send(params[0]);
} else {
roOp.send();
}
}
/**
* @private
* Display error from File Action Event
*/
private function displayError(e:FileActionEvent):void {
this.statusOutput.text = e.message;
}
/**
* @private
* Prompt where to save the data
*/
private function saveAMFResponse():void {
if (this.fActions == null) {
this.fActions = new FileActions(3);
this.fActions.currentFile = File.documentsDirectory.resolvePath("/");
fActions.addEventListener(FileActionEvent.GENERAL_ERROR, displayError);
fActions.addEventListener(FileActionEvent.IO_ERROR, displayError);
fActions.addEventListener(FileActionEvent.CREATE_COMPLETE, saveFile);
}
this.fActions.openFile(null,FileActions.CREATE,"foo.amf");
}
/**
* @private
* Write data to the file
*/
private function saveFile(e:Event):void {
this.fActions.writeAMF(this.responseData);
this.fActions.closeFile();
}
/**
* @private
* On Window Close, ensure ObjectCollection PopUp is shut down.
*/
private function closePopUp():void {
this.sendDG.closePopUp();
}
]]>
</fx:Script>
<s:Label x="10" y="16" width="101" text="RO Endpoint:"/>
<s:TextInput x="119" y="10" width="269" id="roEndpoint" maxChars="4096"
toolTip="Example: http://www.example.com:8400/blazeds/messagebroker/amf"/>
<s:Label x="10" y="42" text="RO Destination:" width="101"/>
<s:TextInput x="119" y="36" width="269" id="roDestination"
toolTip="Example: This would be the id in the destination tag of your remoting-config.xml or proxy-config.xml"/>
<s:Label x="10" y="69" text="RO Function:" width="101"/>
<s:TextInput x="119" y="63" width="269" id="roFunction"
toolTip="This would be the name of an exposed funtion within the above destination"/>
<s:Label x="11" y="98" text="Auth Username:" width="101"/>
<s:TextInput x="120" y="92" width="267" id="roUsername"/>
<s:Label x="10" y="126" text="Auth Password:" width="101"/>
<s:TextInput x="121" y="120" width="267" id="roPassword"/>
<s:CheckBox x="124" y="150" label="Remote Credentials" width="147" id="remoteCreds"/>
<s:Label x="10" y="191" text="Function Parameters/New Value" width="223"/>
<ParamHandlers:ParamCollection x="10" y="209" width="372" id="sendDG" includeClass="true" includeObject="true" height="233"/>
<s:Button x="6" y="464" label="Submit Query" width="125" click="sendRequest()"/>
<s:Label x="423" y="21" text="Output" width="124"/>
<s:TextArea x="421" y="39" width="320" height="470" id="amfOutput"/>
<s:Label x="9" y="512" text="status" width="377" id="statusOutput"/>
<s:Button x="609" y="519" label="Save AMF Response" click="saveAMFResponse()"/>
<mx:VRule x="408" y="13" height="554"/>
</s:Window>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.