Professional Web Applications Themes

Web Service throws exception during Application_Start - ASP.NET Web Services

We have some static information load from web.config during the application_start of our web service. However, if there is an error during this startup, the consumer gets back an ugly error message starting like: Client found response content type of 'text/html; cht=utf-8', but expected 'text/xml'. The request failed with the error message: -- Errors in the Global class seem to step outside of the Soap Fault standards. What is worse is that even though there is an error on Startup, the Web Service actually starts up. But of course the code in Application_Start did not complete so now the Web ...

  1. #1

    Default Web Service throws exception during Application_Start

    We have some static information load from web.config during the
    application_start of our web service.

    However, if there is an error during this startup, the consumer gets back an
    ugly error message starting like: Client found response content type of
    'text/html; cht=utf-8', but expected 'text/xml'. The request failed with
    the error message: --

    Errors in the Global class seem to step outside of the Soap Fault standards.

    What is worse is that even though there is an error on Startup, the Web
    Service actually starts up. But of course the code in Application_Start did
    not complete so now the Web Service is running in error.

    Am I correct or am I doing something wrong?

    fm
    fm@newsgroups.nospam Guest

  2. #2

    Default Re: Web Service throws exception during Application_Start

    ASMX web services use the ASP.NET pipeline. If there is an error in
    Application_Start, it will be returned to the client as an IIS error page.
    One workaround is that you could trap all errors in Application_Error and
    "hand-write" a SOAP envelope with an appropriate SOAP fault to the response.

    Mujtaba.

    <fmnewsgroups.nospam> wrote in message
    news:649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com...
    > We have some static information load from web.config during the
    > application_start of our web service.
    >
    > However, if there is an error during this startup, the consumer gets back
    an
    > ugly error message starting like: Client found response content type of
    > 'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    with
    > the error message: --
    >
    > Errors in the Global class seem to step outside of the Soap Fault
    standards.
    >
    > What is worse is that even though there is an error on Startup, the Web
    > Service actually starts up. But of course the code in Application_Start
    did
    > not complete so now the Web Service is running in error.
    >
    > Am I correct or am I doing something wrong?
    >
    > fm

    Mujtaba Syed Guest

  3. #3

    Default RE: Web Service throws exception during Application_Start

    Something else you can do is change the auto-generated HTML page for
    specific errors. By default, these are HTML, but you can change them from
    the IIS administration console.

    Since you are having this kind of problem I wonder why are you doing
    applicaiton start kind of logic? In general, you want web services to be
    stateless. Using the application start feature implies you aren't staying
    statless - which may be a cause of frustration for you ongoing. The
    application.start, session, etc are ASP programming model entities for
    managing web sites and web page based applications (using a general tone
    here - I'm sure that there are exceptions to the rule as always).

    Try NOT using applicaiton start for your web services....

    Regards

    Dan Rogers
    Microsoft Corporation
    --------------------
    >Thread-Topic: Web Service throws exception during Application_Start
    >thread-index: AcTfFIGVnDpe3DTaRYyAMlLJYzTwRg==
    >X-WBNR-Posting-Host: 192.41.148.220
    >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    >Subject: Web Service throws exception during Application_Start
    >Date: Fri, 10 Dec 2004 16:01:03 -0800
    >Lines: 17
    >Message-ID: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    >MIME-Version: 1.0
    >Content-Type: text/plain;
    > cht="Utf-8"
    >Content-Transfer-Encoding: 7bit
    >X-Newsreader: Microsoft CDO for Windows 2000
    >Content-Class: urn:content-classes:message
    >Importance: normal
    >Priority: normal
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    >Xref: cpmsftngxa10.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webservic es:27147
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >
    >We have some static information load from web.config during the
    >application_start of our web service.
    >
    >However, if there is an error during this startup, the consumer gets back
    an
    >ugly error message starting like: Client found response content type of
    >'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    with
    >the error message: --
    >
    >Errors in the Global class seem to step outside of the Soap Fault
    standards.
    >
    >What is worse is that even though there is an error on Startup, the Web
    >Service actually starts up. But of course the code in Application_Start
    did
    >not complete so now the Web Service is running in error.
    >
    >Am I correct or am I doing something wrong?
    >
    >fm
    >
    Dan Rogers Guest

  4. #4

    Default RE: Web Service throws exception during Application_Start

    During application startup, we are loading static values from web.config. We
    expose those values to the rest of the application as shared properties in
    the Global class. This is to be consistent with our ASP.NET web applications.
    I suppose we could load these values on session start for web services but
    that seems like a lot of extra processing during runtime. Perhaps with web
    services we should have the code call our web.config wrapper methods
    directly. But then you loose that layer of abstraction if we move the
    location of those values (to a database or other data store).

    The only times this logic should bomb is if web.config does not match what
    the code is trying to read (that is how I discovered this problem). But the
    fact is it could still error out. I think one thing I will investigate is
    throwing a hand-written SOAP envelope (does not sound too pretty either).



    "Dan Rogers" wrote:
    > Something else you can do is change the auto-generated HTML page for
    > specific errors. By default, these are HTML, but you can change them from
    > the IIS administration console.
    >
    > Since you are having this kind of problem I wonder why are you doing
    > applicaiton start kind of logic? In general, you want web services to be
    > stateless. Using the application start feature implies you aren't staying
    > statless - which may be a cause of frustration for you ongoing. The
    > application.start, session, etc are ASP programming model entities for
    > managing web sites and web page based applications (using a general tone
    > here - I'm sure that there are exceptions to the rule as always).
    >
    > Try NOT using applicaiton start for your web services....
    >
    > Regards
    >
    > Dan Rogers
    > Microsoft Corporation
    > --------------------
    > >Thread-Topic: Web Service throws exception during Application_Start
    > >thread-index: AcTfFIGVnDpe3DTaRYyAMlLJYzTwRg==
    > >X-WBNR-Posting-Host: 192.41.148.220
    > >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    > >Subject: Web Service throws exception during Application_Start
    > >Date: Fri, 10 Dec 2004 16:01:03 -0800
    > >Lines: 17
    > >Message-ID: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    > >MIME-Version: 1.0
    > >Content-Type: text/plain;
    > > cht="Utf-8"
    > >Content-Transfer-Encoding: 7bit
    > >X-Newsreader: Microsoft CDO for Windows 2000
    > >Content-Class: urn:content-classes:message
    > >Importance: normal
    > >Priority: normal
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    > >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    > >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > >Xref: cpmsftngxa10.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.webservic es:27147
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    > >
    > >We have some static information load from web.config during the
    > >application_start of our web service.
    > >
    > >However, if there is an error during this startup, the consumer gets back
    > an
    > >ugly error message starting like: Client found response content type of
    > >'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    > with
    > >the error message: --
    > >
    > >Errors in the Global class seem to step outside of the Soap Fault
    > standards.
    > >
    > >What is worse is that even though there is an error on Startup, the Web
    > >Service actually starts up. But of course the code in Application_Start
    > did
    > >not complete so now the Web Service is running in error.
    > >
    > >Am I correct or am I doing something wrong?
    > >
    > >fm
    > >
    >
    >
    fm@newsgroups.nospam Guest

  5. #5

    Default Re: Web Service throws exception during Application_Start

    Hi:

    One solution could be to have a singleton-instance class that loads all the
    properties. The constructor of that class reads the web.config and has
    public properties that exposes those settings. And in all web methods that
    you want to use the configuration key/value pairs, you get hold of that
    singleton instance and invoke properties on it. The *first call to any web
    method* will do the *actual loading from web.config* and incase there is an
    error, it will go as a SOAP fault.

    Hope this helps,
    Mujtaba.

    <fmnewsgroups.nospam> wrote in message
    news:70149971-4270-49A3-B95A-0E4F823AE213microsoft.com...
    > During application startup, we are loading static values from web.config.
    We
    > expose those values to the rest of the application as shared properties in
    > the Global class. This is to be consistent with our ASP.NET web
    applications.
    > I suppose we could load these values on session start for web services but
    > that seems like a lot of extra processing during runtime. Perhaps with web
    > services we should have the code call our web.config wrapper methods
    > directly. But then you loose that layer of abstraction if we move the
    > location of those values (to a database or other data store).
    >
    > The only times this logic should bomb is if web.config does not match what
    > the code is trying to read (that is how I discovered this problem). But
    the
    > fact is it could still error out. I think one thing I will investigate is
    > throwing a hand-written SOAP envelope (does not sound too pretty either).
    >
    >
    >
    > "Dan Rogers" wrote:
    >
    > > Something else you can do is change the auto-generated HTML page for
    > > specific errors. By default, these are HTML, but you can change them
    from
    > > the IIS administration console.
    > >
    > > Since you are having this kind of problem I wonder why are you doing
    > > applicaiton start kind of logic? In general, you want web services to
    be
    > > stateless. Using the application start feature implies you aren't
    staying
    > > statless - which may be a cause of frustration for you ongoing. The
    > > application.start, session, etc are ASP programming model entities for
    > > managing web sites and web page based applications (using a general tone
    > > here - I'm sure that there are exceptions to the rule as always).
    > >
    > > Try NOT using applicaiton start for your web services....
    > >
    > > Regards
    > >
    > > Dan Rogers
    > > Microsoft Corporation
    > > --------------------
    > > >Thread-Topic: Web Service throws exception during Application_Start
    > > >thread-index: AcTfFIGVnDpe3DTaRYyAMlLJYzTwRg==
    > > >X-WBNR-Posting-Host: 192.41.148.220
    > > >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    > > >Subject: Web Service throws exception during Application_Start
    > > >Date: Fri, 10 Dec 2004 16:01:03 -0800
    > > >Lines: 17
    > > >Message-ID: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    > > >MIME-Version: 1.0
    > > >Content-Type: text/plain;
    > > > cht="Utf-8"
    > > >Content-Transfer-Encoding: 7bit
    > > >X-Newsreader: Microsoft CDO for Windows 2000
    > > >Content-Class: urn:content-classes:message
    > > >Importance: normal
    > > >Priority: normal
    > > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    > > >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    > > >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > > >Xref: cpmsftngxa10.phx.gbl
    > > microsoft.public.dotnet.framework.aspnet.webservic es:27147
    > > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    > > >
    > > >We have some static information load from web.config during the
    > > >application_start of our web service.
    > > >
    > > >However, if there is an error during this startup, the consumer gets
    back
    > > an
    > > >ugly error message starting like: Client found response content type of
    > > >'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    > > with
    > > >the error message: --
    > > >
    > > >Errors in the Global class seem to step outside of the Soap Fault
    > > standards.
    > > >
    > > >What is worse is that even though there is an error on Startup, the Web
    > > >Service actually starts up. But of course the code in Application_Start
    > > did
    > > >not complete so now the Web Service is running in error.
    > > >
    > > >Am I correct or am I doing something wrong?
    > > >
    > > >fm
    > > >
    > >
    > >

    Mujtaba Syed Guest

  6. #6

    Default Re: Web Service throws exception during Application_Start

    Thanks, I will consider that. Like a Global on top of a Global :)

    "Mujtaba Syed" wrote:
    > Hi:
    >
    > One solution could be to have a singleton-instance class that loads all the
    > properties. The constructor of that class reads the web.config and has
    > public properties that exposes those settings. And in all web methods that
    > you want to use the configuration key/value pairs, you get hold of that
    > singleton instance and invoke properties on it. The *first call to any web
    > method* will do the *actual loading from web.config* and incase there is an
    > error, it will go as a SOAP fault.
    >
    > Hope this helps,
    > Mujtaba.
    >
    > <fmnewsgroups.nospam> wrote in message
    > news:70149971-4270-49A3-B95A-0E4F823AE213microsoft.com...
    > > During application startup, we are loading static values from web.config.
    > We
    > > expose those values to the rest of the application as shared properties in
    > > the Global class. This is to be consistent with our ASP.NET web
    > applications.
    > > I suppose we could load these values on session start for web services but
    > > that seems like a lot of extra processing during runtime. Perhaps with web
    > > services we should have the code call our web.config wrapper methods
    > > directly. But then you loose that layer of abstraction if we move the
    > > location of those values (to a database or other data store).
    > >
    > > The only times this logic should bomb is if web.config does not match what
    > > the code is trying to read (that is how I discovered this problem). But
    > the
    > > fact is it could still error out. I think one thing I will investigate is
    > > throwing a hand-written SOAP envelope (does not sound too pretty either).
    > >
    > >
    > >
    > > "Dan Rogers" wrote:
    > >
    > > > Something else you can do is change the auto-generated HTML page for
    > > > specific errors. By default, these are HTML, but you can change them
    > from
    > > > the IIS administration console.
    > > >
    > > > Since you are having this kind of problem I wonder why are you doing
    > > > applicaiton start kind of logic? In general, you want web services to
    > be
    > > > stateless. Using the application start feature implies you aren't
    > staying
    > > > statless - which may be a cause of frustration for you ongoing. The
    > > > application.start, session, etc are ASP programming model entities for
    > > > managing web sites and web page based applications (using a general tone
    > > > here - I'm sure that there are exceptions to the rule as always).
    > > >
    > > > Try NOT using applicaiton start for your web services....
    > > >
    > > > Regards
    > > >
    > > > Dan Rogers
    > > > Microsoft Corporation
    > > > --------------------
    > > > >Thread-Topic: Web Service throws exception during Application_Start
    > > > >thread-index: AcTfFIGVnDpe3DTaRYyAMlLJYzTwRg==
    > > > >X-WBNR-Posting-Host: 192.41.148.220
    > > > >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    > > > >Subject: Web Service throws exception during Application_Start
    > > > >Date: Fri, 10 Dec 2004 16:01:03 -0800
    > > > >Lines: 17
    > > > >Message-ID: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    > > > >MIME-Version: 1.0
    > > > >Content-Type: text/plain;
    > > > > cht="Utf-8"
    > > > >Content-Transfer-Encoding: 7bit
    > > > >X-Newsreader: Microsoft CDO for Windows 2000
    > > > >Content-Class: urn:content-classes:message
    > > > >Importance: normal
    > > > >Priority: normal
    > > > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > > > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    > > > >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    > > > >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > > > >Xref: cpmsftngxa10.phx.gbl
    > > > microsoft.public.dotnet.framework.aspnet.webservic es:27147
    > > > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    > > > >
    > > > >We have some static information load from web.config during the
    > > > >application_start of our web service.
    > > > >
    > > > >However, if there is an error during this startup, the consumer gets
    > back
    > > > an
    > > > >ugly error message starting like: Client found response content type of
    > > > >'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    > > > with
    > > > >the error message: --
    > > > >
    > > > >Errors in the Global class seem to step outside of the Soap Fault
    > > > standards.
    > > > >
    > > > >What is worse is that even though there is an error on Startup, the Web
    > > > >Service actually starts up. But of course the code in Application_Start
    > > > did
    > > > >not complete so now the Web Service is running in error.
    > > > >
    > > > >Am I correct or am I doing something wrong?
    > > > >
    > > > >fm
    > > > >
    > > >
    > > >
    >
    >
    >
    fm@newsgroups.nospam Guest

  7. #7

    Default RE: Web Service throws exception during Application_Start

    Have you considered using the config classes that are provided as part of
    the WS stack? These are cached on start for you, so that if you access a
    config value from within a web method, you get the cached value. If you
    later change the web.config file, the service is restarted for you, so
    subsequent calls see the new values.

    There is no provision for redirecting config to some other non-file based
    persistence mechanism at this point. But if you try out what is already
    provided, I think you'll find it does the trick. The added value is that
    if there is a config parsing problem, the application WON'T start properly
    (an error is returned to any call).

    I hope this helps

    Dan Rogers
    Microsoft Corporation
    --------------------
    >Thread-Topic: Web Service throws exception during Application_Start
    >thread-index: AcTh+KYtwFXLsmnJSxeJxQNORAN7uw==
    >X-WBNR-Posting-Host: 192.41.148.220
    >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    >References: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    <dwifcgV4EHA.3440cpmsftngxa10.phx.gbl>
    >Subject: RE: Web Service throws exception during Application_Start
    >Date: Tue, 14 Dec 2004 08:19:12 -0800
    >Lines: 85
    >Message-ID: <70149971-4270-49A3-B95A-0E4F823AE213microsoft.com>
    >MIME-Version: 1.0
    >Content-Type: text/plain;
    > cht="Utf-8"
    >Content-Transfer-Encoding: 7bit
    >X-Newsreader: Microsoft CDO for Windows 2000
    >Content-Class: urn:content-classes:message
    >Importance: normal
    >Priority: normal
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    >Xref: cpmsftngxa10.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webservic es:27188
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >
    >During application startup, we are loading static values from web.config.
    We
    >expose those values to the rest of the application as shared properties in
    >the Global class. This is to be consistent with our ASP.NET web
    applications.
    >I suppose we could load these values on session start for web services but
    >that seems like a lot of extra processing during runtime. Perhaps with web
    >services we should have the code call our web.config wrapper methods
    >directly. But then you loose that layer of abstraction if we move the
    >location of those values (to a database or other data store).
    >
    >The only times this logic should bomb is if web.config does not match what
    >the code is trying to read (that is how I discovered this problem). But
    the
    >fact is it could still error out. I think one thing I will investigate is
    >throwing a hand-written SOAP envelope (does not sound too pretty either).
    >
    >
    >
    >"Dan Rogers" wrote:
    >
    >> Something else you can do is change the auto-generated HTML page for
    >> specific errors. By default, these are HTML, but you can change them
    from
    >> the IIS administration console.
    >>
    >> Since you are having this kind of problem I wonder why are you doing
    >> applicaiton start kind of logic? In general, you want web services to
    be
    >> stateless. Using the application start feature implies you aren't
    staying
    >> statless - which may be a cause of frustration for you ongoing. The
    >> application.start, session, etc are ASP programming model entities for
    >> managing web sites and web page based applications (using a general tone
    >> here - I'm sure that there are exceptions to the rule as always).
    >>
    >> Try NOT using applicaiton start for your web services....
    >>
    >> Regards
    >>
    >> Dan Rogers
    >> Microsoft Corporation
    >> --------------------
    >> >Thread-Topic: Web Service throws exception during Application_Start
    >> >thread-index: AcTfFIGVnDpe3DTaRYyAMlLJYzTwRg==
    >> >X-WBNR-Posting-Host: 192.41.148.220
    >> >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    >> >Subject: Web Service throws exception during Application_Start
    >> >Date: Fri, 10 Dec 2004 16:01:03 -0800
    >> >Lines: 17
    >> >Message-ID: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    >> >MIME-Version: 1.0
    >> >Content-Type: text/plain;
    >> > cht="Utf-8"
    >> >Content-Transfer-Encoding: 7bit
    >> >X-Newsreader: Microsoft CDO for Windows 2000
    >> >Content-Class: urn:content-classes:message
    >> >Importance: normal
    >> >Priority: normal
    >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    >> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    >> >Xref: cpmsftngxa10.phx.gbl
    >> microsoft.public.dotnet.framework.aspnet.webservic es:27147
    >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >> >
    >> >We have some static information load from web.config during the
    >> >application_start of our web service.
    >> >
    >> >However, if there is an error during this startup, the consumer gets
    back
    >> an
    >> >ugly error message starting like: Client found response content type of
    >> >'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    >> with
    >> >the error message: --
    >> >
    >> >Errors in the Global class seem to step outside of the Soap Fault
    >> standards.
    >> >
    >> >What is worse is that even though there is an error on Startup, the Web
    >> >Service actually starts up. But of course the code in Application_Start
    >> did
    >> >not complete so now the Web Service is running in error.
    >> >
    >> >Am I correct or am I doing something wrong?
    >> >
    >> >fm
    >> >
    >>
    >>
    >
    Dan Rogers Guest

  8. #8

    Default RE: Web Service throws exception during Application_Start

    My understanding is that the only class to read appfrom web.config (which
    logically merges machine.config) is
    System.Configuration.ConfigurationSettings? We already use GetConfig and
    AppSettings. We use this class to populate shared Global properties.

    Where we are getting the data from was not the issue, just the timing of it.
    Loading application state at Application_Start sounds like a bad spot in an
    ASP.NET WebService even though it is fine in an ASP.NET Web Application.

    We'll make do.

    "Dan Rogers" wrote:
    > Have you considered using the config classes that are provided as part of
    > the WS stack? These are cached on start for you, so that if you access a
    > config value from within a web method, you get the cached value. If you
    > later change the web.config file, the service is restarted for you, so
    > subsequent calls see the new values.
    >
    > There is no provision for redirecting config to some other non-file based
    > persistence mechanism at this point. But if you try out what is already
    > provided, I think you'll find it does the trick. The added value is that
    > if there is a config parsing problem, the application WON'T start properly
    > (an error is returned to any call).
    >
    > I hope this helps
    >
    > Dan Rogers
    > Microsoft Corporation
    > --------------------
    > >Thread-Topic: Web Service throws exception during Application_Start
    > >thread-index: AcTh+KYtwFXLsmnJSxeJxQNORAN7uw==
    > >X-WBNR-Posting-Host: 192.41.148.220
    > >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    > >References: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    > <dwifcgV4EHA.3440cpmsftngxa10.phx.gbl>
    > >Subject: RE: Web Service throws exception during Application_Start
    > >Date: Tue, 14 Dec 2004 08:19:12 -0800
    > >Lines: 85
    > >Message-ID: <70149971-4270-49A3-B95A-0E4F823AE213microsoft.com>
    > >MIME-Version: 1.0
    > >Content-Type: text/plain;
    > > cht="Utf-8"
    > >Content-Transfer-Encoding: 7bit
    > >X-Newsreader: Microsoft CDO for Windows 2000
    > >Content-Class: urn:content-classes:message
    > >Importance: normal
    > >Priority: normal
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    > >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    > >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > >Xref: cpmsftngxa10.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.webservic es:27188
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    > >
    > >During application startup, we are loading static values from web.config.
    > We
    > >expose those values to the rest of the application as shared properties in
    > >the Global class. This is to be consistent with our ASP.NET web
    > applications.
    > >I suppose we could load these values on session start for web services but
    > >that seems like a lot of extra processing during runtime. Perhaps with web
    > >services we should have the code call our web.config wrapper methods
    > >directly. But then you loose that layer of abstraction if we move the
    > >location of those values (to a database or other data store).
    > >
    > >The only times this logic should bomb is if web.config does not match what
    > >the code is trying to read (that is how I discovered this problem). But
    > the
    > >fact is it could still error out. I think one thing I will investigate is
    > >throwing a hand-written SOAP envelope (does not sound too pretty either).
    > >
    > >
    > >
    > >"Dan Rogers" wrote:
    > >
    > >> Something else you can do is change the auto-generated HTML page for
    > >> specific errors. By default, these are HTML, but you can change them
    > from
    > >> the IIS administration console.
    > >>
    > >> Since you are having this kind of problem I wonder why are you doing
    > >> applicaiton start kind of logic? In general, you want web services to
    > be
    > >> stateless. Using the application start feature implies you aren't
    > staying
    > >> statless - which may be a cause of frustration for you ongoing. The
    > >> application.start, session, etc are ASP programming model entities for
    > >> managing web sites and web page based applications (using a general tone
    > >> here - I'm sure that there are exceptions to the rule as always).
    > >>
    > >> Try NOT using applicaiton start for your web services....
    > >>
    > >> Regards
    > >>
    > >> Dan Rogers
    > >> Microsoft Corporation
    > >> --------------------
    > >> >Thread-Topic: Web Service throws exception during Application_Start
    > >> >thread-index: AcTfFIGVnDpe3DTaRYyAMlLJYzTwRg==
    > >> >X-WBNR-Posting-Host: 192.41.148.220
    > >> >From: "=?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=" <fmnewsgroups.nospam>
    > >> >Subject: Web Service throws exception during Application_Start
    > >> >Date: Fri, 10 Dec 2004 16:01:03 -0800
    > >> >Lines: 17
    > >> >Message-ID: <649FEFA7-EF0F-4ABB-9A92-02A64D685530microsoft.com>
    > >> >MIME-Version: 1.0
    > >> >Content-Type: text/plain;
    > >> > cht="Utf-8"
    > >> >Content-Transfer-Encoding: 7bit
    > >> >X-Newsreader: Microsoft CDO for Windows 2000
    > >> >Content-Class: urn:content-classes:message
    > >> >Importance: normal
    > >> >Priority: normal
    > >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
    > >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
    > >> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > >> >Xref: cpmsftngxa10.phx.gbl
    > >> microsoft.public.dotnet.framework.aspnet.webservic es:27147
    > >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    > >> >
    > >> >We have some static information load from web.config during the
    > >> >application_start of our web service.
    > >> >
    > >> >However, if there is an error during this startup, the consumer gets
    > back
    > >> an
    > >> >ugly error message starting like: Client found response content type of
    > >> >'text/html; cht=utf-8', but expected 'text/xml'. The request failed
    > >> with
    > >> >the error message: --
    > >> >
    > >> >Errors in the Global class seem to step outside of the Soap Fault
    > >> standards.
    > >> >
    > >> >What is worse is that even though there is an error on Startup, the Web
    > >> >Service actually starts up. But of course the code in Application_Start
    > >> did
    > >> >not complete so now the Web Service is running in error.
    > >> >
    > >> >Am I correct or am I doing something wrong?
    > >> >
    > >> >fm
    > >> >
    > >>
    > >>
    > >
    >
    >
    fm@newsgroups.nospam Guest

Similar Threads

  1. Help: Server.Execute throws exception in Application_Start
    By frog in forum ASP.NET Web Services
    Replies: 0
    Last Post: May 5th, 09:35 PM
  2. MapPath throws exception
    By cssnow@hotmail.com in forum ASP.NET Web Services
    Replies: 2
    Last Post: April 21st, 05:15 PM
  3. Web Service Calling a COM object-throws exception.
    By Chris Bardon in forum ASP.NET Web Services
    Replies: 1
    Last Post: February 28th, 12:31 AM
  4. Marshal.GetActiveObject throws an exception in a C# webservice but
    By OfurGørn in forum ASP.NET Web Services
    Replies: 30
    Last Post: February 17th, 02:47 AM
  5. Process.GetProcessesByName throws exception
    By howard39@nospam.nospam in forum ASP.NET Security
    Replies: 1
    Last Post: October 26th, 10:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139