WCF web service
からの呼び出しに問題がありAndroid application
ます。以下の URL を呼び出すと"http://10.0.2.2:80/WebService/WebServiceImpl.svc"
responseが返さ"200 OK"
れますが、サービス内で関数を呼び出そうとすると"http://10.0.2.2:80/WebService/WebServiceImpl.svc/Test"
、 response が返され"400 Bad request"
ます。
誰か助けてくれませんか?
namespace WebService
{
public class WebServiceImpl : IWebServiceImpl
{
#region IRestServiceImpl Members
public string Test()
{
return "Test pass";
}
#endregion
}
}
namespace WebService
{
[ServiceContract]
public interface IWebServiceImpl
{
[OperationContract]
[WebInvoke(
Method = "GET")]
string Test();
}
}
Android アクティビティ:
public void onClick(View v)
{
// TODO Auto-generated method stub
HttpClient client = new DefaultHttpClient();
String SERVER_HOST="10.0.2.2";
int SERVER_PORT = 80;
String URL = "http://10.0.2.2:80/WebService/WebServiceImpl.svc/Test";
HttpHost target = new HttpHost(SERVER_HOST, SERVER_PORT, "http");
HttpGet request = new HttpGet(URL);
try
{
HttpResponse response = client.execute(target,request);
HttpEntity entity = response.getEntity();
MessageBox(response.getStatusLine().toString());
}
catch(Exception e)
{
MessageBox("excepton");
MessageBox(e.toString());
}
}
public void MessageBox(String message){
Toast.makeText(this,message,Toast.LENGTH_LONG).show();
}