1. Usługa sieciowa działająca w systemie SAS musi implementować

Transkrypt

1. Usługa sieciowa działająca w systemie SAS musi implementować
1. PRZYGOTOWANIE USŁUGI:
1. Usługa sieciowa działająca w systemie SAS musi implementować interface
Iservice.
2. Przykładowy szablon usługi noticeboard: template.
3. Zadanie:
Zadanie polega na uzupełnieniu szablonu usługi o mechanizm dodawania
oraz wyświetlania wiadomości.
1. Należy utworzyć klase reprezentującą pojedyńczą wiadomość.
2. Należy zaimplementować obsługę metody HTTP POST. Powinna ona
parsować HTTP Request oraz zapisać wiadomość zawartą w polu
content do pamięci operacyjnej. Do parsowania requestu można
wykorzystać klasę Request. Dane przesyłane metodą POST można
otrzymać wykorzystując metodę getPostArg(string key).
3. Klasa reprezentująca pojedynczą wiadomość powinna implementować
funkcję publiczną zwracającą ciąg znaków zawierający kod html,
reprezentujący pojedynczą wiadomość. Można wykorzystać poniższą
funkcję:
public static string CreatePost(string pstrTopic, string pstrUserId,
string pstrContent) {
string res ="\n";
_InsertIndent(ref res);
res += "<div id = \"post\">\n";
_InsertIndent(ref res);
res += "\t<div id=\"big_title\">\n";
_InsertIndent(ref res);
res += "\t\t" + pstrTopic + "\n";
_InsertIndent(ref res);
res += "\t</div>\n";
_InsertIndent(ref res);
res += "\t<div id = \"date\">\n";
_InsertIndent(ref res);
res += "\t\t" + "date" + "\n";
_InsertIndent(ref res);
res += "\t</div>\n";
_InsertIndent(ref res);
res += "\t<div id = \"post_content\">\n";
_InsertIndent(ref res);
res += "\t\t" + pstrContent + "\n";
_InsertIndent(ref res);
res += "\t</div>\n";
_InsertIndent(ref res);
res += "\t<div id = \"author\">\n";
_InsertIndent(ref res);
res += "\t\t" + pstrUserId + "\n";
_InsertIndent(ref res);
res += "\t</div>\n";
_InsertIndent(ref res);
res += "</div>\n";
return res;
}
4. Należy roszerzyć metodę HTTP GET o wyświetlanie postów
przechowywanych w pamięci. Posty powinny być dodane pomiędzy
dwie części strony wczytywane z zasobów. Pomocna może okazać się
funkcją _StringToByte().
5. Implementacja method GetState(), SetState(). Klasa reprezentująca
wiadomości powinna posiadać ustawiony atrybut Serializable.
Wspomniane metody mogą wyglądać następująco:
public Object GetState() {
return (object)this.posts;
}
public void SetState(object pobjState) {
try {
}
this.posts = (/*typ kolekcji*/)(pobjState);
} catch(Exception ex) {
Console.WriteLine("set state ex: " + ex.Message);
}
Właściwa serializacje będzie gwarantowana przez system SAS.
2. URUCHOMIENIE USŁUGI W SYSTEMIE SAS:
1. Pobranie systemu SAS.
2. Konfiguracja systemu jest wykonywana za pomoca pliku
sas-configuration.xml:
1. Ustawienie adresu sieciowego oraz maski sieciowej na podane przez
prowadzącego.
2. Ustawienie portu http proxy.
3. Uruchomienie systemu:
1. mono sas-proxy.exe sas-configuration.xml

Podobne dokumenty