Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 05-14-2004, 09:46 AM   #1
Beta Member
Join Date: May 2004
Posts: 2
Default weather script...

Hey.. I'm working on a web site for this guy who owns a computer shop, and he wants local weather to be displayed on his site, just like www.unitz.on.ca has.. Now, On that unitz site, people can select a city and it will automatically refresh and display the weather for that city, and that is what I want to do on my friends site as well. his site is www.vccnet.ca

Can somebody help me

Thank You very much..


odd_foo is offline   Reply With Quote
Old 06-08-2004, 05:37 AM   #2
Solid State Member
julian_brunt's Avatar
Join Date: Jun 2004
Posts: 7
Default Re: weather script...

You generally have to subscribe to one of the weather web sites and they willgive you the code to stick on your site

julian_brunt is offline   Reply With Quote
Old 06-15-2004, 07:51 AM   #3
Solid State Member
Microdude's Avatar
Join Date: Jun 2004
Posts: 8

exactly what he said it what makes the most sense
Microdude is offline   Reply With Quote
Old 07-19-2004, 10:14 AM   #4
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 8,098
Default Re: weather script...

a web tip that eas emailed to me
Public Web services add a great deal of functionality to your applications without the hassle of implementing third-party software on your system. A Web service for Web applications is usually utilized server-side. The Web service is intended to replace business objects built either with COM, Enterprise JavaBeans, or as part of another service package. However, with Mozilla, you can easily implement a Web service within the browser using the SOAP API. In this article, I'm going to use a free public Web service for displaying the current temperature on a Web page. 

The SOAP API is a _JavaScript interface that contains a set of objects that you can use to manage SOAP messages. SOAP is the communication protocol between the client using the Web service and the server hosting the service; this communique is a series of messages wrapped up in an XML envelope. XML provides the power to create complicated data types and the flexibility to use them across platforms. 

The Web service's specifications that I'll be using are located at XMethods. This Web service takes a zip code as a parameter and returns the current temperature. 

In order to create the SOAP message with Mozilla, you use the SOAPCall and SOAPParameter objects. SOAPCall is responsible for creating and encoding the SOAP message, and SOAPParameter is for creating the individual parameters to pass to the Web service. In my page, when the page loads--let's say that we have a user-aware site with preferences set--I use the users' preferred zip code to display their local temperature: 

function window_onload() {
    var soap_call = new SOAPCall();
    soap_call.transportURI =
    var p = [new SOAPParameter("90210", "zipcode")];
    soap_call.encode(0, "getTemp", "urn:xmethods-Temperature", 0, null,
 p.length, p);
    var temp = soap_call.invoke();
    if (temp.fault) {
    } else {
        var response = [];
        response = temp.getParameters(false, {});
        document.getElementById("divTemp").innerHTML = response[0].value +

The first thing that happens is a new SOAPCall object is created. The transportURI property is set; you can find this in the WSDL file in the <soap:address> location attribute. Parameters are passed to the encode() method of the SOAPCall object as an array of SOAPParameter objects. 

The getTemp() method of the Web service takes only one parameter: zipcode. This parameter is set to the user's defined zip code; in my example, that user's zip code is 90210. 

The encode() method accepts six parameters, but the four that you should concern yourself with are: the Web service method name, the target namespace, the parameter array length, and the parameter array. These are the second, third, fifth, and sixth parameters, respectively. 

The method name is self-explanatory; this is the name of the method you wish to invoke. You can find the target namespace for this Web service in the namespace attribute of the <soap:body> input element. The parameter array length is simply the length of the parameter array. (Length is a property on the _JavaScript Array object.) The parameter array is the collection of SOAPParameters in a _JavaScript Array. 

In order to make the actual call to the Web service, you can use either the asyncInvoke() method or the invoke() method of the SOAPCall object. The difference between asyncInvoke() and invoke() is that asyncInvoke() will perform an asynchronous invocation of the Web service method. The result is returned to a callback function that will handle the response. The invoke() method will halt the script until a response is received. I'm using this method because I'm not working with time-sensitive operations. 

The return value of the invoke() method is a SOAPResponse object. The SOAPResponse object's fault property contains a SOAPFault object if a fault occurs. In this case, I simply issue an alert box with the faultString value of the SOAPFault object. Otherwise, I grab the return parameters and store them to a local variable. Each return parameter is an object that contains three properties: name, value, element. Name is the name of the parameter; value is the value of the returned parameter; element is a pointer to a DOM node in the returned XML. For my purposes, only one parameter is returned, as defined in the WSDL. I set the innerHTML of an arbitrary <DIV> element to the value of the returned parameter.
Not exactly all weather, but a bit of it. hope it helps anyone.
root is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 05:20 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0