-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTCP_SOAP_Text.xml
executable file
·214 lines (190 loc) · 8.19 KB
/
TCP_SOAP_Text.xml
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<ConnectionProxies>
<Items>
<ConnectionProxy>
<Items>
<ConnectionProxyRuleSet>
<Items>
<ConnectionProxySyntaxItem>
<Items />
<DefaultValue>
</DefaultValue>
<Description>
</Description>
<Label>IP</Label>
<ShowInGui>True</ShowInGui>
<IsDefaultItem>False</IsDefaultItem>
<IsEmpty>False</IsEmpty>
</ConnectionProxySyntaxItem>
<ConnectionProxySyntaxItem>
<Items>
<Rule>
<Items />
<RegExp>
</RegExp>
<IgnoreCase>False</IgnoreCase>
<ValueType>intType</ValueType>
<DisplayAsPassword>False</DisplayAsPassword>
<Description>
</Description>
<Label>
</Label>
<ShowInGui>True</ShowInGui>
<IsDefaultItem>False</IsDefaultItem>
<IsEmpty>False</IsEmpty>
</Rule>
</Items>
<DefaultValue>
</DefaultValue>
<Description>Examples: application/x-www-form-urlencoded; application/x-amf</Description>
<Label>Port</Label>
<ShowInGui>True</ShowInGui>
<IsDefaultItem>False</IsDefaultItem>
<IsEmpty>False</IsEmpty>
</ConnectionProxySyntaxItem>
</Items>
<Connected>False</Connected>
<TracertField>1</TracertField>
<ChildDelimiter>;</ChildDelimiter>
<Description>
</Description>
<ShowInGui>True</ShowInGui>
<IsDefaultItem>False</IsDefaultItem>
<IsEmpty>False</IsEmpty>
</ConnectionProxyRuleSet>
<ConnectionProxyCode>
<Items />
<Code>/*
ConnectionProxy generated by vApus
vApus is Copyrighted by Sizing Servers Lab
University College of West-Flanders, Department GKG
Note: If you want to edit this connection proxy code you need to know what you are doing. You might break your stresstest.
VERSION @BRANCH@-@TM@
*/
//This connection proxy serves at sending text over a socket to the server, objects in the scenario are represented as SOAP strings.
// The following line is used to add references when compiling, you can edit this here or in the references tab page. Please use the 'Browse...' button for dlls that are not in the GAC.
// dllreferences:System.dll;System.Data.dll;vApus.Util.dll;vApus.SolutionTree.dll;vApus.Stresstest.dll;System.Net.dll;
#region Preprocessors
// Enable debug mode
//#define DEBUGMODE
#endregion // Preprocessors
#region Usings
using System;
using System.Data;
using System.Diagnostics;
using vApus.Util;
using System.Net.Sockets;
#endregion // Usings
namespace vApus.StressTest {
public class ConnectionProxy : IConnectionProxy {
#region Fields
Stopwatch _stopwatch = new Stopwatch();
bool _isDisposed;
// Please do not edit the following lines (RuleSetFields).
// -- RuleSetFields --
System.String _connectionProxySyntaxItem0 = string.Empty; // IP
System.Int32 _connectionProxySyntaxItem1; // Port
// -- RuleSetFields --
SocketWrapper _socketWrapper;
const int _sendBufferSize = 8912, _receiveBufferSize = 8912;
const int _content = 2;
#endregion // Fields
#region Properties
public bool IsConnectionOpen { get { return _socketWrapper != null && _socketWrapper.Connected; } }
public bool IsDisposed { get { return _isDisposed; } }
#endregion // Properties
public ConnectionProxy() {
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SendTimeout = 3000;
socket.ReceiveTimeout = 3000;
socket.SendBufferSize = _sendBufferSize;
socket.ReceiveBufferSize = _receiveBufferSize;
_socketWrapper = new SocketWrapper(_connectionProxySyntaxItem0, _connectionProxySyntaxItem1, socket);
}
#region Functions
public void TestConnection(out string error) {
error = null;
try {
OpenConnection();
if (IsConnectionOpen) {
CloseConnection();
}
else {
error = "Could not open the connection.";
}
}
catch (Exception ex) {
error = ex.ToString();
}
}
public void OpenConnection() {
if (!IsConnectionOpen) {
_socketWrapper.Connect(3000, 2);
}
}
public void CloseConnection() {
if (IsConnectionOpen) {
_socketWrapper.Close();
}
}
public void SendAndReceive(StringTree parameterizedRequest, out DateTime sentAt, out TimeSpan timeToLastByte, out string meta, out Exception exception) {
exception = null;
meta = null;
//
// parameterizedRequest is the request parsed to a String Tree using the Scenario Rule Set.
// String Tree is a simple class: it can have either a value (string Value { get; }) or childs who are also String Trees (e.g. StringTree foo = parameterizedRequest[n] where n is an integer value).
// You can get the combined value of the childs using the function CombineValues() (not shallow, returns a string), this uses the child delimiters in the rule set to glue these values together.
//
sentAt = HighResolutionDateTime.UtcNow;
if (_isDisposed) {
timeToLastByte = new TimeSpan();
return;
}
try {
_stopwatch.Start();
try {
string request = parameterizedRequest[_content].Value;
_socketWrapper.Send(request, SendType.Text);
_socketWrapper.Receive(SendType.Text);
}
catch (Exception ex) {
exception = ex;
#if DEBUGMODE
EventPanel.AddEvent("SendAndReceive Exception: " + parameterizedRequest.CombineValues() + " " + exception);
#endif
}
}
catch {
//
// Always throw the exception, if any, if 'stuff' cannot be closed.
// vApus will handle it as a connection problem.
//
throw;
}
finally {
_stopwatch.Stop();
timeToLastByte = _stopwatch.Elapsed;
_stopwatch.Reset();
}
}
public void Dispose() {
if (!_isDisposed) {
_isDisposed = true;
CloseConnection();
_socketWrapper = null;
}
}
#endregion // Functions
} // ConnectionProxy
} // vApus.Stresstest</Code>
<ShowInGui>True</ShowInGui>
<IsDefaultItem>False</IsDefaultItem>
<IsEmpty>False</IsEmpty>
</ConnectionProxyCode>
</Items>
<Label>TCP SOAP/Text @BRANCH@-@TM@</Label>
<ShowInGui>True</ShowInGui>
<IsDefaultItem>False</IsDefaultItem>
<IsEmpty>False</IsEmpty>
</ConnectionProxy>
</Items>
</ConnectionProxies>