Hi Jim,
Thanks for your followup. You meant that your code is exactly the same as
mine which has set the "async"as
false and still not work? If so, I'm thinking whether the problem is
something concerned with the certain webservcie. Would you try creating
another new simple webservice and try to call it via the sychronous style
javascript code to see whether it works? Here are webservice class and
jscript code I used for testing, you may have a try on them to see whether
they work:
----------------------------------websrevice
class------------------------------
public class MyService : System.Web.Services.WebService
{
public MyService()
{
InitializeComponent();
}
#region Component Designer generated code
private IContainer components = null;
private void InitializeComponent()
{
}
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod]
public void LogCall(string caller)
{
StreamWriter w = File.AppendText(Server.MapPath("logs/log.txt"));
Log(caller + "called LogCall Service",w);
w.Close();
}
public void Log (String logMessage, TextWriter w)
{
w.Write("\r\nLog Entry : ");
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString());
w.WriteLine(" :");
w.WriteLine(" :{0}", logMessage);
w.WriteLine ("-------------------------------");
// Update the underlying file.
w.Flush();
}
}
-----------------------------page used to call
webservice--------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>CallWS</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript">
function CallLog()
{
document.all("divWS").useService("
http://localhost/Myservice/MyService.asmx?
WSDL","LogCall");
document.all("divWS").LogCall.async = false;
document.all("divWS").LogCall.callService("LogCall","steven");
alert('unload');
}
</script>
</HEAD>
<body onunload="CallLog();">
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td>Call WebService</td>
</tr>
<tr>
<td>
<div id="divWS" style="BEHAVIOR: url(webservice.htc)">
LogService
</div>
</td>
</tr>
<tr>
<td><INPUT type="button" value="CallService" name="btnCall"
onclick="CallLog()" /></td>
</tr>
</table>
</form>
</body>
</HTML>
---------------------------------------------------------------------
Hope these help.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx