Solved

Need pseudo-code

Posted on 2008-06-14
8
499 Views
Last Modified: 2008-06-20
Hi there,

I am a newb to programming and need some pseudo-code to get me started. I know it doesnt make a diff with pseudo-code but im planning to write this in c#.

Now i am planning to write a application proxy or servlet which will query a web service and return world time zones from this website.

http://worldtimeengine.com/api

Then javascript from my website (do not need pseudo-code for js) will query the results from the application proxy or servelet, so basically it is a seperate app from my website but will sit on the same server.

I have been given this guide from a previous posting but i dont know where to start (ie call the webservice) and which of the examples it implement.

Please ask me any questions on this if i have not explained clearly.

Thanks in advanced.
0
Comment
Question by:irfo
  • 5
  • 3
8 Comments
 
LVL 5

Expert Comment

by:coldboy
Comment Utility
Which .NET Framework are you working on? If it 3.5, then it's very easy.
Read the article here: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=264
and then you can start in a minute.
0
 

Author Comment

by:irfo
Comment Utility
Hi there,

its .NET 2.

Still  as easy?
0
 

Author Comment

by:irfo
Comment Utility
Hi,

Is asking for pseudo-code too much for one question.

Just need to know if i need break question up into smaller chunks as im not getting much response.
0
 

Author Comment

by:irfo
Comment Utility
Hi,

Is asking for pseudo-code too much for one question.

Just need to know if i need break question up into smaller chunks as im not getting much response.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Accepted Solution

by:
coldboy earned 500 total points
Comment Utility
Dot NET 2.0 is still possible (though it much simpler with .NET 1.0).
About pseudo code, I'm not very sure, because you have to deal with web.config also.
Any way, here is an instruction. It's may not complete as I do not work much on 2.0 now.

First, search for "AJAX Extensions for net 2.0" and you will be able to download ASP.NET AJAX 1.0
Second, add these settings to your web.config:
1.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <configSections>
            <section name="UploadModuleManagement" type="UploadModule"/>
            <section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
            <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                  <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
                              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                        </sectionGroup>
                  </sectionGroup>
            </sectionGroup>

2.
<system.web>
            <httpModules>
            <compilation>
                  <assemblies>
                        <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </compilation>
            <httpHandlers>
                  <remove verb="*" path="*.asmx"/>
                  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </httpHandlers>

Up to that time, your webservice can be invoke via javascript with input and output in form of JSON syntax.

Next, write a web service. Here is an example:

using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
    [ScriptService]
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class HelloWorld : System.Web.Services.WebService
    {

        public HelloWorld()
        {

            //Uncomment the following line if using designed components
            //InitializeComponent();
        }

        [WebMethod]
        public string TalkToMe(string what)
        {
            return "You ask " + what;
        }

    }
}

And, finally, build the request component:
The easiest way is to use a Javascript framework. I use prototype, you can obtain a copy of prototype at prototypejs.org. Prototypejs provide a class named Ajax.Request to handle ajax request, we will use it for communicate with web services.

After include prototype.js, you can make a web service call:

function requestOK(result){
      alert(result.responseJSON)
}
function invoke: function (){
        var options = {
            method: "post",
            onSuccess: requestOK,
            postBody: {param: "How can this work"},
            contentType: "application/json"
        }
        return new Ajax.Request("HelloWorld.asmx/TalkToMe", options);
    }


As you can see, it will require alot of work. And you must done every thing correctly in order for it to work.
I know you are asking for pseudo code, I cannot give you any, because it about detail.
Now follow the step above, and you should have a wonderful web service.
Cold
0
 
LVL 5

Expert Comment

by:coldboy
Comment Utility
There is a mistake on the javascript code above.
change it:
function invoke: function (){
        var options = {
            method: "post",
            onSuccess: requestOK,
            postBody: "{param: \"How can this work\"}",
            contentType: "application/json"
        }
        return new Ajax.Request("HelloWorld.asmx/TalkToMe", options);
    }
0
 

Author Comment

by:irfo
Comment Utility
Thank you so much for taking the time to code the code.

Much appreciated.
0
 

Author Comment

by:irfo
Comment Utility
Sorry,

Post the code.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now