BizTalk - WebService失败 - 无法将“System.DBNull”类型的对象强制转换为“System.String”类型。 [英] BizTalk - WebService fails - Unable to cast object of type 'System.DBNull' to type 'System.String'.
问题描述
您好,
- WebServerA连接到SQLServer以检索日期' 我怀疑某些服务已关闭并重新启动会有所帮助,但我会推荐是否要找出导致此问题的根本原因?
I suspect some service went down and restart will help, but I would prefere to figure out the root cause of this ?
您将在WebServerA上采取哪些措施?
What actions would you reccoment to be taken on WebServerA ?
< td style ="border-bottom:solid#000000 1px;填充:7px 7px 7px 7px">
ERROR
------------------------------------------- -------------------------------------------------- ------------------------------
2016年6月15日18:01:18
类型:System.ServiceModel.FaultException`1 [[System.ServiceModel.ExceptionDetail,
System.ServiceModel,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]],System。 ServiceModel,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089消息:无法将'System.DBNull'类型的对象强制转换为'System.String'。
来源:mscorlib
帮助链接:
详细信息:ExceptionDetail,可能由IncludeExceptionDetailInFaults = true,
创建,其值为:System.InvalidCastException:
无法将'System.DBNull'类型的对象强制转换为'System.String'。at
LSB.Data.LSBProvider.RetrieveCafForms(DateTime datesLaterThan)at LSB.Business.LSBManager.RetrieveCafForms(DateTime datesLaterThan,
IEnumerable`1 databasesToUse)at LSB.WCF.MainService.LSBService.RetrieveCafForms(DateTime datesLaterThan)
在SyncInvokeRetrieveCafForms(对象,对象[],对象[])
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
instance,Object [] inputs,Object []& outputs)at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc)at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
操作:http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault
代码:System.ServiceModel.FaultCode
原因:无法将'System.DBNull'类型的对象强制转换为'System.String'。
数据:System.Collections.ListDictionaryInternal
TargetSite:Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage,
System.Runtime.Remoting.Messaging.IMessage)HResult:-2146233087
堆栈跟踪:
服务器堆栈跟踪:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message
reply,MessageFault fault,String action,MessageVersion version,FaultConverter faultConverter)at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
operation,ProxyRpc& rpc)at System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall,ProxyOperationRuntime操作)at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)在[0]处重新抛出异常:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg,IMessage retMsg)在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData,Int32 type)at ESD.ESDDataService.ILSBService.RetrieveCafForms(DateTime datesLaterThan)
at ESD.ESDDataService.LSBServiceClient.RetrieveCafForms(DateTime datesLaterThan)
at MForms.Service.ESD.ESDService.ReadCafDataFromExternalProvider(DateTime
datesLaterThan)at MForms.Service.ESD.ESDService.CafFormTimer_Elapsed(Object sender,
ElapsedEventArgs e)其他信息:
MachineName:PRDUCTIONMMO01
TimeStamp:15/06/2016 17:01:18
FullName:Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,Version = 4.1.0.0,
Culture = neutral,PublicKeyToken = 31bf3856ad364e35AppDomainName:ESDService.exe
ThreadIdentity:
WindowsIdentity:NT AUTHORITY \SYSTEM
类别:调试
优先级:0
EventId:100
严重性:错误
标题:企业库异常处理
Machine:PRDUCTIONMMO01
应用程序域:ESDService.exe
进程ID:2064
进程名称:E:\Program Files(x86)\ CFLY FDG SEZ \ESD Scheduler \ESDService.exe
Win32线程ID:5384
主题名称:
扩展属性:
------------ DEBUG_EVENT_LOG_END ------------
推荐答案
看起来SQL查询正在返回由于某种原因出现NULL,并且在尝试将DBNull转换为字符串时,您的Web服务代码正在崩溃。理想情况下,这应该在webservice / WCF代码中处理。检查数据库中
返回的日期值是否为DBNull ,如果是,则将WCF代码中的日期字段/变量分配给String.Empty(在您从WCF代码中的Web服务响应访问/分配的行中)。Looks like the SQL query is returning a NULL for some reason, and your webservice code is breaking while trying to convert the DBNull to string. Ideally, this should be handled within the webservice/WCF code. Check if the date value being returned from the database is DBNull, if yes then assign the date field/variable in WCF code to String.Empty instead (in the line where you are accessing/assigning from the web service response in your WCF code).
你知道从你的step1引起这个问题的确切查询吗?
Do you know the exact query that is causing this from your step1?
" WebServerA连接到SQLServer以检索日期'datesLaterThan'"
如果是,请尝试在SQL Server Management Studio中运行相同的操作。如果要返回NULL,则必须在WebSe中的WCF代码中处理此问题。 rverA如上所述。
If yes, try to run the same in SQL Server Management Studio. If you are getting back a NULL, you have to handle this within the WCF code in WebServerA as mentioned above.
参考 -
这篇关于BizTalk - WebService失败 - 无法将“System.DBNull”类型的对象强制转换为“System.String”类型。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆