私は.NETでサーバーを作成しており、Android用のクライアントアプリケーションを作成しています。私はサーバーにユーザー名とパスワードを送信する認証メソッドを実装したいと思いますし、サーバーはセッション文字列を送り返します。AndroidでWCFサービスを使用する方法
私はWCFに精通していないので、本当にありがとうございます。
は、Javaで私は、次のメソッドを書いている:
private void Login()
{
HttpClient httpClient = new DefaultHttpClient();
try
{
String url = "http://192.168.1.5:8000/Login?username=test&password=test";
HttpGet method = new HttpGet(new URI(url));
HttpResponse response = httpClient.execute(method);
if (response != null)
{
Log.i("login", "received " + getResponse(response.getEntity()));
}
else
{
Log.i("login", "got a null response");
}
} catch (IOException e) {
Log.e("error", e.getMessage());
} catch (URISyntaxException e) {
Log.e("error", e.getMessage());
}
}
private String getResponse(HttpEntity entity)
{
String response = "";
try
{
int length = (int) entity.getContentLength();
StringBuffer sb = new StringBuffer(length);
InputStreamReader isr = new InputStreamReader(entity.getContent(), "UTF-8");
char buff[] = new char[length];
int cnt;
while ((cnt = isr.read(buff, 0, length - 1)) > 0)
{
sb.append(buff, 0, cnt);
}
response = sb.toString();
isr.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return response;
}
しかし、サーバ側の
は、これまでのところ、私は何かを考え出したていません。誰でも適切なメソッド文字列を作成する方法を説明できれば本当に感謝します。これらの2つのパラメータを読み込むには、適切なApp.config設定と適切な[OperationContract]署名付きのログイン(文字列ユーザー名、文字列パスワード)クライアントとセッション文字列で応答します。
ありがとうございます!
私はアンドロイドでシリアル化されたwcfバイナリを消費する方法を見たいと思っています。今それはクールだ。 –