?
Solved

Need pseudo-code

Posted on 2008-06-14
8
Medium Priority
?
511 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 1 hour left to enroll

864 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