This example passes and goes through:
GetTestSalesRequest req = new GetTestSalesRequest()
{
CurrentTest = new byte[] { 1 },
CurrentMTest = new byte[] { 4 },
UserName = this.gl_userName,// <---- is a string
UserPwd = new byte[] { 2 }
};
string test = await this.gl_client2.TestFunc(req);
System.Diagnostics.Debug.WriteLine("Test function: {0}", test);
This example fails.
GetTestSalesRequest req = new GetTestSalesRequest()
{
CurrentTest = CryptographicEngine.Encrypt(keySvr, Encoding.UTF8.GetBytes(test1.ToString()).AsBuffer(), null).ToArray(), // <---- is a byte[]
CurrentMTest = CryptographicEngine.Encrypt(keySvr, Encoding.UTF8.GetBytes(test2.ToString()).AsBuffer(), null).ToArray(), //<---- is a byte[]
UserName = this.gl_userName,// <---- is a string
UserPwd = this.gl_userPwd // <--- is a byte[]
};
string test = await this.gl_client2.TestFunc(req);
System.Diagnostics.Debug.WriteLine("Test function: {0}", test);
public async Task<string> TestFunc(GetTestSalesRequest request)
{
string resBody = null;
byte[] testStr = Encoding.UTF8.GetBytes(WebHelperClass.SerializeJSONObj<GetTestSalesRequest>(request));
string addr = string.Format("{0}/TestFunc/{1}", this.gl_baseAddr, Convert.ToBase64String(testStr));
WebRequest req = WebRequest.Create(addr);
HttpWebResponse res = await req.GetResponseAsync() as HttpWebResponse;
if (res.StatusCode == HttpStatusCode.OK)
{
using (Stream stream = res.GetResponseStream())
{
using (StreamReader sr = new StreamReader(stream))
{
resBody = sr.ReadToEnd();
sr.Dispose();
}
}
}
return resBody;
}
Is there a pitfall I'm going into here? What am I missing that is really obvious because this has to be possible to be done.






