EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElHTTPSClient .NET PostAsync

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#27869
Posted: 01/10/2014 00:07:46
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

Hello,

i have some code like this:

Code
var httpStatus = await HTTPSClient.PostAsync(uri).ConfigureAwait(false);
if (httpStatus == 200)
{
...
}


How i can geht the Post response Content?
I send some JSON and it will also return some JSON.

Is there other way than use this event?

Code
private void HTTPSClient_OnData(object Sender, byte[] Buffer)


I wish i had something like this from the .NET HttpClient Class:

Code
using (var client = new HttpClient(certHandler))
{

var jsonString = await client.PostAsync(uri, content).ConfigureAwait(false);
Stream c = await jsonString.Content.ReadAsStreamAsync();
[...]
}

Thank you for any suggestion
#27870
Posted: 01/10/2014 01:11:30
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

You can use both OnData event and OutputStream properties. What you wish to have is equal to using OutputStream property, which you just allocated beforehand.


Sincerely yours
Eugene Mayevski
#27871
Posted: 01/10/2014 01:28:39
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

Thank you for the reply.

So it should work like this?


Code
MemoryStream stream = new MemoryStream();
this.HTTPSClient.OutputStream = stream;

var httpStatus = await HTTPSClient.PostAsync(uri).ConfigureAwait(false);
                
if (httpStatus == 200)
{

}


The stream is always null, in the OnData Event i can see the Response.
#27872
Posted: 01/10/2014 01:51:39
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
So it should work like this?

Yes it should work.

Quote
The stream is always null

Do you mean its empty or HTTPSClient.OutputStream is null after PostAsync invocation?
#27877
Posted: 01/10/2014 02:36:40
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

Hello,

seems i have no a other problem.
The stream is not null now, so it is working.


My DataContractJsonSerializer have a problem to read the MemoryStream with ReadObject.

At the moment i need to convert it to a string an read it back to a stream.

But i think this is no eldos problem :)

Thank you
#27878
Posted: 01/10/2014 02:40:57
by Vsevolod Ievgiienko (EldoS Corp.)

JFYI: we have TElRESTClient component that has built-in support for JSON and XML responses handling. You can get JSON response using its TElRESTClient.ResponseJSON property and then work with it using our JSON classes.
#27879
Posted: 01/10/2014 02:41:49
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
My DataContractJsonSerializer have a problem to read the MemoryStream with ReadObject.

Do you set stream position to '0' after Post invocation and before passing it to your DataContractJsonSerializer ?
#27880
Posted: 01/10/2014 02:43:48
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

Is it included in the SecureBlackBox Package?
Can you post me the link to the class description?

Thank you
#27881
Posted: 01/10/2014 02:46:24
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
Is it included in the SecureBlackBox Package?

Yes its a part of HTTPBlackbox but unfortunately the documentation is not ready yet.
#27882
Posted: 01/10/2014 02:50:06
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

I will give it a try :)

Quote
Position = 0;


just forgot to set ... now it works like with my old .NET HttpClient.

Thank you very much!
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 2216 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!