public BaseResponseEntity CallCheckFrame(CheckFrameRequest model) { int iReturn = 511; _WsResponse = new BaseResponseEntity(); _WsResponse.WebService = "RXOCheckFrame"; _WsResponse.ErrorCode = iReturn; CheckFrameFullRequest _request = new CheckFrameFullRequest(); _request.Kunnr = model.Kunnr; _request.Upc = model.Upc; _request.Address = "https://certi-my.luxottica.com:443/Stores-WS/RXOServiceImplService"; _request.BasicAuth = true; _request.BasicAuthUsername = "******"; _request.BasicAuthPassword = "******"; _HTTPClient = new HTTPClient(1); iReturn = _HTTPClient.InvokeRXOCheckFrame(_request); _WsResponse.ErrorCode = iReturn; _WsResponse.ErrorDescription = DecodeResponseCodes(iReturn); return(_WsResponse); }
public int InvokeRXOCheckFrame(CheckFrameFullRequest _RXOCheckFrameRequest) { if (_RXOCheckFrameRequest == null) { return(501); } HttpWebRequest request = CreateWebRequest(_RXOCheckFrameRequest.Address, _RXOCheckFrameRequest); XmlDocument soapEnvelopeXml = new XmlDocument(); string stringRequest = @"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:rxo=""http://rxo.webservices.luxottica.it/""> <soapenv:Header/> <soapenv:Body> <rxo:rxoCheckFrame> <arg0>{0}</arg0> <arg1>{1}</arg1> </rxo:rxoCheckFrame> </soapenv:Body> </soapenv:Envelope>"; stringRequest = String.Format(stringRequest, _RXOCheckFrameRequest.Kunnr, _RXOCheckFrameRequest.Upc); soapEnvelopeXml.LoadXml(stringRequest); // // Logging // //if (_iLoggingLevel > (int)LoggingLevelEnums.None) //{ // ExceptionLoggingService.Instance.WriteRXOWSLog("HTTPClient.InvokeRXOCheckFrame", "rxoCheckFrame Request", soapEnvelopeXml.InnerXml.ToString()); //} using (Stream stream = request.GetRequestStream()) { soapEnvelopeXml.Save(stream); } try { using (WebResponse response = request.GetResponse()) { using (StreamReader rd = new StreamReader(response.GetResponseStream())) { string soapResult = rd.ReadToEnd(); Console.WriteLine(soapResult); // // Logging // //if (_iLoggingLevel > (int)LoggingLevelEnums.None) //{ // ExceptionLoggingService.Instance.WriteRXOWSLog("HTTPClient.InvokeRXOCheckFrame", "rxoCheckFrame Response", soapResult); //} // // Now parse the response // string strResponseCode = null; XDocument doc = XDocument.Parse(soapResult); XNamespace ns = "http://rxo.webservices.luxottica.it/"; IEnumerable <XElement> responses = doc.Descendants(ns + "rxoCheckFrameResponse"); foreach (XElement _element in responses) { strResponseCode = (string)_element.Element("return"); } if (strResponseCode != null) { int iReturnFromResponse = 500; Int32.TryParse(strResponseCode, out iReturnFromResponse); return(iReturnFromResponse); } else { return(501); } } } } //catch (HttpException httpex) //{ // return 501; //} catch (WebException webex) { if (webex.Status == WebExceptionStatus.ProtocolError) { var response = webex.Response as HttpWebResponse; if (response != null) { Console.WriteLine("HTTP Status Code: " + (int)response.StatusCode); return((int)response.StatusCode); } else { // no http status code available } } else { // no http status code available } } catch (Exception ex) { return(501); } return(0); }