Sunday, July 16, 2017

.NET Core 2.0 & old WebService error

1 comment

I've been trying to rewrite an older web application in the latest version of .NET Core. The project started out in .NET Core 1.1 but we quickly realized we'd have to move to .NET 2.0 (currently in preview 2) so that we could get access to DataSets/DataTables since our middleware service uses them and we're not looking to upgrade them as of right now.

From what I'm seeing everything is correct and connecting to the service works as expected when using the "HelloWorldAsync" test. The problem comes when we use our execute method that contains a DataSet as one of the parameters. I've literally boiled down the issue to that (the DataSet Paramenter) specific parameter.

Helper Method

    public async static Task<DataSet> CheckTIN(int TIN) {         ParameterArrayBuilder pab = new ParameterArrayBuilder();         pab.Add("@TIN", SqlDbType.Int, TIN);          DataSet ds = await GetData("usp_CheckTIN", pab);         if (ds == null) {             ds.Tables.Add();         }         return ds;     }      public async static Task<string> HellowWorldAsync() {         BusLogic40.FactorySoapClient factory = new BusLogic40.FactorySoapClient(BusLogic40.FactorySoapClient.EndpointConfiguration.FactorySoap, "http://localhost/BusLogic40/Request.asmx");         var result = await factory.HelloWorldAsync();          return result;     }      private async static Task<DataSet> GetData(string procedure, ParameterArrayBuilder pab) {         string ProviderName = "";         string Service = "";         string AuthKey = "";         string CmdName = procedure;          BusLogic40.FactorySoapClient factory = new BusLogic40.FactorySoapClient(BusLogic40.FactorySoapClient.EndpointConfiguration.FactorySoap, "http://localhost/BusLogic40/Request.asmx");          var theDataSet = await factory.ExecuteAsync(ProviderName, Service, AuthKey, CmdName, pab.AsDataSet());          if (theDataSet.Tables.Count > 0) {             return theDataSet;         } else {             return null;         }     } 

Results

Application version: 1.0.0.0 AspNetCoreEnvironment: Development Client IP address: ::1 DeveloperMode: true Event time: 7/5/2017 4:50:58 PM Exception type: System.ServiceModel.FaultException handledAt: Platform Message: System.Web.Services.Protocols.SoapException: Server was unable to read request.    ---> System.InvalidOperationException: There is an error in XML document (1, 1269).    ---> System.ArgumentException: Column requires a valid DataType.    at System.Data.DataColumn.set_DataType(Type value)    at System.Data.XSDSchema.SetProperties(Object instance, XmlAttribute[] attrs)    at System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement elem, DataTable table, Boolean isBase)    at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)    at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)    at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)    at System.Data.XSDSchema.HandleTable(XmlSchemaElement node)    at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)    at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)    at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)    at System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)    at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny)    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_Execute()    at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer4.Deserialize(XmlSerializationReader reader)    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)    --- End of inner exception stack trace ---    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()    --- End of inner exception stack trace ---    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest() Node name: Operation ID: 0HL63ONV9T29O Operation name: GET Home/Index Problem ID: System.ServiceModel.FaultException at Infx.FIDM.WebUI.SecureWebUI.Helpers.Utilities.GetData Role instance: SDK version: aspnet5c:2.0.0  Stack Trace System.ServiceModel.FaultException: System.Web.Services.Protocols.SoapException: Server was unable to read request.    ---> System.InvalidOperationException: There is an error in XML document (1, 1269).    ---> System.ArgumentException: Column requires a valid DataType.    at System.Data.DataColumn.set_DataType(Type value)    at System.Data.XSDSchema.SetProperties(Object instance, XmlAttribute[] attrs)    at System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement elem, DataTable table, Boolean isBase)    at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)    at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)    at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)    at System.Data.XSDSchema.HandleTable(XmlSchemaElement node)    at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)    at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)    at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)    at System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)    at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny)    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_Execute()    at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer4.Deserialize(XmlSerializationReader reader)    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)    --- End of inner exception stack trace ---    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()    --- End of inner exception stack trace ---    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()     at  System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)     at  System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)     at  System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()     at  Infx.FIDM.WebUI.SecureWebUI.Helpers.Utilities.<GetData>d__2.MoveNext() in C:\Projects\FIDMWeb\Infx.FIDM.WebUI.SecureWebUI\Helpers\Utilities.cs:line 32     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()     at  Infx.FIDM.WebUI.SecureWebUI.Helpers.Utilities.<CheckTIN>d__0.MoveNext() in C:\Projects\FIDMWeb\Infx.FIDM.WebUI.SecureWebUI\Helpers\Utilities.cs:line 11     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()     at  Infx.FIDM.WebUI.SecureWebUI.Controllers.HomeController.<Index>d__0.MoveNext() in C:\Projects\FIDMWeb\Infx.FIDM.WebUI.SecureWebUI\Controllers\HomeController.cs:line 8     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext()     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext()     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext()     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)     at  Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext()     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  Microsoft.VisualStudio.Web.BrowserLink.BrowserLinkMiddleware.<ExecuteWithFilter>d__7.MoveNext()     at  End of stack trace from previous location where exception was thrown ---     at  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()     at  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)     at  Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext() 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

1 comment:

  1. Any luck with your issue? I having similar problem when talking to webservices that have dataset as a parameter

    ReplyDelete