Question : Web Services Cross Browser Support

Below I have provided examples of Web Services.cs and calling.js.  What I am doing is passing an xml object to the client by calling the .cs web servie from a .js file and then using sarissa to perform transaformation on the client.

This works fine in IE browsers however cannot seem to successfully pass xml data to client using other browsers such as firefox. Can anyone assist with some advice on what I am doing wrong and how I can possibly work towards resolving the issue.
Code Snippet:
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:
namespace Sprite.Call
{
/// 
/// Summary description for LiveCallsService
/// 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
     [System.Web.Script.Services.ScriptService]
    public class LiveCallsService : System.Web.Services.WebService
    { 
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
        public XElement GetDirectory()
        {
            DirectoryConstructor myDirectoryConstructor = new DirectoryConstructor();
            XElement myDirectory = new XElement(myDirectoryConstructor.GoSites());
            //myDirectory.Save(@"C:\SpriteMasterPage\XSLscripts\sites.xml");
            return myDirectory; 
        }
        
    } 
}

var xmlDoc = Sarissa.getDomDocument();
xmlDoc.async = false;

// create an object from the xsl
var xslDoc = Sarissa.getDomDocument();
xslDoc.async = false;
xslDoc.load("XSLscripts/sites.xsl");

function CallGetDirectory() {
    Sprite.Call.LiveCallsService.GetDirectory(
    SucceededDirectoryCallback, FailedCallback,
        "XmlDocument")
}

function SucceededDirectoryCallback(result, userContext, methodName) {
    xmlDoc.load(result);
    showDetail('0');
}

function FailedCallback(error) {
    alert("Load Failure");
}
function showDetail(id) {
    var xsltProc = new XSLTProcessor();
    xsltProc.importStylesheet(xslDoc);
    xsltProc.setParameter('', "detail-id", id);
    var transformResult = xsltProc.transformToDocument(xmlDoc);
    //alert(new XMLSerializer().serializeToString(transformResult));
    document.getElementById("structureContainer").innerHTML = new XMLSerializer().serializeToString(transformResult);
}

if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

function verify() {
    // 0 Object is not initialised
    // 1 Loading object is loading data
    // 2 Loaded object has loaded data
    // 3 Data from object can be worked with
    // 4 Object completely initialised

    if (xmlDoc.readyState != 4) {
        return false;
    }
}

Answer : Web Services Cross Browser Support

there is no need to create your own xml and send it to client because this is XML web service
you just need to define your output serializable and everything will be correct.
add [Serializable] tag before your DirectoryConstructor class
and in your webmethod
just return:
return myDirectoryConstructor;
Random Solutions  
 
programming4us programming4us