Solved

Need pseudo-code

Posted on 2008-06-14
8
503 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

685 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