Hi,
I'm trying to convert an excel file to byte array and passing the same to WCF service method.
I'm getting the following exception. Please help me to resolve this issue.
This is the below code chunk where I'm getting error and
SaveData(***) method is the one which calls the WCF service
string strFile = ViewState[GlobalConstants.strVsfilePath].ToString();
DataTable dtSaveData = new DataTable();
dtSaveData = (DataTable)ViewState[GlobalConstants.strVsOrginal];
DataSet dsSaveData = new DataSet();
dsSaveData.DataSetName = "dsfff";
dsSaveData.Tables.Add(dtSaveData);
dsSaveData.Tables[0].TableName = "dtfff";
string strResult = string.Empty;
MemoryStream stream = new MemoryStream();
dtSaveData.WriteXml(stream, true);
stream.Seek(0, SeekOrigin.Begin);
StreamReader sr = new StreamReader(stream);
string strInputXML = sr.ReadToEnd();
string strModifiedXml = strInputXML.Replace("+05:30", "");
byte[] btData = FileToByteArray(strFile);
File.Delete(strFile);
Stream streamData = new MemoryStream(btData);
adminsvc.SaveData(strModifiedXml, dsSaveData.DataSetName, dsSaveData.Tables[0].TableName, strType, strLoginName, "FIXED", btData, (string)ViewState["strWorkbookName"], (string)ViewState["SheetName"]);
Exception Detail
{System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ImportExchangeRates.AdminService.IAdminservice.SaveData(String strModifiedXml, String strDatasetName, String strDataTableName, String strModelName, String strLoginName, String strTableType, Byte[] bytWorkbook, String strWorkbookName, String strOuptuSheet)
at ImportExchangeRates.AdminService.AdminserviceClient.SaveData(String strModifiedXml, String strDatasetName, String strDataTableName, String strModelName, String strLoginName, String strTableType, Byte[] bytWorkbook, String strWorkbookName, String strOuptuSheet)