0
약간의 문제가 있습니다. 나는 첫 번째 Android 앱과 첫 번째 WCF 서비스를 동시에하고 있습니다. 나는 다음과 같은 서비스 계약이 ... 나와 함께 베어하십시오Android 클라이언트에서 웹 서비스 호출
[ServiceContract]
public interface ILoginService
{
[OperationContract]
string Login(string username, string password);
// TODO: Add your service operations here
}
내가 내 안드로이드 응용 프로그램에서이를 호출하고 사용자 이름과 암호 매개 변수를 전달하고자합니다. 1.이 작업이 작업에 적합한 것입니까? 2. 누군가 Android를 통해이 WCF 서비스를 호출하는 방법에 대한 자습서/코드 샘플을 가르쳐 주시겠습니까?
감사합니다.
편집 : 좀 더 가까울 지 모르지만 나는 여전히 길을 잃었습니다. 계약 : : 지금 뭐가 잘못 아무 생각
public LoginResponse RemoteLogin(String username, String password)
{
loginParameters = "/LoginService/username=" + username + "&password=" + password;
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(serviceAddress + loginParameters);
HttpResponse response;
LoginResponse loginResponse = null;
try
{
response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if(entity != null)
{
InputStream instream = entity.getContent();
String result = convertStreamToString(instream);
JSONObject json = new JSONObject(result);
// Parsing
JSONArray nameArray = json.names();
JSONArray valArray = json.toJSONArray(nameArray);
loginResponse = new LoginResponse(valArray.getBoolean(1), valArray.getString(0), valArray.getString(2));
instream.close();
}
}
catch(Exception e)
{
loginResponse = new LoginResponse();
String sDummy = e.toString();
}
return loginResponse;
}
:
[OperationContract]
[WebGet(ResponseFormat= WebMessageFormat.Json,
UriTemplate="/LoginService/?username={username}&password={password}")]
Response Login(string username, string password);
가 그럼 난 안드로이드에서 서비스를 호출을 여기에 내가 지금까지 가지고있는 것입니다.
샘플 코드를 제공해 주시겠습니까? –
android.please에서 wcf 서비스로 시작하는 방법을 설명하고 몇 가지 단계를 시작하십시오. 나는 이것에 관해 어떤 생각도 가지지 않고있다. –