Say I have a page that calls a web service from a client function to get some data to bind a gridView like this:
-------------------
<scripttype="text/javascript"language="JavaScript">
function GetDataSet(){
var ds = SimpleService.ActiveProcess();
}
</script >
-------------------
And the web service looks something like this:
-------------------
[WebMethod]
public datasetActiveProcess(){
string connectionString ="Connstring stuff here";
DataSet ds = csql.GetActiveProcess(connectionString);
return ds;
}
-------------------
Of course, because I'm posting this problem, this isn't the correct way to implement this kind of solution...
Question is: Is there a better way? Or how do I manage to handle and display what's being returned from this web service in the web page?
thanks.
doug
This issue is associated with an Atlas Web Service call.
Here is a crude solution that I still need to refine:
------------------------
1. JavasScript call to webservice:
------------------------
function fnSetTimeout( ){
//this is the call to the web service.
var ds = SimpleService.ActiveProcess(OnComplete, OnTimeout);
}
------------------------
2. Webservice method
------------------------
[WebMethod]
publicstring ActiveProcess(){
string connectionString ="Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=simple2;Data Source=local
string xmlReader = csql.GetActiveProcess(connectionString);
return xmlReader;
}
------------------------
3 Webservice method
------------------------
publicstring GetActiveProcess(string connString)
{
string strSQL ="Select id, threadid, conversationId from ActiveProcess";
SqlConnection conn =newSqlConnection(connString);
SqlDataAdapter da =newSqlDataAdapter(strSQL, conn);
DataSet ds =newDataSet();
try
{
conn.Open();
da.Fill(ds);
XmlDataDocument xmlDataDocument =newXmlDataDocument(ds);
return xmlDataDocument.OuterXml.ToString();
}
catch (SqlException ex)
{
returnnull;
}
}
------------------------
3 Load the XML into parser
------------------------
/*==============================================================================
function: OnComplete
paramaters: result
Purpose: Gets the results from the ATLAS call and parses into an XML document
Date: 12/21/2005
==============================================================================*/
function OnComplete(result)
{
//Load XML
var XMLDoc =new ActiveXObject("Microsoft.XMLDOM");
try
{
XMLDoc.loadXML(result);
}
catch(err)
{
alert(err.description);
}
//Load XSL
var XSLDoc =new ActiveXObject("Microsoft.XMLDOM");
try
{
XSLDoc.async =false;
XSLDoc.load("ActiveRecords.xsl");
}
catch(err)
{
alert(err.description);
}
//Write the results of the transformation out to the div.
document.all.divTable.innerHTML = XMLDoc.transformNode(XSLDoc);
}
Here's the XSL if you're interested:
<?xmlversion="1.0"encoding="utf-8"?>
<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:templatematch="/">
<html>
<head>
<title>Active</title>
<style>
copy { font-family: Arial, Verdana;}
h1 { font-family: Arial, Verdana; font-size: 14pt;}
p { font-family: Arial, Verdana; font-size: 10pt;}
</style>
</head>
<body>
<p><fontface="verdana">Active</font></p>
<tableborder="1">
<tr>
<thclass="copy">ID</th>
<thclass="copy">Thread Id</th>
<thclass="copy">Configuration ID</th>
</tr>
<xsl:for-eachselect ="NewDataSet/Table">
<tr>
<td>
<xsl:value-ofselect="id"/>
</td>
<td>
<xsl:value-ofselect="threadid"/>
</td>
<td>
<xsl:value-ofselect="conversationId"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
thanks...
0 件のコメント:
コメントを投稿