gpt4 book ai didi

java - Android java.net.SocketException : socket failed: EACCES (Permission denied) while inserting value into sql server through Web service

转载 作者:太空宇宙 更新时间:2023-11-04 14:13:00 29 4
gpt4 key购买 nike

在我的项目中,我尝试通过调用Web服务将用户详细信息插入到SQL Server中,当我连接到Web服务时,logcat中出现java.net.SocketException:套接字失败:EACCES(权限被拒绝)警告,下面是我的代码。我无法将值插入 SQL Server。

RegisterToServer.java

public class RegisterToServer extends AsyncTask<UserDetails, Void, Void> {

String SOAP_ACTION1 = "http://tempuri.org/RegisterUser";
String NAMESPACE = "http://tempuri.org/";
String METHOD_NAME1 = "RegisterUser";

String URL="http://192.168.0.100/panictest/WebService2.asmx";

private String TAG = "RegisterUser";

String responseString;
String responseStatus = "SUCCESS";
Context context;

@Override
protected Void doInBackground(UserDetails... params) {
Log.i(TAG, "doInBackground");
RegToServer(params[0]);
return null;
}

@Override
protected void onPostExecute(Void result) {
Log.i(TAG, "onPostExecute");


}

@Override
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
// Display the progress bar

}

@Override
protected void onProgressUpdate(Void... values) {
Log.i(TAG, "onProgressUpdate");
}

private void RegToServer(UserDetails user) {

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("mobileNumber", user.getMobilNumber());
request.addProperty("userName", user.getUserName());
request.addProperty("address", user.getAddress());
Log.i("TAG","Inside regtoserver before webservice call"+user.getAddress());

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;


try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION1, envelope);


Object response = (Object) envelope.getResponse();


Log.i("GET ROAD TAX", "Websevice called");



} catch (Exception e) {
e.printStackTrace();


}

list 文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.panicbutton"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>



</manifest>

Logcat

最佳答案

尝试添加:

<uses-permission android:name="android.permisson.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.READ_PROFILE"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

关于java - Android java.net.SocketException : socket failed: EACCES (Permission denied) while inserting value into sql server through Web service,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067134/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com