/// <summary> /// заполняем dataGridItemsDocument and lables /// </summary> private void FillDataGridandLablesDocument() { ComarchEDIGetListMBFromXml_Result item = dataGridListMB.SelectedItem as ComarchEDIGetListMBFromXml_Result; if (item != null) { ComarchEDIGetDocOrderHeaderFromXml_Result headerDocument = SoapRequest.HeaderDocument(partnerIln, item.document_type_id, item.tracking_id).First(); lblВалюта.Content = headerDocument.Валюта; lblВремяДоставки.Content = headerDocument.ОжидаемоеВремяДоствки; lblДатаДоставки.Content = headerDocument.ОжидаемаяДатаДоставки; lblДатаЗаказа.Content = headerDocument.ДатаЗаказа; lblНомерЗаказа.Content = headerDocument.НомерЗаказа; lblЗаметка.Content = headerDocument.Remarks; lblКодПромоАкции.Content = headerDocument.КодПромоАкции; ComarchEDIGetDocOrderInfoBuyerFromXml_Result InfoBuyerDocument = SoapRequest.InfoBuyer(partnerIln, item.document_type_id, item.tracking_id).First(); lblПокупатель.Content = InfoBuyerDocument.GLNПокупателя; lblОтправитель.Content = InfoBuyerDocument.GLNОтправителя; lblКодПокупателя.Content = InfoBuyerDocument.КодПокупателя; lblЗаказСформировал.Content = InfoBuyerDocument.ЗаказаСформировал; lblМестоДоставки.Content = InfoBuyerDocument.GLNМестаДоставки; lblПолучательНакладной.Content = InfoBuyerDocument.GLNПолучателяНакладной; lblПродавец.Content = InfoBuyerDocument.GLNпродавца; lblПунктДоставки.Content = InfoBuyerDocument.DeliveryPlace; ComarchEDIGetDocOrderSummaryFromXml_Result orderSummaryDocument = SoapRequest.OrderSummary(partnerIln, item.document_type_id, item.tracking_id).First(); lblобщееКол.Content = orderSummaryDocument.ОбщееКолТовара; lblСуммаБезНДС.Content = orderSummaryDocument.СуммаБезНДС; lblСуммаСНДС.Content = orderSummaryDocument.СуммаЗПДВ; dataGridItemsDocument.ItemsSource = SoapRequest.LineItem(partnerIln, item.document_type_id, item.tracking_id); } }
public void Soap12Parser_ParsesHeaderAndBody(string soap, string expectedAction) { var requestStream = new MemoryStream(Encoding.UTF8.GetBytes(soap)); var action = SoapRequest.GetSoap12ActionFromInputStream(requestStream); action.Should().Be(expectedAction); }
protected override void OnStartup(StartupEventArgs e) { Properties.Settings App = new Properties.Settings(); // провереям подключение к WebService var client = new EDIWebServiceSoapClient("EDIWebServiceSoap"); string result = client.Relationships(App.LoginWebService, App.PasswordWebService, 1000).Res; client.Close(); if (!String.IsNullOrEmpty(SoapRequest.ResultWebRequest(result))) { MessageBox.Show(SoapRequest.ResultWebRequest(result), "Подключения к WebService", MessageBoxButton.OK, MessageBoxImage.Error); SettingWebSerice settingForm = new SettingWebSerice(); settingForm.ShowDialog(); // перезагружаем приложение System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } // проверяем подключения к бд if (!StatusApp.CheckConnection()) { MessageBox.Show("Нет соединение с базой данных , проверьте параметры подключения или обратитесь к системному администратору ", "Cоединение с базой данных", MessageBoxButton.OK, MessageBoxImage.Hand); ConnectionDataBase.ChangeConnect(); } }
public HttpResponse Request(string action, XDocument soapEnvelop) { var request = new SoapRequest(ServiceBaseUri, action); request.ApplyCredential(UserNetworkCredentials); return(request.Request(soapEnvelop)); }
public HttpResponse Request(string action, XDocument soapEnvelop) { var request = new SoapRequest(ServiceBaseUri, action); request.ApplyCredential(UserNetworkCredentials); return request.Request(soapEnvelop); }
/// <summary> /// Расширенный поиск документов /// </summary> private void btnSearchDocument_Click(object sender, RoutedEventArgs e) { DateTime?selectedDateFirst = datePickerFirst.SelectedDate; string dateFrom = Convert.ToDateTime(selectedDateFirst.Value.Date.ToShortDateString()).ToString("yyyy-MM-dd"); DateTime?selectedDateLast = datePickerLast.SelectedDate; string dateTo = Convert.ToDateTime(selectedDateLast.Value.Date.ToShortDateString()).ToString("yyyy-MM-dd"); dataGridListMB.ItemsSource = SoapRequest.DataListMBEx(partnerIln, documentType, documentVersion, dateFrom, dateTo, this.SelectedStatusDoc(cmbDocumentStatus.SelectedIndex)); }
public MainWindow() { InitializeComponent(); #region StatusBarElements lblStatus.Content = "WebService OK"; EllipseStatus.Fill = Brushes.GreenYellow; lblConnectionString.Content = ConnectionDataBase.Read(); #endregion // выводим список направлений cbxDirection.ItemsSource = StoredProcedureItems.getDirection(); // выводим список партнеров в EDI cbxPartnerILN.ItemsSource = SoapRequest.Relationships("DESADV"); }
/// <summary> /// Обновляет статус елипса в статус баре /// </summary> /// <param name="resSoapRequest">код ошибки</param> private void SetEllipseStatus(string resSoapRequest) { if (String.IsNullOrEmpty(SoapRequest.ResultWebRequest(resSoapRequest))) { EllipseStatus.Fill = Brushes.GreenYellow; lblStatus.Content = "WebService : Документ передан успешно"; } else { EllipseStatus.Fill = Brushes.Red; lblStatus.Content = "WebService :" + SoapRequest.ResultWebRequest(resSoapRequest); } }
public void GetBody_CheckXmlHeader_ShouldNotHaveXmlHeader() { SoapRequest request = new SoapRequest() { Action = "SomeAction", ServiceType = "SomeServiceType", ControlUrl = "/SomeUrl" }; string body = request.GetBody(); Assert.True(!body.StartsWith("<?xml")); }
public SignInStatus Authenticate(ref BRBUser user, string password) { var signInStatus = SignInStatus.Failure; var soapRequest = new SoapRequest { Source = "UserAuth", StaticDataFile = "AuthenticateUser_Response.xml", Url = "AuthenticateUser/RTSClientPortalAPI_API_WSD_AuthenticateUser_Port", Action = "RTSClientPortalAPI_API_WSD_AuthenticateUser_Binder_authenticateUserLogin" }; try { soapRequest.Body.Append("<api:authenticateUserLogin>"); soapRequest.Body.Append("<authenticateUserReq>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.AppendFormat("<pwd>{0}</pwd>", SafeString(password)); soapRequest.Body.Append("</authenticateUserReq>"); soapRequest.Body.Append("</api:authenticateUserLogin>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("authenticateUserRes")) { if (detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS")) { signInStatus = SignInStatus.Success; if (detail.SelectSingleNode("relationship") != null) { user.Relationship = detail.SelectSingleNode("relationship").InnerText; } user.IsFirstlogin = detail.SelectSingleNode("isFirstLogin").InnerText.ToUpper() == "TRUE"; user.IsTemporaryPassword = detail.SelectSingleNode("isTemporaryPwd").InnerText.ToUpper() == "TRUE"; } else { ErrorMessage = detail.SelectSingleNode("errorMsg").InnerText; } } } catch (Exception ex) { SetErrorMessage("Authenticate", ex); } return(signInStatus); }
private void btnImport_Click(object sender, RoutedEventArgs e) { string xmldocument = StoredProcedureItems.getXMLDESADV(Guid.Parse("{A4AD92BA-90AA-4059-A03B-0BCDDC91AD21}")); string res = SoapRequest.Send(partnerIln, "DESADV", "ECOD.UA", Guid.NewGuid().ToString(), xmldocument, documentTest: "P"); if (!String.IsNullOrEmpty(SoapRequest.ResultWebRequest(res))) { MessageBox.Show(SoapRequest.ResultWebRequest(res), "Подключения к WebService", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show(SoapRequest.ResultWebRequest(res), "Документ передан !!!", MessageBoxButton.OK, MessageBoxImage.Information); } }
public void GetBody_SingleArgument_ArgumentShouldBePresentInXml() { SoapRequest request = new SoapRequest { Action = "SomeAction", ServiceType = "SomeServiceType", ControlUrl = "/SomeUrl", Arguments = new Dictionary <string, object> { { "SomeArgument", "SomeValue" } } }; string body = request.GetBody(); Assert.True(body.Contains("<SomeArgument>SomeValue</SomeArgument>")); }
public async Task <IDictionary <string, string> > SendAction(string action, IDictionary <string, string> arguments) { SoapClient client = new SoapClient() { BaseAddress = new Uri(Service.BaseUrl) }; SoapRequest request = new SoapRequest() { Action = action, ServiceType = Service.Type, Arguments = arguments, ControlUrl = Service.ControlUrl }; return((await client.SendAsync(request)).Values); }
public ResponseType Execute <ResponseType>(SoapRequest <ResponseType> request) { // Create the url string url = string.Format(ACTIVESYNC_URL, _connection.Account.Account.ServerURL, "webservice", ServiceName, // TODO: this username is a bit of a quick hack. request.UserName ?? _connection.Account.Account.UserName, "webservice"); // Set up the encoding SoapRequestEncoder encoder = new SoapRequestEncoder(_connection.Account.Account.ServerURL, ServiceParameters, request); encoder.ServiceName = ServiceName; // Execute the request return((ResponseType)_connection.Execute(url, encoder)); }
public bool ConfirmUserProfile(BRBUser user) { var isConfirmed = false; var soapRequest = new SoapRequest { Source = "ConfirmProfile", Url = "ConfirmUserProfileByDeclaration/RTSClientPortalAPI_API_WSD_ConfirmUserProfileByDeclaration_Port", Action = "RTSClientPortalAPI_API_WSD_ConfirmUserProfileByDeclaration_Binder_confirmProfileInformation" }; try { soapRequest.Body.Append("<api:confirmProfileInformation>"); soapRequest.Body.Append("<profileConfirmationReq>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.AppendFormat("<securityQuestion1>{0}</securityQuestion1>", user.Question1.EscapeXMLChars()); soapRequest.Body.AppendFormat("<securityAnswer1>{0}</securityAnswer1>", user.Answer1.EscapeXMLChars()); soapRequest.Body.AppendFormat("<securityQuestion2>{0}</securityQuestion2>", user.Question2.EscapeXMLChars()); soapRequest.Body.AppendFormat("<securityAnswer2>{0}</securityAnswer2>", user.Answer2.EscapeXMLChars()); soapRequest.Body.AppendFormat("<declarationInitial>{0}</declarationInitial>", SafeString(user.DeclarationInitials)); soapRequest.Body.Append("</profileConfirmationReq>"); soapRequest.Body.Append("</api:confirmProfileInformation>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { isConfirmed = detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS"); if (!isConfirmed) { ErrorMessage = detail.ChildNodes[1].InnerText; } } } catch (Exception ex) { SetErrorMessage("ConfirmUserProfile", ex); } return(isConfirmed); }
public bool ResetUserPassword(ref BRBUser user) { var canReset = false; var soapRequest = new SoapRequest { Source = "ValidateReset", Url = "ValidateResetPasswordRequest/RTSClientPortalAPI_API_WSD_ValidateResetPasswordRequest_Port", Action = "RTSClientPortalAPI_API_WSD_ValidateResetPasswordRequest_Binder_validateResetUserPassword" }; try { soapRequest.Body.Append("<api:validateResetUserPassword>"); soapRequest.Body.Append("<resetUserPwdReq>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.AppendFormat("<securityQuestion1>{0}</securityQuestion1>", SafeString(user.Question1)); soapRequest.Body.AppendFormat("<securityAnswer1>{0}</securityAnswer1>", SafeString(user.Answer1)); soapRequest.Body.AppendFormat("<securityQuestion2>{0}</securityQuestion2>", SafeString(user.Question2)); soapRequest.Body.AppendFormat("<securityAnswer2>{0}</securityAnswer2>", SafeString(user.Answer2)); soapRequest.Body.Append("</resetUserPwdReq>"); soapRequest.Body.Append("</api:validateResetUserPassword>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { canReset = detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS"); if (!canReset) { ErrorMessage = detail.ChildNodes[1].InnerText; } } } catch (Exception ex) { SetErrorMessage("ResetUserPassword", ex); } return(canReset); }
public bool UpdateSecurityQuestions(ref BRBUser user) { var wasUpdated = false; var soapRequest = new SoapRequest { Source = "UpdateSecurityQuestions", Url = "UpdateUserProfileSecurityQA/RTSClientPortalAPI_API_WSD_UpdateUserProfileSecurityQA_Port", Action = "RTSClientPortalAPI_API_WSD_UpdateUserProfileSecurityQA_Binder_updateUserProfileSecurityQA" }; try { soapRequest.Body.Append("<api:updateUserProfileSecurityQA>"); soapRequest.Body.Append("<UpdateSecurityQAReq>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.AppendFormat("<securityQuestion1>{0}</securityQuestion1>", user.Question1.EscapeXMLChars()); soapRequest.Body.AppendFormat("<securityAnswer1>{0}</securityAnswer1>", user.Answer1.EscapeXMLChars()); soapRequest.Body.AppendFormat("<securityQuestion2>{0}</securityQuestion2>", user.Question2.EscapeXMLChars()); soapRequest.Body.AppendFormat("<securityAnswer2>{0}</securityAnswer2>", user.Answer2.EscapeXMLChars()); soapRequest.Body.Append("</UpdateSecurityQAReq>"); soapRequest.Body.Append("</api:updateUserProfileSecurityQA>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { wasUpdated = detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS"); if (!wasUpdated) { ErrorMessage = detail.ChildNodes[1].InnerText; } } } catch (Exception ex) { SetErrorMessage("ConfirmUserProfile", ex); } return(wasUpdated); }
/// <summary> /// Експортирует выбранные документы из журнала расхода в систему EDI /// </summary> /// <param name="documentType">тип документа</param> private void ExportDocument(string documentType) { // загружаем из DataGrid данные List <ComarchEDIЖурналРасходныхНакладных> ЖурналРасхода = (dataGridЖурналРасхода.ItemsSource as IEnumerable <ComarchEDIЖурналРасходныхНакладных>).ToList(); // проверяем выбран ли партнер EDI if (cbxPartnerILN.SelectedValue != null) { RelationshipsFromXml_Result PartnerILN = cbxPartnerILN.SelectedItem as RelationshipsFromXml_Result; if (MessageBox.Show(GetMessageDocumentType(documentType) + PartnerILN.partner_name + " ?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var IsexportCount = (from m in ЖурналРасхода where (m.isExport == true) select m).Count(); // проверяем пуст ли журнал расхода if (IsexportCount > 0) { foreach (var row in ЖурналРасхода) { // выбраны ли накладные для експорта if (row.isExport) { string xmldocument = GetDocumentEDI(documentType, row.ID_Операции); // если нет ошибок и документ не пуст, то отправляем в систему EDI if (!String.IsNullOrEmpty(xmldocument)) { string res = SoapRequest.Send(cbxPartnerILN.SelectedValue.ToString(), documentType, PartnerILN.document_version, Guid.NewGuid().ToString(), xmldocument, documentTest: "P"); StoredProcedureItems.SetTypeОперации(row.ID_Операции, documentType); SetEllipseStatus(res); } } } } else { MessageBox.Show("Выберите документы для експорта !!!", "Ошибка ", MessageBoxButton.OK, MessageBoxImage.Warning); } } } else { MessageBox.Show("Не выбран партнер EDI !!!", "Ошибка ", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public bool UpdateUserPassword(BRBUser user, string currentPassword, string newPassword, string reTypePwd) { var wasUpdated = false; var soapRequest = new SoapRequest { Source = "UpdatePassword", Url = "UpdatePassword/RTSClientPortalAPI_API_WSD_UpdatePassword_Port", Action = "RTSClientPortalAPI_API_WSD_UpdatePassword_Binder_updateUserPassword" }; try { soapRequest.Body.Append("<api:updateUserPassword>"); soapRequest.Body.Append("<updateUserPwdReq>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.AppendFormat("<currentPwd>{0}</currentPwd>", SafeString(currentPassword)); soapRequest.Body.AppendFormat("<newPwd>{0}</newPwd>", SafeString(newPassword)); soapRequest.Body.AppendFormat("<retypeNewPwd>{0}</retypeNewPwd>", SafeString(reTypePwd)); soapRequest.Body.Append("</updateUserPwdReq>"); soapRequest.Body.Append("</api:updateUserPassword>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { wasUpdated = detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS"); if (!wasUpdated) { ErrorMessage = detail.ChildNodes[1].InnerText; } } } catch (Exception ex) { SetErrorMessage("UpdateUserPassword", ex); } return(wasUpdated); }
public void Build(SoapRequest request) { using (Stream stream = request.Request.GetRequestStream()) { //write initial header WriteSoapHeader(stream); //write soap request WriteSoapBody(stream, request.SoapStr); //add attachment header WriteAttachmentHeader(stream, request.FileName); //write the zip file WriteFile(stream, request.FileContent); //write end of request WriteEndFile(stream); } }
/// <summary> /// Send SOAP with the following format /// </summary> /// <param name="body"></param> /// <param name="webServiceUri"></param> /// <param name="soapAction"></param> /// <param name="header"></param> /// <param name="host"></param> /// <param name="httpMethod"></param> /// <param name="contentType"></param> /// <param name="httpVersion"></param> /// <param name="throwExceptionIfHttpException"></param> /// <remarks> /// /// POST (@webServiceUri) HTTP/(@version) /// Host: (@webServiceUri.Host or @host) /// Content-Type: (@contentType) /// Content-Length: length /// SOAPAction: "(@soapAction)" /// /// <?xml version="1.0" encoding="utf-8"?> /// <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> /// <soap:Header> /// (@header) /// </soap:Header> /// <soap:Body> /// (@body) /// </soap:Body> /// </soap:Envelope> /// /// </remarks> /// <returns></returns> public static SoapResponse Send(SoapRequest soapRequest, bool throwExceptionIfHttpException = true) { var request = soapRequest.PreparHttpWebRequest(); // this just prepare the HttpHeaders var buffer = soapRequest.HttpBytes; // get the byte[] for Soap message var requestStream = request.GetRequestStream(); requestStream.Write(buffer, 0, buffer.Length); var response = (HttpWebResponse)request.GetResponse(); // response var result = new SoapResponse(response); if (throwExceptionIfHttpException && result.HttpStatusCodeNumber >= 400) { throw new WhiteMarsException(string.Format("Http Exception: {0} - {1}", result.HttpStatusCodeNumber, result.HttpStatusDescription)); } return result; }
/// <summary> /// Send SOAP with the following format /// </summary> /// <param name="body"></param> /// <param name="webServiceUri"></param> /// <param name="soapAction"></param> /// <param name="header"></param> /// <param name="host"></param> /// <param name="httpMethod"></param> /// <param name="contentType"></param> /// <param name="httpVersion"></param> /// <param name="throwExceptionIfHttpException"></param> /// <remarks> /// /// POST (@webServiceUri) HTTP/(@version) /// Host: (@webServiceUri.Host or @host) /// Content-Type: (@contentType) /// Content-Length: length /// SOAPAction: "(@soapAction)" /// /// <?xml version="1.0" encoding="utf-8"?> /// <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> /// <soap:Header> /// (@header) /// </soap:Header> /// <soap:Body> /// (@body) /// </soap:Body> /// </soap:Envelope> /// /// </remarks> /// <returns></returns> public static SoapResponse Send(SoapRequest soapRequest, bool throwExceptionIfHttpException = true) { var request = soapRequest.PreparHttpWebRequest(); // this just prepare the HttpHeaders var buffer = soapRequest.HttpBytes; // get the byte[] for Soap message var requestStream = request.GetRequestStream(); requestStream.Write(buffer, 0, buffer.Length); var response = (HttpWebResponse)request.GetResponse(); // response var result = new SoapResponse(response); if (throwExceptionIfHttpException && result.HttpStatusCodeNumber >= 400) { throw new WhiteMarsException(string.Format("Http Exception: {0} - {1}", result.HttpStatusCodeNumber, result.HttpStatusDescription)); } return(result); }
public SoapClientTests() { _soapRequest = new SoapRequest { ControlUrl = "SomeControlUrl", ServiceType = "SomeServiceType", Action = "SomeAction" }; _httpHandler = Substitute.For <IHttpHandler>(); _responseParser = Substitute.For <ISoapResponseParser>(); _reponseMessage = Substitute.For <HttpResponseMessage>(); _reponseMessage.Content = new ByteArrayContent(Encoding.UTF8.GetBytes("SomeContent")); _httpHandler.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(_reponseMessage); _soapClient = new SoapClient() { HttpHandler = _httpHandler, SoapResponseParser = _responseParser, BaseAddress = new Uri("http://SomeUri") }; }
public async Task <SoapResponse> Search(string url, string category, string term, int index = 0, int count = 100) { SoapClient client = new SoapClient() { BaseAddress = new System.Uri(url) }; var request = new SoapRequest() { Action = "search", Arguments = new Dictionary <string, string> { { "id", category }, { "term", term }, { "index", index.ToString() }, { "count", count.ToString() }, }, ControlUrl = "", ServiceType = "http://www.sonos.com/Services/1.1" }; return(await client.SendAsync(request)); }
/// <summary> /// заполняем DataGridListMB списком входящих документов /// </summary> private void FillDataGridListMB() { dataGridListMB.ItemsSource = SoapRequest.DataListMB(partnerIln, documentType, documentVersion); }
public bool Register(ref BRBUser user) { bool wasRegistered = false; var soapRequest = new SoapRequest { Source = "Register", Url = "ValidateRegistrationRequest/RTSClientPortalAPI_API_WSD_ValidateRegistrationRequest_Port", Action = "RTSClientPortalAPI.API.WSD.ValidateRegistrationRequest" }; try { soapRequest.Body.Append("<api:validateRegistrationRequest>"); soapRequest.Body.Append("<registrationRequestReq>"); soapRequest.Body.Append("<profileDetails>"); soapRequest.Body.AppendFormat("<userId>{0}</userId>", user.UserCode.EscapeXMLChars()); soapRequest.Body.AppendFormat("<billingCode>{0}</billingCode>", user.BillingCode.EscapeXMLChars()); soapRequest.Body.Append("<name>"); soapRequest.Body.Append("<!--Optional:--><first></first>"); soapRequest.Body.Append("<!--Optional:--><middle></middle>"); soapRequest.Body.AppendFormat("<last>{0}</last>", SafeString(user.LastName)); soapRequest.Body.Append("<suffix></suffix>"); soapRequest.Body.Append("<!--Optional:--><nameLastFirstDisplay></nameLastFirstDisplay>"); soapRequest.Body.Append("</name>"); soapRequest.Body.Append("<mailingAddress>"); soapRequest.Body.AppendFormat("<!--Optional:--><streetNumber>{0}</streetNumber>", SafeString(user.StreetNumber)); soapRequest.Body.AppendFormat("<!--Optional:--><streetName>{0}</streetName>", SafeString(user.StreetName)); soapRequest.Body.Append("<!--Optional:--><unitNumber></unitNumber>"); soapRequest.Body.Append("<fullAddress></fullAddress>"); soapRequest.Body.AppendFormat("<!--Optional:--><city>{0}</city>", SafeString(user.City)); soapRequest.Body.AppendFormat("<!--Optional:--><state>{0}</state>", SafeString(user.StateCode)); soapRequest.Body.AppendFormat("<!--Optional:--><zip>{0}</zip>", SafeString(user.ZipCode)); soapRequest.Body.Append("<!--Optional:--><country></country>"); soapRequest.Body.Append("</mailingAddress>"); soapRequest.Body.AppendFormat("<emailAddress>{0}</emailAddress>", SafeString(user.Email)); soapRequest.Body.AppendFormat("<phone>{0}</phone>", SafeString(user.PhoneNumber)); soapRequest.Body.Append("<securityQuestion1></securityQuestion1>"); soapRequest.Body.Append("<securityAnswer1></securityAnswer1>"); soapRequest.Body.Append("<securityQuestion2></securityQuestion2>"); soapRequest.Body.Append("<securityAnswer2></securityAnswer2>"); soapRequest.Body.Append("</profileDetails>"); soapRequest.Body.Append("<propertyDetails>"); soapRequest.Body.AppendFormat("<relationship>{0}</relationship>", SafeString(user.Relationship)); soapRequest.Body.AppendFormat("<ownerLastName>{0}</ownerLastName>", SafeString(user.PropertyOwnerLastName)); soapRequest.Body.AppendFormat("<address>{0}</address>", SafeString(user.PropertyAddress)); soapRequest.Body.Append("<purchaseYear></purchaseYear>"); soapRequest.Body.Append("</propertyDetails>"); soapRequest.Body.Append("</registrationRequestReq>"); soapRequest.Body.Append("</api:validateRegistrationRequest>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { Status = detail.ChildNodes[0].InnerText; if (Status.ToUpper() != "SUCCESS") { ErrorMessage = detail.ChildNodes[1].InnerText; } } wasRegistered = Status.ToUpper().Equals("SUCCESS"); } catch (Exception ex) { SetErrorMessage("Register", ex); } return(wasRegistered); }
public bool GetUnitTenants(ref BRBUser user) { var gotTenants = false; var soapRequest = new SoapRequest { Source = "GetPropertyTenants", StaticDataFile = "GetPropertyAndUnitDetails_Response.xml", Url = "GetPropertyAndUnitDetails/RTSClientPortalAPI_API_WSD_GetPropertyAndUnitDetails_Port", Action = "RTSClientPortalAPI_API_WSD_GetPropertyAndUnitDetails_Binder_getPropertyAndUnitDetails" }; try { user.CurrentUnit.Tenants = new List <BRBTenant>(); soapRequest.Body.Append("<api:getPropertyAndUnitDetails>"); soapRequest.Body.AppendFormat("<propertyId>{0}</propertyId>", SafeString(user.CurrentProperty.PropertyID)); soapRequest.Body.Append("<request>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.Append("</request>"); soapRequest.Body.Append("</api:getPropertyAndUnitDetails>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("propertyAndUnitsRes")) { foreach (XmlElement detailUnits in detail.GetElementsByTagName("units")) { var unitID = detailUnits.SelectSingleNode("unitId").InnerText; if (user.CurrentUnit.UnitID == detailUnits.SelectSingleNode("unitId").InnerText) { // // OCCUPANCY // if (detailUnits.SelectNodes("occupancy").Count > 0) // some Rented Units have no Occupants -- bad data? { if (detailUnits.GetElementsByTagName("noOfOccupants").Item(0) != null) { user.CurrentUnit.TenantCount = int.Parse(detailUnits.GetElementsByTagName("noOfOccupants").Item(0).InnerText); } if (detailUnits.GetElementsByTagName("initialRent").Item(0) != null) { user.CurrentUnit.InitialRent = detailUnits.GetElementsByTagName("initialRent").Item(0).InnerText; } if (detailUnits.GetElementsByTagName("datePriorTenancyEnded").Item(0) != null) { user.CurrentUnit.DatePriorTenancyEnded = DateTime.Parse(detailUnits.GetElementsByTagName("datePriorTenancyEnded").Item(0).InnerText); } if (detailUnits.GetElementsByTagName("reasonPriorTenancyEnded").Item(0) != null) { user.CurrentUnit.ReasonPriorTenancyEnded = detailUnits.GetElementsByTagName("reasonPriorTenancyEnded").Item(0).InnerText; } if (detailUnits.GetElementsByTagName("smokingProhibitionInLeaseStatus").Item(0) != null) { user.CurrentUnit.SmokingProhibitionInLeaseStatus = detailUnits.GetElementsByTagName("smokingProhibitionInLeaseStatus").Item(0).InnerText; } if (detailUnits.GetElementsByTagName("smokingProhibitionEffectiveDate").Item(0) != null) { DateTime dtSmokingProhibitionEffectiveDate = DateTime.MinValue; if (DateTime.TryParse(detailUnits.GetElementsByTagName("smokingProhibitionEffectiveDate").Item(0).InnerText, out dtSmokingProhibitionEffectiveDate)) { user.CurrentUnit.SmokingProhibitionEffectiveDate = dtSmokingProhibitionEffectiveDate; } } // // TENANTS // foreach (XmlElement detailOccBy in detailUnits.GetElementsByTagName("occupants")) { var tenant = new BRBTenant(); tenant.TenantID = detailOccBy.SelectSingleNode("occupantId").InnerText; tenant.FirstName = detailOccBy.SelectSingleNode("name").SelectSingleNode("firstName").InnerText; tenant.LastName = detailOccBy.SelectSingleNode("name").SelectSingleNode("lastName").InnerText; tenant.PhoneNumber = detailOccBy.SelectSingleNode("contactInfo").SelectSingleNode("phoneNumber").InnerText; tenant.Email = detailOccBy.SelectSingleNode("contactInfo").SelectSingleNode("emailAddress").InnerText; user.CurrentUnit.Tenants.Add(tenant); } } } } } gotTenants = true; } catch (Exception ex) { SetErrorMessage("GetUnitTenants", ex); } return(gotTenants); }
private XmlDocument GetXmlResponse(SoapRequest soapRequest) { WebRequest request = null; WebResponse response = null; Stream requestStream = null; Stream responseStream = null; StreamReader reader = null; var xmlDoc = new XmlDocument(); var soapMessage = NewSoapMessage(); var xmlString = ""; Status = ""; ErrorMessage = ""; try { if (USE_MOCK_SERVICES && !string.IsNullOrEmpty(soapRequest.StaticDataFile)) { xmlDoc = GetStaticXml(soapRequest.StaticDataFile); } else { soapMessage.Append("<soapenv:Header/>"); soapMessage.Append("<soapenv:Body>"); soapMessage.Append(soapRequest.Body.ToString()); soapMessage.Append("</soapenv:Body>"); soapMessage.Append("</soapenv:Envelope>"); Logger.Log(string.Format("{0}(request)", soapRequest.Source), soapMessage.ToString()); var soapByte = System.Text.Encoding.UTF8.GetBytes(soapMessage.ToString()); Logger.Log("SoapRequest URL", urlPrefix + soapRequest.Url); try { request = WebRequest.Create(urlPrefix + soapRequest.Url); request.Timeout = (int)TimeSpan.FromSeconds(10).TotalMilliseconds; request.Headers.Add("SOAPAction", soapRequest.Action); request.ContentType = "text/xml; charset=utf-8"; request.ContentLength = soapByte.Length; request.Method = "POST"; requestStream = request.GetRequestStream(); requestStream.Write(soapByte, 0, soapByte.Length); } catch (Exception ex) { throw ex; } try { response = request.GetResponse(); responseStream = response.GetResponseStream(); reader = new StreamReader(responseStream); xmlString = reader.ReadToEnd(); } catch (Exception ex) { throw ex; } Logger.Log(string.Format("{0}(response)", soapRequest.Source), xmlString); xmlDoc.LoadXml(xmlString); } } catch (Exception ex) { ErrorMessage = ex.Message; Logger.LogException(soapRequest.Action, ex); } finally { if (reader != null) { reader.Close(); reader.Dispose(); } if (requestStream != null) { requestStream.Close(); requestStream.Dispose(); } if (responseStream != null) { responseStream.Close(); responseStream.Dispose(); } if (response != null) { response.Close(); response.Dispose(); } } return(xmlDoc); }
public bool UpdateUserProfile(ref BRBUser user) { var wasUpdated = false; var soapRequest = new SoapRequest { Source = "UpdateProfile", Url = "UpdateUserProfile/RTSClientPortalAPI_API_WSD_UpdateUserProfile_Port", Action = "RTSClientPortalAPI_API_WSD_UpdateUserProfile_Binder_updateUserProfile" }; try { soapRequest.Body.Append("<api:updateUserProfile>"); soapRequest.Body.Append("<updateUserProfileReq>"); soapRequest.Body.AppendFormat("<!--Optional:--><userId>{0}</userId>", SafeString(user.UserCode)); soapRequest.Body.AppendFormat("<!--Optional:--><billingCode>{0}</billingCode>", SafeString(user.BillingCode)); soapRequest.Body.Append("<name>"); soapRequest.Body.AppendFormat("<first>{0}</first>", SafeString(user.FirstName)); soapRequest.Body.AppendFormat("<!--Optional:--><middle>{0}</middle>", SafeString(user.MiddleName)); soapRequest.Body.AppendFormat("<last>{0}</last>", SafeString(user.LastName)); soapRequest.Body.AppendFormat("<suffix>{0}</suffix>", SafeString(user.Suffix)); soapRequest.Body.Append("<!--Optional:--><nameLastFirstDisplay></nameLastFirstDisplay>"); soapRequest.Body.Append("</name>"); soapRequest.Body.Append("<mailingAddress>"); soapRequest.Body.AppendFormat("<!--Optional:--><streetNumber>{0}</streetNumber>", SafeString(user.StreetNumber)); soapRequest.Body.AppendFormat("<!--Optional:--><streetName>{0}</streetName>", SafeString(user.StreetName)); soapRequest.Body.AppendFormat("<!--Optional:--><unitNumber>{0}</unitNumber>", SafeString(user.UnitNumber)); soapRequest.Body.AppendFormat("<!--Optional:--><fullAddress>{0}</fullAddress>", SafeString(user.FullAddress)); soapRequest.Body.AppendFormat("<!--Optional:--><city>{0}</city>", SafeString(user.City)); soapRequest.Body.AppendFormat("<!--Optional:--><state>{0}</state>", SafeString(user.StateCode)); soapRequest.Body.AppendFormat("<!--Optional:--><zip>{0}</zip>", SafeString(user.ZipCode)); soapRequest.Body.AppendFormat("<!--Optional:--><country>{0}</country>", SafeString(user.Country)); soapRequest.Body.Append("</mailingAddress>"); soapRequest.Body.AppendFormat("<emailAddress>{0}</emailAddress>", SafeString(user.Email)); soapRequest.Body.AppendFormat("<phone>{0}</phone>", user.PhoneNumber); soapRequest.Body.AppendFormat("<securityQuestion1>{0}</securityQuestion1>", SafeString(user.Question1)); soapRequest.Body.AppendFormat("<securityAnswer1>{0}</securityAnswer1>", SafeString(user.Answer1)); soapRequest.Body.AppendFormat("<securityQuestion2>{0}</securityQuestion2>", SafeString(user.Question2)); soapRequest.Body.AppendFormat("<securityAnswer2>{0}</securityAnswer2>", SafeString(user.Answer2)); soapRequest.Body.Append("</updateUserProfileReq>"); soapRequest.Body.Append("<!--Optional:--><isActive>Y</isActive>"); soapRequest.Body.Append("</api:updateUserProfile>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { wasUpdated = detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS"); if (!wasUpdated) { ErrorMessage = detail.ChildNodes[2].InnerText; } } } catch (Exception ex) { Status = "FAILURE"; SetErrorMessage("UpdateUserProfile", ex); } return(wasUpdated); }
public bool UpdateUnit(ref BRBUser user) { var wasSaved = false; var soapRequest = new SoapRequest { Source = "SaveUnit", Url = "UpdateUnitStatusChange/RTSClientPortalAPI_API_WSD_UpdateUnitStatusChange_Port", Action = "RTSClientPortalAPI_API_WSD_UpdateUnitStatusChange_Binder_updateUnitStatusChange" }; try { var unit = user.CurrentUnit; soapRequest.Body.Append("<api:updateUnitStatusChange>"); soapRequest.Body.Append("<unitStatusChangeReq>"); soapRequest.Body.AppendFormat("<userId>{0}</userId>", user.UserCode); soapRequest.Body.AppendFormat("<propertyId>{0}</propertyId>", user.CurrentProperty.PropertyID); soapRequest.Body.AppendFormat("<unitId>{0}</unitId>", user.CurrentUnit.UnitID); soapRequest.Body.AppendFormat("<clientPortalUnitStatusCode>{0}</clientPortalUnitStatusCode>", unit.ClientPortalUnitStatusCode); soapRequest.Body.AppendFormat("<unitStatus>{0}</unitStatus>", unit.ClientPortalUnitStatusCode); soapRequest.Body.AppendFormat("<!--Optional:--><exemptionReason>{0}</exemptionReason>", unit.ExemptionReason); soapRequest.Body.AppendFormat("<declarationInitial>{0}</declarationInitial>", unit.DeclarationInitials); soapRequest.Body.Append("<questions>"); if (unit.StartDate.HasValue) { soapRequest.Body.AppendFormat("<!--Optional:--><dateStarted>{0}</dateStarted>", unit.StartDate.Value.AsShortDateFormat()); } else { soapRequest.Body.Append("<!--Optional:--><dateStarted></dateStarted>"); } if (unit.AsOfDate.HasValue) { soapRequest.Body.AppendFormat("<!--Optional:--><asOfDate>{0}</asOfDate>", unit.AsOfDate.Value.AsShortDateFormat()); } else { soapRequest.Body.AppendFormat("<!--Optional:--><asOfDate>{0}</asOfDate>", DateTime.Now.AsShortDateFormat()); } soapRequest.Body.AppendFormat("<!--Optional:--><occupiedBy>{0}</occupiedBy>", unit.OccupiedBy); soapRequest.Body.AppendFormat("<!--Optional:--><contractNo>{0}</contractNo>", unit.ContractNo); soapRequest.Body.AppendFormat("<!--Optional:--><commeUseDesc>{0}</commeUseDesc>", unit.CommUseDesc); soapRequest.Body.AppendFormat("<!--Optional:--><isCommeUseZoned>{0}</isCommeUseZoned>", unit.CommZoneUse); soapRequest.Body.AppendFormat("<!--Optional:--><isExclusivelyForCommeUse>{0}</isExclusivelyForCommeUse>", unit.CommResYN); // Next 3 removed when Owner Occupied Exempt Duplex was removed from the Other dropdown soapRequest.Body.Append("<!--Optional:--><_x0035_0PercentAsOf31Dec1979></_x0035_0PercentAsOf31Dec1979>"); soapRequest.Body.Append("<!--Optional:--><ownerOccupantName></ownerOccupantName>"); // OK: vb.net is same soapRequest.Body.Append("<!--Zero or more repetitions:--><namesOfownersOfRecord></namesOfownersOfRecord>"); soapRequest.Body.AppendFormat("<!--Optional:--><nameOfPropertyManagerResiding>{0}</nameOfPropertyManagerResiding>", unit.PropMgrName); soapRequest.Body.AppendFormat("<!--Optional:--><emailOfPhoneOfPropertyManagerResiding>{0}</emailOfPhoneOfPropertyManagerResiding>", unit.PMEmailPhone); soapRequest.Body.AppendFormat("<!--Optional:--><IsOwnersPrinciplePlaceOfResidence>{0}</IsOwnersPrinciplePlaceOfResidence>", unit.PrincResYN); soapRequest.Body.AppendFormat("<!--Optional:--><doesOwnerResideInOtherUnitOfThisUnitProperty>{0}</doesOwnerResideInOtherUnitOfThisUnitProperty>", unit.MultiUnitYN); soapRequest.Body.Append("<!--Zero or more repetitions:--><tenantsAndContactInfo>"); // OK: vb.net is same soapRequest.Body.AppendFormat("<name>{0}</name>", unit.TenantNames); soapRequest.Body.AppendFormat("<contactInfo>{0}</contactInfo>", unit.TenantContacts); soapRequest.Body.Append("</tenantsAndContactInfo>"); soapRequest.Body.Append("</questions>"); soapRequest.Body.Append("</unitStatusChangeReq>"); soapRequest.Body.Append("</api:updateUnitStatusChange>"); var xmlDoc = GetXmlResponse(soapRequest); foreach (XmlElement detail in xmlDoc.DocumentElement.GetElementsByTagName("response")) { wasSaved = detail.ChildNodes[0].InnerText.ToUpper().Equals("SUCCESS"); if (!wasSaved) { ErrorMessage = detail.ChildNodes[1].InnerText; } } } catch (Exception ex) { SetErrorMessage("UpdateUnit", ex); } return(wasSaved); }
public void ProcessRequest(HttpContext context) { #region Validations if (context == null) { throw new ArgumentNullException("context"); } #endregion /* * */ ExecutionHeader execution = new ExecutionHeader(); execution.ExecutionId = Guid.NewGuid(); execution.MomentStart = DateTime.UtcNow; /* * */ SoapRequest request = null; if (context.Request.Headers["SOAPAction"] != null) { request = new SoapRequest(); request.Version = SoapVersion.Soap11; request.SoapAction = context.Request.Headers["SOAPAction"]; request.SoapAction = request.SoapAction.Substring(1, request.SoapAction.Length - 2); } else { var values = context.Request.ContentType .Split(';') .Select(s => { var p = s.Split(new char[] { '=' }, 2); if (p.Length == 1) { return new { Key = "content-type", Value = p[0] } } ; else { return new { Key = p[0], Value = p[1] } }; }).ToList(); var contentType = values.FirstOrDefault(x => x.Key == "content-type"); var action = values.FirstOrDefault(x => x.Key == "action"); if (contentType?.Value == "application/soap+xml" && action != null) { request = new SoapRequest(); request.Version = SoapVersion.Soap12; request.SoapAction = action.Value.Substring(1, action.Value.Length - 2); } } if (request == null) { ActorException error = new WebException(ER.Soap_RequestNotSoap); var fault = ToFault(request.Version, execution, error); ResponseEmit(context, fault); return; } /* * Derive the rule being invoked, based on the URL of the request. */ if (request.SoapAction.StartsWith(WebServicesConfiguration.Current.Namespace) == false) { ActorException error = new WebException(ER.Soap_ActionUnsupported, request.SoapAction, WebServicesConfiguration.Current.Namespace); var fault = ToFault(request.Version, execution, error); ResponseEmit(context, fault); return; } string ruleName = request.SoapAction.Substring(WebServicesConfiguration.Current.Namespace.Length).Replace("/", "."); /* * */ using (var sr = new StreamReader(HttpContext.Current.Request.InputStream)) { sr.BaseStream.Seek(0, SeekOrigin.Begin); request.Message = sr.ReadToEnd(); } /* * Service NS - derived from the name of the rule :) */ string[] parts = ruleName.Split('.'); string serviceNs = string.Join("/", parts.Take(parts.Length - 2)) + "/"; /* * */ RuleRunner rr = new RuleRunner(); IRule rule = rr.Get(ruleName); if (rule == null) { ActorException error = new WebException(ER.Soap_ActionUnknown, request.SoapAction); var fault = ToFault(request.Version, execution, error); ResponseEmit(context, fault); return; } /* * */ XNamespace soapNs; if (request.Version == SoapVersion.Soap11) { soapNs = "http://schemas.xmlsoap.org/soap/envelope/"; } else { soapNs = "http://www.w3.org/2003/05/soap-envelope"; } XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable()); manager.AddNamespace("soap", soapNs.NamespaceName); /* * */ XDocument requestDoc; try { using (StringReader sr = new StringReader(request.Message)) { requestDoc = XDocument.Load(sr); } } catch (XmlException ex) { ActorException error = new WebException(ER.Soap_RequestNotXml, ex); var fault = ToFault(request.Version, execution, error); ResponseEmit(context, fault); return; } XElement element = requestDoc.XPathSelectElement(" /soap:Envelope/soap:Body/*[ 1 ] ", manager); if (element == null) { ActorException error = new WebException(ER.Soap_BodyNotFound); var fault = ToFault(request.Version, execution, error); ResponseEmit(context, fault); return; } /* * */ object oreq; XmlSerializer der = XmlSerializerFor(rule.RequestType, serviceNs); try { oreq = der.Deserialize(element.CreateReader()); } catch (InvalidOperationException ex) { ActorException error = new WebException(ER.Soap_RequestInvalid, ex, rule.Name, rule.RequestType.FullName); var fault = ToFault(request.Version, execution, error); ResponseEmit(context, fault); return; } /* * */ SoapResponse response; try { object oresp; oresp = rr.Run(rule, oreq); response = ToResponse(request.Version, execution, oresp, serviceNs); } catch (ActorException ex) { response = ToFault(request.Version, execution, ex); } catch (Exception ex) { ActorException aex = new WebException(ER.Soap_UnhandledException, ex); response = ToFault(request.Version, execution, aex); } /* * */ ResponseEmit(context, response); return; }
public virtual void Send(SoapRequest request) { throw new NotSupportedException("Mock exception."); }