views:

1765

answers:

2

Whilst trying to get our app working in Firefox (I'm a big proponent of X-Browser support but our lead dev is resisting me saying IE is good enough). So I'm doing a little side project to see how much work it is to convert.

I've hit a problem straight away.

The main.aspx page binds to a webservice using the IE only method of adding behaviour through a htc file, which is auto-generated by VS I beleive.

Firefox doesn't support this but there is an xml bindings file which can be used to enable htc support (see here: http://dean.edwards.name/moz-behaviors/overview/). The examples work in FF3 but when I use my webservice.htc as I normally would e.g.:

//Main.aspx
/*SNIP*/
<style type="text/css" media="all">
    #webservice
    {
        behavior:url(webservice.htc);
        -moz-binding:url(bindings.xml#webservice.htc);
    }
</style>
</head>
<body>
<div id="webservice"></div> <!-- we use this div to load the webservice stuff -->
/*SNIP*/

//Main.js
webservice.useService(url + asmpath + "/WebServiceWrapper.asmx?WSDL","WebServiceWrapper");

I get webservice is not defined (works fine in IE), I obviously tried

var webservice = document.getElementById("webservice")

and

$("#webservice").useService(url + asmpath + "/WebServiceWrapper.asmx?WSDL","WebServiceWrapper");

as well which just gives me "useService is not defined" in Firebug. Which leads me to beleive that the binding is not working. However I can see that webservice.htc is being loaded by Firefox in the Firebug console window.

Anyone got any experience of this?

Am I going to have to rewrite how the webservice is called?

Cheers, Rob

+2  A: 

I don't think that you are on the right way for achieving real cross-browser compatibility. Adding support for IE-specific features for Firefox is definitely not the way to go. What about Opera, Safari, Chrome...? If the app you're working on is used strictly on the intranet then supporting Firefox may be enough however...

IMHO, the code should be refactored, but in an other way. If you are working with ASP.NET 2.0 (in this case you'd need ASP.NET Ajax) or newer, you can create proxy between Ajax and SOAP web services. In that case you would need to rewrite all your behaviors as a JavaScript code which may not be a small feat.

On a side note: AFAIK VS.NET does not generate behaviors.

Sorry if this is not too helpful :(

Damir Zekić
+1  A: 

Your jQuery snippet has an error: since useService is a method defined on the node itself, not the jQuery object, you'd have to do:

$("#webservice")[0].useService(url + asmpath +
  "/WebServiceWrapper.asmx?WSDL","WebServiceWrapper");
savetheclocktower