Android 应用程序将简单的表单发送到 Web 服务并获取短信作为回报
我正在尝试用简单的形式编写一个Android应用程序。用户将向服务器发送一个字符串,并收到一条短信,其中包含相同的字符串+“谢谢!”。
我了解 Java,但我更擅长 C#。我确实设法将字符串发送到网络服务。
在 Android 客户端上:
public void sendFeedback(View button) {
final EditText nameField = (EditText) findViewById(R.id.EditTextName);
String name = nameField.getText().toString();
postData(name);
}
public void postData(String name) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://localhost:53811/WinnerSite/WebService.asmx?op=WriteToDB");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("json", name));
// nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
System.out.println(response.getFirstHeader(getPackageName()));
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
Web 服务非常薄弱:
[WebMethod]
public string WriteToDB(string json)
{
return "Hello World "+ json;
}
我使用 Visual-Studio 内置的服务器服务运行 Web 服务。 应用程序背后的代码正确获取了字符串,但代码从未收到该字符串。有人知道可能是什么问题吗?
在下一阶段,我无法找到从我的网络服务 SMS 发送至以下以色列运营商之一的 SMS 电子邮件网关:
- Orange(又名合作伙伴)
- Cellcom
有人可以帮助我找到该网关吗?
I'm trying to write an android application with a simple form. The user will send a string to a server and will get an SMS back with the same string + "thank you!".
I know Java but I'm more fluent in C#. I did manage to send the string to the web-service.
On Android Client:
public void sendFeedback(View button) {
final EditText nameField = (EditText) findViewById(R.id.EditTextName);
String name = nameField.getText().toString();
postData(name);
}
public void postData(String name) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://localhost:53811/WinnerSite/WebService.asmx?op=WriteToDB");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("json", name));
// nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
System.out.println(response.getFirstHeader(getPackageName()));
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
Web-Service is pretty slim:
[WebMethod]
public string WriteToDB(string json)
{
return "Hello World "+ json;
}
I ran the web-service with Visual-Studio built in server service.
The code behind the application got the string properly, but the code never recieved the string. Does someone has an idea what could be the problem?
the next phase, I cannot find the SMS email gate to SMS from my web-service SMS to one of the following Israeli operators:
- Orange (a.k.a Partner)
- Cellcom
Can someone help me find that gate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
并在服务器中使用
可能对您有帮助的消息发送消息
try to use
and in the server send a message by using
that may help you