sharplife


software is a artwork, also make the life better !!!
  首页  :: 联系 :: 订阅 订阅  :: 管理

flex处理webservice异常

Posted on 2007-12-06 23:18  sharplife  阅读(1158)  评论(0编辑  收藏  举报
采用client flex+webservice的开发模式,很自然的,需要处理server端抛出的业务异常,本来是很普通的事,偏偏遇上flex,就有了特殊性了。

就现在来讲,flash player9不区分网络异常还是服务端抛出的业务异常,通通作为http request io error,并且得不到异常的详细信息,现在的解决办法总体上来讲,就是让server正常的抛出业务异常,在webservice response前加filter,定制soap fault信息,加入具体异常信息(server端和客户端互知),将异常的http status code 500改为正常返回的200,如此flex便可以继续fault事件处理,较之之前可以得到异常的详细信息了。

具体点,针对asp.net,自定义实现soapextension,通过web.config将其加入aspnet的webservice处理过程中去,在其中可以定制soap fault的detail xmlnode,加入相关的业务异常信息,提示一点soapextension的触发仅仅在soap请求被处理时,通过http get或post发出的webservice请求不行(如aspnet的webservice本地调试页面直接发出的请求——post,将不触发soapextension的处理),可以使用webservice studio进行调试,参见:
http://msdn.microsoft.com/msdnmag/issues/04/03/ASPColumn/
http://msdn2.microsoft.com/en-us/library/ds492xtk(vs.71).aspx
http://www.codeproject.com/KB/aspnet/ASPNETExceptionHandling.aspx
http://skipmeamadeus.blogspot.com/2007/09/aspnet-hack-for-processing-soap-faults.html
对于j2ee,采用xfire的可以参见http://stackoverflowexception.blogspot.com/search?updated-min=2007-01-01T00%3A00%3A00-08%3A00&updated-max=2008-01-01T00%3A00%3A00-08%3A00&max-results=8 ,采用filter处理,对于使用cxf和springside的,可以暂时仅使用简单的filter,并抛出简单异常信息(仅有message),默认填充在soap fault的faultstring节点,detail为空。

完整的处理书写,待有时间了吧!