[progress Communities] [progress Openedge Abl] Forum Post: Re: .net Equivalent To...

  • Thread starter Thread starter tbergman
  • Start date Start date
Status
Not open for further replies.
T

tbergman

Guest
For adding headers and setting content-type it's best to use the httpRequestMessage when using HttpClient. The code below shows another usage where headers anhd content type are set. Content-type is not an ordinary header like SOAPAction below. It needs to be done as a part of setting the content. The Uri should be just what you'd type in a browser, no href. httpClient = NEW System.Net.Http.HttpClient(). httpRequestMessage = NEW System.Net.Http.HttpRequestMessage(). httpRequestMessage:Method = System.Net.Http.HttpMethod:Post. httpRequestMessage:RequestUri = NEW System.Uri(vUrl). httpRequestMessage:Content = NEW System.Net.Http.StringContent(xmlRequest, System.Text.Encoding:UTF8, "text/xml"). httpRequestMessage:Headers:Add ("SOAPAction","~"~""). /* Use SendAsync in a synchronous manner by directly accessing the result */ httpResponseMessage = httpClient:SendAsync(httpRequestMessage):Result. xmlResponse = httpResponseMessage:Content:ReadAsStringAsync():RESULT NO-ERROR.

Continue reading...
 
Status
Not open for further replies.
Back
Top