Solved

Need pseudo-code

Posted on 2008-06-14
8
501 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
ID: 21787412
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
ID: 21789330
Hi there,

its .NET 2.

Still  as easy?
0
 

Author Comment

by:irfo
ID: 21789459
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:irfo
ID: 21789463
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
 
LVL 5

Accepted Solution

by:
coldboy earned 500 total points
ID: 21812760
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
ID: 21819622
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
ID: 21835367
Thank you so much for taking the time to code the code.

Much appreciated.
0
 

Author Comment

by:irfo
ID: 21835373
Sorry,

Post the code.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Latency in .net app using DB in .net 21 62
HTTPS jquery doesn't work 9 58
Javascript to set controls visibility 5 33
How to join on ID, with prefix? 15 58
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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