There is a WCF service. The method i have to access has 1 parameter as input whoes type is Stream.
I don't know how to provide stream object from JMeter to the WCF service.
Currently i have written a C# method (MVC Project) which accepts string from JMeter and then converts it into Stream type object, Which is than processed by the WCF service. But this approach does not give does not give the actual performance of the WCF service
[WebInvoke(UriTemplate = "", Method = "POST")]
[OperationContract]
public Stream ReceiveChirp(Stream fileContents)
{
string response = "";
long ticks = DateTime.Now.Ticks;
DateTime receiveTime = DateTime.Now;
Currently i am getting an exception of object type.
Here is the exception :
<p class="heading1">Request Error</p>
<p xmlns="">The server encountered an error processing the request. Please see the <a rel="help-page" href="http://t2vnmeterservicessciexp.cloudapp.net/ReceiveChirp/help">service help page</a> for constructing valid requests to the service. The exception message is 'Object reference not set to an instance of an object.'. See server logs for more details. The exception stack trace is: </p>
<p> at Base.VN.Core.Generic.GenericExtensions.ChirpGenerator.ConvertStringToByteArray(String input)
at T2.VN.Core.MeterServices.MainEndPoint.ReceiveChirp(Stream fileContents)
at SyncInvokeReceiveChirp(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>
The code my colleague is using to unit test the same:
public string TestServicePacket(string data)
{
var url = "http://test.net/";
var requestUrl = string.Format("{0}/ReceiveChirp/", url);
var request = (HttpWebRequest)WebRequest.Create(requestUrl);
request.Timeout = Timeout.Infinite;
request.Method = "POST";
request.ContentType = "text/plain";
var dataTrailing = "&UserName=eReg&UserPassword=abc123";
var dataTrailingBytes = Encoding.ASCII.GetBytes(dataTrailing);
var bChirp = ConvertStringToByteArray(data);
var ToSend = new byte[dataTrailingBytes.Length + bChirp.Length];
ToSend = bChirp.Concat(dataTrailingBytes).ToArray();
request.ContentLength = ToSend.Length;
using (var requestStream = request.GetRequestStream())
{
// Send the file as body request.
requestStream.Write(ToSend, 0, ToSend.Length);
requestStream.Close();
}
var response = (HttpWebResponse)request.GetResponse();
var responseStream = response.GetResponseStream();
var memoryStream = new MemoryStream();
string resultResponse;
resultResponse = ConvertStream(responseStream);
return resultResponse;
}
We can use Java Request Sampler here. We can write customized code create our own data in byte stream and do GET/POST. We can look at the code of the HttpSampler and in the post/get method, we can return a byte array instead of the String.
Through Http Sampler it is not possible to send byte array. i.e. HTTP Sampler only works with String