By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,775 Members | 1,306 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,775 IT Pros & Developers. It's quick & easy.

Calling Web Services from Mozilla Browsers

P: n/a
Hi,

Can anybody give me a simple example of how to Call Web Services from
Mozilla based Browsers ? I can call web services from IE browser using
web service behavior file, without any problems. Just wanted to know an
easy way to call them from Firefox or Netscape.

Thanks,
Nifty.

Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a


ni*******@gmail.com wrote:

Can anybody give me a simple example of how to Call Web Services from
Mozilla based Browsers ? I can call web services from IE browser using
web service behavior file, without any problems. Just wanted to know an
easy way to call them from Firefox or Netscape.


Since Mozilla 1.4 (respectively Netscape 7.1) there is a web service
proxy facility implemented in Mozilla that reads the WSDL description of
a service and creates a proxy object in JavaScript, see
<http://www.mozilla.org/projects/webservices/>
In earlier versions there is support for a (lower level) SOAP API.
Unfortunately there are issues with SOAP/WSDL clients and servers not
being as interoperable as they are supposed to be, perhaps you can
report back to the group how your service is implemented and whether you
get the Mozilla proxy object and the service interoperate with each
other successfully.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
My web service is written in C# and ASP.NET. The name of the service is
Service1. The web methods exposed under this service is "WebAdd". This
webmethod takes two integers as an input and returns the result of
addition of both the integers.

I have this service hosted in a folder called "MathOps" in my localhost
(IIS Webserver). I want to write a simple html file, which has two text
boxes to take those inputs and upon clicking an "Add" Button, it prints
the result to the screen.

I have accomplished this task using IE with the help of HTML Component
for web serrvices (WebServices.htc) provided by Microsoft. I researched
a lot on calling web services from netscape/mozilla based browsers but
to no avail. I have visited the site you told me, but I am surprised to
find out their examples dont run on Firefox 1.0 I havent tried other
mozilla based browsers though.

My HTML file looks like this (when I use webservices.htc for IE)
************************************************** ***********************
<HTML>
<HEAD>
<TITLE>Consuming the ADD Web Service</TITLE>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function init() {

myWebService.useService("http://localhost/MathOps/Service1.asmx?WSDL",

"simpleCalcWebService");
}

function addNumbers(a, b) {
myWebService.simpleCalcWebService.callService(addR esult, "WebAdd",
first.value, second.value);
}

function addResult(result) {
theResult1.innerHTML = result.value;
}
// -->
</SCRIPT>
</HEAD>
<BODY onload="init()">
<DIV ID="myWebService" STYLE="behavior:url(webservice.htc)"></DIV>
<TABLE BORDER="0">
<TR><TD>Number 1: </TD><TD><INPUT SIZE="4" TYPE="text" ID="first"
STYLE="text-align:'right'"></TD></TR>
<TR><TD>Number 2: </TD><TD><INPUT SIZE="4" TYPE="text" ID="second"
STYLE="text-align:'right'"></TD></TR>
<TR><TD><HR></TD><TD><INPUT VALUE="Add" TYPE="button"
onclick="addNumbers();"></TD></TR>
<TR><TD>Result: </TD><TD><DIV ID="theResult1"
STYLE="text-align:'right'"></DIV></TD></TR>
</TABLE>
</BODY>
</BODY>
</HTML>

************************************************** ************

Please let me know if you need more info on this..

Thanks,
Nifty

Jul 23 '05 #3

P: n/a


ni*******@gmail.com wrote:
My web service is written in C# and ASP.NET.
Unfortunately there are incompabilites between the SOAP requests ASP.NET
wants and understands and the SOAP requests Mozilla creates, at least as
far as I can tell currently.
There are some bugs filed on that:
<https://bugzilla.mozilla.org/show_bug.cgi?id=137490>
I researched
a lot on calling web services from netscape/mozilla based browsers but
to no avail. I have visited the site you told me, but I am surprised to
find out their examples dont run on Firefox 1.0 I havent tried other
mozilla based browsers though.


Which examples have you tried exactly, and what happens exactly when an
example doesn't "run"?
For instance
<http://www.mozilla.org/projects/webservices/>
links to the example
<http://mgalli.com/wsdom/moz-crossportal/fs-4/>
and that works here for me with Firefox 1.0, if you click the "get"
button then a conversion rate is displayed.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4

P: n/a
I have tried out this example:

http://www.mozilla.org/projects/webs...sdl/index.html

When I run this in firefox, I get two javascript errors.

1.Error: [Exception... "'A script from "http://www.mozilla.org" was
denied UniversalBrowserRead privileges.' when calling method:
[nsIWebServiceProxyCreationListener::onLoad]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

2. Error: uncaught exception: A script from "http://www.mozilla.org"
was denied UniversalBrowserRead privileges.

I have also tried the bablefish example. But seems like it is disabled.

I also tried the Translator Service.

http://www.mozilla.org/projects/webs...ple/index.html

This doesnt seem to work either. When I select an option to translate
into and click the button, nothing gets displayed next to "Results:" I
do not recieve any javascript errors on this one.. But still it doesnt
work.

I hope somebody fixes the "accessing .net web services from mozilla"
bug soon.. I am not the only one who will be using this. I wonder what
people with similar problem have done? Any other alternatives you can
suggest to get rid of this problem?

Thanks for your feedback,
Nifty

Jul 23 '05 #5

P: n/a


ni*******@gmail.com wrote:
I have tried out this example:

http://www.mozilla.org/projects/webs...sdl/index.html

When I run this in firefox, I get two javascript errors.

1.Error: [Exception... "'A script from "http://www.mozilla.org" was
denied UniversalBrowserRead privileges.' when calling method:
[nsIWebServiceProxyCreationListener::onLoad]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

2. Error: uncaught exception: A script from "http://www.mozilla.org"
was denied UniversalBrowserRead privileges.
That example clearly explains ("Note about Security") that you would
need to change security settings before being able to run it from the
Mozilla web site as (usually with scripts) the page from mozilla.org is
not allowed to access a web service on amazon.com.
I hope somebody fixes the "accessing .net web services from mozilla"
bug soon.. I am not the only one who will be using this.
Yes, but the problem is not necessarily related to Mozilla only, it is
more a problem as to different people interpreting SOAP 1.1 differently
as it is not clear enough about XML namespaces applied on arguments or
result values. That Mozilla web service proxy code was obviously written
against web services where the problem did not occur.
I wonder what
people with similar problem have done? Any other alternatives you can
suggest to get rid of this problem?


If you are a writing web service with .NET then it usually does not only
accept SOAP requests but simple HTTP POST (or even HTTP GET) requests
too so you could ignore SOAP for the time being and simply use
XMLHttpRequest to send your data and receive the response.

The XMLHttpRequest object is decribed here:
<http://www.faqts.com/knowledge_base/view.phtml/aid/17226/fid/616>
<http://jibbering.com/2002/4/httprequest.html>

If you load your .NET .asmx page for the web service then it usually
displays a documentation about the methods and the page documenting a
method shows how the HTTP POST request for a method and the result would
look so it is rather easy then to use XMLHttpRequest to send the message
and to read the response.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.