开发者

Web services return xml error

All of the sudden all of the calls to my web services get this error:

2010-11-04 17:42:16,321 [9] ERROR ABCKiosk - System.InvalidOperationException: Response is not well-formed XML. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlTextReader.Read()
   at System.Xml.XmlReader.MoveToContent()
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   --- End of inner exception stack trace ---
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at ABCKiosk.WebServices.Services.ActivityLog(String kioskID, String KTID, String activityType, Int32 errorCodeFromIncentOne, String msgFromIncentOne, DateTime kioskTime) in D:\SMS SHANE\KIOSK\ABCNC_Kiosk\Implementation\Source Code\ABCKioskClient\ABCKiosk\Web References\WebServices\Reference.cs:line 121
   at ABCKiosk.FrmMain.FrmMain_KeyUp(Object sender, KeyEventArgs e) in D:\SMS SHANE\KIOSK\ABCNC_Kiosk\Implementation\Source Code\ABCKioskClient\ABCKiosk\FrmMain.cs:line 110

Before every were fine :( anyone know where is the problem and how to solve this?

Many thanks!

UPDATE - PROVIDE MORE INFORMATION

Here is one of my web methods:

[WebMethod(EnableSession = true)]
        public CommonResult ActivityLog(string kioskID, string KTID,
            string activityType, int errorCodeFromIncentOne, string msgFromI开发者_高级运维ncentOne, DateTime kioskTime)
        {
            XMLParser parser = new XMLParser(Server.MapPath(Constant.XML_CONFIGURATION_FILE_PATH));
            CommonResult result = new CommonResult();
            try
            {
                AccountDAO accountDAO = new AccountDAO();
                ActivityLogDAO activityLogDAO = new ActivityLogDAO();
                KioskDAO kioskDAO = new KioskDAO();

                // check if this kiosk is existed
                if (!kioskDAO.IsKioskIDExisted(kioskID))
                {
                    result.ErrorCode = Constant.ERROR_CODE_KIOSKID_NOT_EXISTED;
                    result.Message = "abc";
                    return result;
                }

                // check if this KTID is existed
                if (!accountDAO.IsKTIDExisted(KTID))
                {
                    result.ErrorCode = Constant.ERROR_CODE_KTID;
                    result.Message = "abc";
                    return result;
                }

                // check if this customer already logged for today
                if (activityLogDAO.IsLoggedForToday(KTID, DateTime.Now))
                {
                    result.ErrorCode = Constant.ERROR_CODE_LOG_LIMIT;
                    result.Message = "abc";
                    return result;
                }

                // begin log this activity to database
                activityLogDAO.ActivityLog(KTID, kioskID, kioskTime);

                // return success
                result.ErrorCode = Constant.ERROR_CODE_SUCCESS;
                result.Message = "abc";
                return result;
            }
            catch (Exception e)
            {
                result.ErrorCode = Constant.ERROR_CODE_SYSTEM_ERROR;
                result.Message = "abc";
                return result;
            }
        }

UPDATE

I tried running the webmethod locally, inspected the return page and saw this in the page source:

<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



            <br><br>



            <b> Exception Details: </b>System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/ActivityLog'.<br><br>



            <b>Source Error:</b> <br><br>



            <table width=100% bgcolor="#ffffcc">

               <tr>

                  <td>

                      <code>



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>



                  </td>

               </tr>

            </table>



            <br>



            <b>Stack Trace:</b> <br><br>



            <table width=100% bgcolor="#ffffcc">

               <tr>

                  <td>

                      <code><pre>



[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/ActivityLog'.]

   System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +405913

   System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212

   System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47

   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193

   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93

   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155

</pre></code>


I found out the bug myself, all because of a single line Response.Write() in the Session_Start() that mess up everything :(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜