locked
Webservice throws exception "Expected text/xml" but got text/html

    Question

  • I access a Webservice written by our client developers.I call a method written by me and return a dataset to the client.This exception happens only when more than 3 users access the application fropm their client machines.

    I put tracing statements in my method and even put try-catch block in order to write to a log file if exception happens.But no errors are written to the log file from my method.

    But the control does not go back to the client code.It would take some tinme and throws this error ""Expected text/xml" but got text/html".

    Does anyone know how can i find out the real problem behind this, what is the actual problem that has occured?

     

    Pls help.

     

    Friday, December 01, 2006 8:41 AM

Answers

  • I can help you here.

    A web service returns by specification always the mime type text/xml. In this case the web server returned you text/html, which means that you got a HTML page as return. In this case it's an error message from the web server - 500 or similar - telling you that there has happend an internal error. Probably the web services has problems with concurrent users and is running into an error, resulting in returning you an error page (it could also be an ASP.NET error page, if the web services has been implemented using Visual Studio and .NET).

    Have you tried to look at the whole exception text? Aren't you getting also the HTML body?

    Friday, December 01, 2006 12:16 PM
  • good answer, also try hitting the web service .asmx URL in the web browser -- you may see HTML there.  in IE you'll have to disable the "show friendly HTTP error messages" feature -- it's in Tools -> Internet Options -> Advanced

    hope this helps

    alex

     

    Friday, December 01, 2006 9:11 PM
    Moderator
  • The web server doesn't need to return an html body for an error. The HTTP result could be set to 500 + content type to text/html and the body is empty. This is happening here, but it's for sure an error in the web service that causes this behaviour.
    Monday, December 04, 2006 1:41 PM

All replies

  • I can help you here.

    A web service returns by specification always the mime type text/xml. In this case the web server returned you text/html, which means that you got a HTML page as return. In this case it's an error message from the web server - 500 or similar - telling you that there has happend an internal error. Probably the web services has problems with concurrent users and is running into an error, resulting in returning you an error page (it could also be an ASP.NET error page, if the web services has been implemented using Visual Studio and .NET).

    Have you tried to look at the whole exception text? Aren't you getting also the HTML body?

    Friday, December 01, 2006 12:16 PM
  • good answer, also try hitting the web service .asmx URL in the web browser -- you may see HTML there.  in IE you'll have to disable the "show friendly HTTP error messages" feature -- it's in Tools -> Internet Options -> Advanced

    hope this helps

    alex

     

    Friday, December 01, 2006 9:11 PM
    Moderator
  • This is the exception i am getting when accessing a method(OpenLinkService.GetLoadDefinitionOleData) of the Webservice.This method is called from the client method(SummaryDetail.SummaryDetail_Load()).

     

    Err=[Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.

    The request failed with an empty response.]

     

    System.InvalidOperationException

     

       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)

       at Geac.PM.OpenLinkEnterprise.OpenLinkServiceProxy.OpenLinkService.GetLoadDefinitionOleData(String viewName, String username, String password, Int32 loadDefinitionClassID, Int32 periodID, Int32 yearID, String loadType)

       at Geac.PM.OpenLinkEnterprise.WorkFlowCommon.GetLoadDefinitionOleData(String loadType)

       at Geac.PM.OpenLinkEnterprise.SummaryDetailReport.SummaryDetail.FillData(String loadDefinitionName, String loadType)

       at Geac.PM.OpenLinkEnterprise.SummaryDetailReport.SummaryDetail.SummaryDetail_Load(Object sender, EventArgs e)

    --- End of [System.InvalidOperationException] inner exception stack trace ---

       at Geac.PM.Windows.Forms.ErrorDetailMessageBox.Initialize() in :line 0

       at Geac.PM.Windows.Forms.ErrorDetailMessageBox..ctor() in :line 0

       at Geac.PM.Windows.Forms.ErrorDetailMessageBox.Show() in :line 0

       at Geac.PM.OpenLinkEnterprise.OpenLinkCommon.ReportException() in :line 0

       at Geac.PM.OpenLinkEnterprise.SummaryDetailReport.SummaryDetail.SummaryDetail_Load() in :line 0

       at System.Windows.Forms.UserControl.OnLoad() in :line 0

       at System.Windows.Forms.UserControl.OnCreateControl() in :line 0

       at System.Windows.Forms.Control.CreateControl() in :line 0

       at System.Windows.Forms.Control.CreateControl() in :line 0

       at System.Windows.Forms.Control.CreateControl() in :line 0

       at System.Windows.Forms.Control.WmShowWindow() in :line 0

       at System.Windows.Forms.Control.WndProc() in :line 0

       at System.Windows.Forms.ScrollableControl.WndProc() in :line 0

       at System.Windows.Forms.ContainerControl.WndProc() in :line 0

       at System.Windows.Forms.Form.WmShowWindow() in :line 0

       at System.Windows.Forms.Form.WndProc() in :line 0

       at System.Windows.Forms.Control+ControlNativeWindow.OnMessage() in :line 0

       at System.Windows.Forms.Control+ControlNativeWindow.WndProc() in :line 0

       at System.Windows.Forms.NativeWindow.Callback() in :line 0

       at System.Windows.Forms.SafeNativeMethods.ShowWindow() in :line 0

       at System.Windows.Forms.Control.SetVisibleCore() in :line 0

       at System.Windows.Forms.Form.SetVisibleCore() in :line 0

       at System.Windows.Forms.Control.set_Visible() in :line 0

       at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner() in :line 0

       at System.Windows.Forms.Application+ThreadContext.RunMessageLoop() in :line 0

       at System.Windows.Forms.Form.ShowDialog() in :line 0

       at System.Windows.Forms.Form.ShowDialog() in :line 0

       at Geac.PM.OpenLinkEnterprise.WorkFlowClient.buttonSummaryVSDetail_Click() in :line 0

       at System.Windows.Forms.ToolStripItem.RaiseEvent() in :line 0

       at System.Windows.Forms.ToolStripButton.OnClick() in :line 0

       at System.Windows.Forms.ToolStripItem.HandleClick() in :line 0

       at System.Windows.Forms.ToolStripItem.HandleMouseUp() in :line 0

       at System.Windows.Forms.ToolStripItem.FireEventInteractive() in :line 0

       at System.Windows.Forms.ToolStripItem.FireEvent() in :line 0

       at System.Windows.Forms.ToolStrip.OnMouseUp() in :line 0

       at System.Windows.Forms.Control.WmMouseUp() in :line 0

       at System.Windows.Forms.Control.WndProc() in :line 0

       at System.Windows.Forms.ScrollableControl.WndProc() in :line 0

       at System.Windows.Forms.ToolStrip.WndProc() in :line 0

       at System.Windows.Forms.Control+ControlNativeWindow.OnMessage() in :line 0

       at System.Windows.Forms.Control+ControlNativeWindow.WndProc() in :line 0

       at System.Windows.Forms.NativeWindow.Callback() in :line 0

    )

     

    I am not getting any other details about what is wrong with the method.

     

     

     

    Monday, December 04, 2006 8:59 AM
  • The web server doesn't need to return an html body for an error. The HTTP result could be set to 500 + content type to text/html and the body is empty. This is happening here, but it's for sure an error in the web service that causes this behaviour.
    Monday, December 04, 2006 1:41 PM