Java/Pingアプリケーション/Pingを受け付けるServlet
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
今回のPingアプリケーションの機能要件とは直接関係ないです...
うけつけるサーブレットでは、おなじみの[[Apache XML-RPC:ht...
サーブレットのクラス名は
nu.mine.kino.servlets.ping.PingReceiver
としました。
サーブレットのdoPostを以下の通りOverrideします。
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletExcept...
logger.debug("doPost(HttpServletRequest, HttpServletRe...
XmlRpc.setEncoding("UTF-8");
XmlRpcServer xmlrpc = new XmlRpcServer();
// Handlerの追加。このハンドラは、weblogUpdates.ping ...
// pingはメソッド名。
xmlrpc.addHandler("weblogUpdates", new UpdateHandler()...
try {
byte[] result = xmlrpc.execute(request.getInputStrea...
response.setContentType("text/html");
response.setContentLength(result.length);
OutputStream out = response.getOutputStream();
out.write(result);
out.flush();
} catch (IOException e) {
logger.error("doPost(HttpServletRequest, HttpServlet...
}
logger.debug("doPost(HttpServletRequest, HttpServletRe...
}
ここで
xmlrpc.addHandler("weblogUpdates", new UpdateHandler());...
の意味ですが、このエンドポイントのweblogUpdates.hogeとい...
UpdateHandlerは特別なインタフェースを実装するわけではなく...
public class UpdateHandler {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(...
// pingというメソッド名を定義
public Hashtable ping(String name, String url) throws ...
logger.debug("ping(String, String) - start");
logger.debug("Name: " + name);
logger.debug("url : " + url);
Hashtable result_hash = new Hashtable();
result_hash.put("name", name);
result_hash.put("url", url);
result_hash.put("message", "Thanks for the ping");
result_hash.put("error", Boolean.FALSE);
logger.debug("ping(String, String) - end");
return result_hash;
}
}
これで、このエンドポイントのweblogUpdates.pingというメソ...
ちなみに、このサービスのエンドポイントは
http://[サーバ名]/[context]/[サーブレット名]
となります。ここでは
http://localhost:8080/PingWeb/PingReceiver
としました。
----
この記事は
#vote(おもしろかった[2],そうでもない[1])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
終了行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
今回のPingアプリケーションの機能要件とは直接関係ないです...
うけつけるサーブレットでは、おなじみの[[Apache XML-RPC:ht...
サーブレットのクラス名は
nu.mine.kino.servlets.ping.PingReceiver
としました。
サーブレットのdoPostを以下の通りOverrideします。
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletExcept...
logger.debug("doPost(HttpServletRequest, HttpServletRe...
XmlRpc.setEncoding("UTF-8");
XmlRpcServer xmlrpc = new XmlRpcServer();
// Handlerの追加。このハンドラは、weblogUpdates.ping ...
// pingはメソッド名。
xmlrpc.addHandler("weblogUpdates", new UpdateHandler()...
try {
byte[] result = xmlrpc.execute(request.getInputStrea...
response.setContentType("text/html");
response.setContentLength(result.length);
OutputStream out = response.getOutputStream();
out.write(result);
out.flush();
} catch (IOException e) {
logger.error("doPost(HttpServletRequest, HttpServlet...
}
logger.debug("doPost(HttpServletRequest, HttpServletRe...
}
ここで
xmlrpc.addHandler("weblogUpdates", new UpdateHandler());...
の意味ですが、このエンドポイントのweblogUpdates.hogeとい...
UpdateHandlerは特別なインタフェースを実装するわけではなく...
public class UpdateHandler {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(...
// pingというメソッド名を定義
public Hashtable ping(String name, String url) throws ...
logger.debug("ping(String, String) - start");
logger.debug("Name: " + name);
logger.debug("url : " + url);
Hashtable result_hash = new Hashtable();
result_hash.put("name", name);
result_hash.put("url", url);
result_hash.put("message", "Thanks for the ping");
result_hash.put("error", Boolean.FALSE);
logger.debug("ping(String, String) - end");
return result_hash;
}
}
これで、このエンドポイントのweblogUpdates.pingというメソ...
ちなみに、このサービスのエンドポイントは
http://[サーバ名]/[context]/[サーブレット名]
となります。ここでは
http://localhost:8080/PingWeb/PingReceiver
としました。
----
この記事は
#vote(おもしろかった[2],そうでもない[1])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
ページ名: