Service unavailable on First call in synchronous mode only! question for webservice.htc gurus.

Discussion in 'ASP .Net Web Services' started by sonic_soul, Oct 20, 2004.

  1. sonic_soul

    sonic_soul Guest

    Hi,
    This is a interesting problem.

    I got webservice.htc integrated pretty well with .net framework. I
    wrote a control that generates all the necessary scripts to consume
    webservices with dhtml objects.

    It is working great for me accept for one scenario.

    When the page loads, and the first webservice call is synchronous, it
    returns "service unavailable" error, BEFORE actually making the server
    call!

    After stepping through the webservice.htc file a few [dozen] times i
    noticed that:
    callService method checks for readyState == 4 (completed) status of
    the xml object. if call is synchronous and status isnt 4 it throws the
    "service unavailable" error.

    the status is actually 3 (loaded) during the call.

    after callservice is executed and I get the nice error alert,
    onreadystatechange event is exected again and the xml doc is now in
    completed state.

    therefore every call after this is successful!


    I am running out of ideas on how to troubleshoot this further (other
    than working around by making a dummy call to the ws on page load) but
    i would hate to work around such important issue.


    here is my abridged viewsource (all my js is autogenerated by asp.net
    control):

    <div id="WebService_233632359"
    style="behavior:url(/scripts/webservice.htc)">

    function Confirmation_servicecontrol_SubmitTrade_synchronous (
    Quantity, Price, Symbol, tradeId, Action ) {

    // create call object and set its properties

    var callobject = new Object();
    callobject.funcName = 'SubmitTrade';
    callobject.async = false;


    // register service if this is the first time running it
    // tagid.classname ( classname = name of server side class which
    methods will be using )
    if ( ! WebService_233632359.Confirmation ) {

    // check if this service has a registration function
    if ( typeof(register_Confirmation_servicecontrol) == 'function' )
    {
    register_Confirmation_servicecontrol();
    } else {

    // are we in debug mode ?
    if (register_Confirmation_servicecontrol) {
    alert( 'registration function not found
    register_Confirmation_servicecontrol' );
    }
    return;
    }
    }

    // verify that the service was registered and call it
    if ( WebService_233632359.Confirmation ) {


    // webservice call

    return WebService_233632359.Confirmation.callService( callobject ,
    Quantity, Price, Symbol, tradeId, Action );


    } else {
    if (true) { alert( ' service failed to register ::
    WebService_233632359:Confirmation ' ); }
    }

    }

    function register_Confirmation_servicecontrol() {
    WebService_233632359.useService('http://localhost/pbt/Confirmation.asmx?wsdl','Confirmation');
    }
     
    sonic_soul, Oct 20, 2004
    #1
    1. Advertising

  2. sonic_soul

    David Guest

    RE: Service unavailable on First call in synchronous mode only! questi

    Actually, if you're calling the service synchronously, I believe the
    applicable code is in the _invoke method of webservice.htc. Specifically the
    following code block:

    try
    {
    oXmlHttp.xmlHttp.send(szPayload);
    }
    catch(e)
    {
    return returnError(oCall, 5);
    }
    if (oXmlHttp.xmlHttp.responseXML.parseError.errorCode != 0)
    {
    _errUnknownS.raw = oXmlHttp.xmlHttp.responseText;
    return returnError(oCall, 4);
    }

    If you'll send me your email, I'll send you a commented/formatted version of
    webservice.htc that I just created. If you're going to spend much time
    trying to understand that code - like I've been trying to do - you'll need
    all the help you can get!

    David Thom





    "sonic_soul" wrote:

    > Hi,
    > This is a interesting problem.
    >
    > I got webservice.htc integrated pretty well with .net framework. I
    > wrote a control that generates all the necessary scripts to consume
    > webservices with dhtml objects.
    >
    > It is working great for me accept for one scenario.
    >
    > When the page loads, and the first webservice call is synchronous, it
    > returns "service unavailable" error, BEFORE actually making the server
    > call!
    >
    > After stepping through the webservice.htc file a few [dozen] times i
    > noticed that:
    > callService method checks for readyState == 4 (completed) status of
    > the xml object. if call is synchronous and status isnt 4 it throws the
    > "service unavailable" error.
    >
    > the status is actually 3 (loaded) during the call.
    >
    > after callservice is executed and I get the nice error alert,
    > onreadystatechange event is exected again and the xml doc is now in
    > completed state.
    >
    > therefore every call after this is successful!
    >
    >
    > I am running out of ideas on how to troubleshoot this further (other
    > than working around by making a dummy call to the ws on page load) but
    > i would hate to work around such important issue.
    >
    >
    > here is my abridged viewsource (all my js is autogenerated by asp.net
    > control):
    >
    > <div id="WebService_233632359"
    > style="behavior:url(/scripts/webservice.htc)">
    >
    > function Confirmation_servicecontrol_SubmitTrade_synchronous (
    > Quantity, Price, Symbol, tradeId, Action ) {
    >
    > // create call object and set its properties
    >
    > var callobject = new Object();
    > callobject.funcName = 'SubmitTrade';
    > callobject.async = false;
    >
    >
    > // register service if this is the first time running it
    > // tagid.classname ( classname = name of server side class which
    > methods will be using )
    > if ( ! WebService_233632359.Confirmation ) {
    >
    > // check if this service has a registration function
    > if ( typeof(register_Confirmation_servicecontrol) == 'function' )
    > {
    > register_Confirmation_servicecontrol();
    > } else {
    >
    > // are we in debug mode ?
    > if (register_Confirmation_servicecontrol) {
    > alert( 'registration function not found
    > register_Confirmation_servicecontrol' );
    > }
    > return;
    > }
    > }
    >
    > // verify that the service was registered and call it
    > if ( WebService_233632359.Confirmation ) {
    >
    >
    > // webservice call
    >
    > return WebService_233632359.Confirmation.callService( callobject ,
    > Quantity, Price, Symbol, tradeId, Action );
    >
    >
    > } else {
    > if (true) { alert( ' service failed to register ::
    > WebService_233632359:Confirmation ' ); }
    > }
    >
    > }
    >
    > function register_Confirmation_servicecontrol() {
    > WebService_233632359.useService('http://localhost/pbt/Confirmation.asmx?wsdl','Confirmation');
    > }
    >
     
    David, Oct 26, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. batista
    Replies:
    1
    Views:
    940
    Laurent Bugnion
    Jan 26, 2006
  2. batista
    Replies:
    0
    Views:
    575
    batista
    Jan 26, 2006
  3. Replies:
    0
    Views:
    152
  4. batista
    Replies:
    0
    Views:
    262
    batista
    Jan 26, 2006
  5. webservice.htc doesnt work on first call

    , Jul 26, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    118
Loading...

Share This Page