Mother’s Day


Today, 22nd of December, we Indonesian is celebrating mother’s day. Close to Cristmas, this usually used by preachers to notify us Christian about how important our mother is.

Mother is a figure, mother is our very first teacher, the one whom we, must love and care most. There was a story, I don’t know whether it was true or not, where every old and sick mom must be brought to the middle of a forest and left there by their son.

One time, there was a son who was going to do so, brought his mother to a middle of a forest and left her there. He pickaback his mother and left the house heading to the forest. Knowing their direction, his mother knew that she was going to be left there. His mother thought of the last thing she could to to her son. As soon as they reach the forest, she grabbed any branches she could reach and cut it. When the son put his mother down in the middle of the forest with sad expression, he told his mother that he was going to left her there. Amazingly, because love, his mother said, “My son, I knew that you are going to left me here. When you go back, look for branches I have left on the grounds so that you can return home safety.” Hearing that, the son picked his mother up and carried her back to their home, ignoring what may people said about him.

Mother’s love is eternal and unlimited. Even when she knew that we were going to left her, she still love us with all she had. Motgher is the one willing to suffer for us. A woman, that will never left us.

So, people, love your mother because she had loved yoy first.

Sitecore – Web Service


I don’t know whether I should hold my post for another day or I keep posting everything. But well, I am in mood to post things, so here it is.

Somehow, I develop a web that using javascript to run a serverside method. Yes, sometimes you need that. I figure it out how to use that and I got the answer: web service.

Sitecore has provide its developer with a web service to access some functions. You can find it on /sitecore/shell/Webservice/Service.asmx Well they provide some useful functions I told you and you might need that. But those functions are not always needed (I guess). For me, (I don’t know about others) I use web service to access data that my application provide not the data that CMS provide for my application. For example, sitecore is providing me the list of users, I really don’t need to use web service (at least until now) to access that. My application provide a list of products and I need to access them from anywhere. Oh, and by the way, if you use the web service that Sitecore provide you will be logged in as sitecore/* user.

So, I create a custom web service in my application. Just say that the web service provide me a function that returns a list of string. I have to call it using javascript. How do I do that? Here’s the step.

  1. Add [System.Web.Script.Services.ScriptService] tag before your web service class definition. So it will become like the code below.

    [System.Web.Script.Services.ScriptService]
    public class ClassName : System.Web.Services.WebService
    
  2. You need to register your service in your web control. Using the code below, you can register the web service as a script on a control.

    <asp:ScriptManager ID="_scriptManager" runat="server">
      <Services>
        <asp:ServiceReference Path="/path/to/your/web/service.asmx" />
      </Services>
    </asp:ScriptManager>
    
  3. Then you may call it using javascript using the code below.

    The.Namespace.Of.Your.Web.Service.WSName.MethodName([params,]OnSuccess,OnFail,userContext);
    

    Params is all parameters needed by your web service method. OnSuccess is a function that will process the result if there is no error. OnFail is a function that will process the result if there is any error. And I haven’t used userContext. 😀

  4. the function to process the result will be like

    function FunctionName(result) {
        /* body */
    }
    

Simple right? Just four steps to use it. You can do most of anything. And if you want to use the web service from the server side C# code, it becomes even simpler. You only need to add reference then use it as you like.