public HttpClientWrapper(HttpClient httpClient, RequestHeaders requestHeaders = null) { _httpClient = httpClient; if (requestHeaders != null) _httpClient.DefaultHeaders = requestHeaders; }
public RestfulieProxy Create(object content) { var requestHeaders = new RequestHeaders { ContentType = _contentType }; var httpResponseMessage = _httpClient.Send(HttpMethod.POST, _uri, requestHeaders, HttpContent.Create(content.ToString())); return NewRestfulieProxy(httpResponseMessage); }
public HttpResponseMessage Send(HttpMethod method, Uri uri, RequestHeaders headers, HttpContent content) { throw new NotImplementedException(); }
public HttpResponseMessage Send(HttpMethod method, string uri, RequestHeaders headers) { throw new NotImplementedException(); }
public HttpRequestMessage(string method, Uri uri, RequestHeaders headers, HttpContent content) : this(method, uri,content) { this.headers = headers; }
public HttpRequestMessage(string method, Uri uri, RequestHeaders headers) : this(method, uri) { this.headers = headers; }
public HttpResponseMessage Send(HttpMethod method, Uri uri, RequestHeaders headers, HttpContent content) { return Send(new HttpRequestMessage(method.ToString(), uri, headers, content)); }
public HttpResponseMessage Send(HttpMethod method, string uri, RequestHeaders headers, HttpContent content) { return Send(method, new Uri(uri, UriKind.RelativeOrAbsolute), headers, content); }
public HttpResponseMessage Send(HttpMethod method, string uri, RequestHeaders headers) { return Send(method, uri, headers, null); }
/// <summary> /// Example of calling Actor.svc/participant to get participant details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SearchResults_SelectedIndexChanged(object sender, EventArgs e) { string siteid = Session["SessionID"].ToString(); string enterprise = Session["EnterpriseGUID"].ToString(); string baseurl = WebConfigurationManager.AppSettings["ETOSoftwareWS_BaseUrl"]; string clid = null; using (HttpClient client = new HttpClient(baseurl)) { RequestHeaders headers = new RequestHeaders(); headers.Add("enterpriseGuid", enterprise); headers.Add("securityToken", Session["SecurityToken"].ToString()); clid = SearchResults.SelectedValue; HttpResponseMessage resp = client.Send(HttpMethod.GET, "Actor.svc/participant/" + clid, headers); resp.EnsureStatusIsSuccessful(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Participant)); Participant participant = (Participant)ser.ReadObject(resp.Content.ReadAsStream()); PartNameLabel.Text = participant.FirstName + " " + participant.LastName; PartIdLabel.Text = participant.ID.ToString(); PartAddrLabel.Text = participant.Address1 + " " + participant.Address2; PartGenderLabel.Text = participant.Gender.ToString(); } DisplayAssessments(clid); }
/// <summary> /// Example of calling Security.svc/getsiteinfo to display details /// for a specific site. /// </summary> private void DisplaySiteInfo() { string siteid = Session["SessionID"].ToString(); string enterprise = Session["EnterpriseGUID"].ToString(); string baseurl = WebConfigurationManager.AppSettings["ETOSoftwareWS_BaseUrl"]; string securitytoken = Session["SecurityToken"].ToString(); string authtoken = Session["AuthToken"].ToString(); using (HttpClient client = new HttpClient(baseurl)) { RequestHeaders headers = new RequestHeaders(); headers.Add("Content-Type", "application/json"); headers.Add("enterpriseGuid", enterprise); headers.Add("securityToken", securitytoken); HttpResponseMessage resp = client.Send(HttpMethod.GET, "Security.svc/GetSiteInfo/" + siteid, headers); resp.EnsureStatusIsSuccessful(); DataContractJsonSerializer siteSer = new DataContractJsonSerializer(typeof(SiteInfo)); SiteInfo siteInfo = (SiteInfo)siteSer.ReadObject(resp.Content.ReadAsStream()); SiteNameLabel.Text = siteInfo.SiteName; AddressLabel.Text = siteInfo.Address1 + " " + siteInfo.Address2; PhoneLabel.Text = siteInfo.PhoneNumber; ZipLabel.Text = siteInfo.ZipCode; DisabledLabel.Text = siteInfo.Disabled ? "Yes" : "No"; } }
/// <summary> /// Example of calling Form.svc/Forms/Program/GetPrograms to get a /// list of programs for a specific site. /// </summary> private void DisplayPrograms() { string siteid = Session["SessionID"].ToString(); string enterprise = Session["EnterpriseGUID"].ToString(); string baseurl = WebConfigurationManager.AppSettings["ETOSoftwareWS_BaseUrl"]; using (HttpClient client = new HttpClient(baseurl)) { RequestHeaders headers = new RequestHeaders(); headers.Add("enterpriseGuid", enterprise); headers.Add("securityToken", Session["SecurityToken"].ToString()); HttpResponseMessage resp = client.Send(HttpMethod.GET, "Form.svc/Forms/Program/GetPrograms/" + siteid, headers); resp.EnsureStatusIsSuccessful(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ProgramInfo[])); ProgramInfo[] progInfo = (ProgramInfo[])ser.ReadObject(resp.Content.ReadAsStream()); foreach (ProgramInfo pinfo in progInfo) { ProgramDropList.Items.Add(new ListItem(pinfo.Name, pinfo.ID.ToString())); } } }
/// <summary> /// Example of calling Form.svc/Forms/Assessments/GetAllAssessementResponses /// to get a list of assessment responses for a participant. /// </summary> /// <param name="clid"></param> private void DisplayAssessments(string clid) { string siteid = Session["SessionID"].ToString(); string enterprise = Session["EnterpriseGUID"].ToString(); string baseurl = WebConfigurationManager.AppSettings["ETOSoftwareWS_BaseUrl"]; using (HttpClient client = new HttpClient(baseurl)) { RequestHeaders headers = new RequestHeaders(); headers.Add("enterpriseGuid", enterprise); headers.Add("securityToken", Session["SecurityToken"].ToString()); string body = "{\"CLID\":\""; body = body + clid + "\",\"surveyResponderType\":"; body = body + (int)SurveyResponderType.Client + "}"; HttpResponseMessage resp = client.Send(HttpMethod.POST, "Form.svc/Forms/Assessments/GetAllAssessementResponses/", headers, HttpContent.Create(body, "application/json; charset=utf-8")); resp.EnsureStatusIsSuccessful(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(AssessmentResponse[])); AssessmentResponse[] responses = (AssessmentResponse[])ser.ReadObject(resp.Content.ReadAsStream()); foreach (AssessmentResponse response in responses) { Panel2.Controls.Add(new LinkButton() { Text = response.SurveyName + " " + response.SurveyDate.ToString() + " " + response.SurveyResponseID.ToString() + " " + response.SurveyTaker }); } } }
/// <summary> /// Example of calling Search.svc/Search/ to search for participants /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SearchText_TextChanged(object sender, EventArgs e) { string siteid = Session["SessionID"].ToString(); string enterprise = Session["EnterpriseGUID"].ToString(); string baseurl = WebConfigurationManager.AppSettings["ETOSoftwareWS_BaseUrl"]; using (HttpClient client = new HttpClient(baseurl)) { RequestHeaders headers = new RequestHeaders(); headers.Add("enterpriseGuid", enterprise); headers.Add("securityToken", Session["SecurityToken"].ToString()); string programId = ProgramDropList.SelectedValue; string searchtext = SearchText.Text; HttpResponseMessage resp = client.Send(HttpMethod.GET, "Search.svc/Search/" + programId + "/" + searchtext, headers); resp.EnsureStatusIsSuccessful(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SearchResult[])); SearchResult[] results = (SearchResult[])ser.ReadObject(resp.Content.ReadAsStream()); if (results.Length == 0) { SearchResults.Items.Clear(); } else { foreach (SearchResult result in results) { SearchResults.Items.Add(new ListItem(result.FName + " " + result.LName, result.CLID.ToString())); } } } }