私は、デバイスSQLiteとサーバーMS SQLデータベース間のデータをIIS 7で複製するWebサービスを構築しています.Webサービスは、 。 transporte.callが実行されると、アクセス拒否エラーが発生します。私はSamsung Note Edgeデバイスから実行しようとしています。モバイルアプリケーションからlocalhost Webサービスを呼び出す際にアクセス拒否エラーが発生しました
VB.Netを使って、Webサービスの両方のメソッドをネットワーク上の別のコンピュータから正常に使用できることに注意してください。
ありがとうございました。
主な活動:
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import org.json.JSONArray;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class MainActivity extends AppCompatActivity {
private final String NAMESPACE = "http://192.168.0.2/";
private final String URL = "http://192.168.0.2/MimsWeb/MimsWeb.asmx";
private final String SOAP_ACTION = "MimsWeb";
private final String METHOD_NAME = "RetrieveS";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
request.addProperty("select * from Product","Prduct");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
try {
HttpTransportSE transporte = new HttpTransportSE(URL);
transporte.call(SOAP_ACTION,envelope);
SoapPrimitive resultadoXML = (SoapPrimitive)envelope.getResponse();
//Log.e("Valor de respuesta",resultadoXML.toString());
String resultado = resultadoXML.toString();
}catch (Exception e){
e.printStackTrace();
Toast.makeText(getBaseContext(),e.getMessage().toString(),Toast.LENGTH_LONG).show();
}
}
}
マニフェスト:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
ログイン
I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
W/art: Debugger attempted to resume all threads without having suspended them all before.
W/System.err: java.net.SocketException: socket failed: EACCES (Permission denied)
Disconnected from the target VM, address: 'localhost:8606', transport: 'socket'
のWebサービスURL:
http://192.168.0.2/MimsWeb/MimsWeb.asmx
The following operations are supported. For a formal definition, please review the Service Description.
InsertS
RetrieveS
の取得:AndroidManifest.xml
、uses-permission
タグで
http://192.168.0.2/MimsWeb/MimsWeb.asmx?op=RetrieveS
Click here for a complete list of operations.
RetrieveS
Test
To test the operation using the HTTP POST protocol, click the 'Invoke' button.
Parameter Value
s:
t:
Invoke
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
POST /MimsWeb/MimsWeb.asmx HTTP/1.1
Host: 192.168.0.2
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://192.168.0.2/RetrieveS"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<RetrieveS xmlns="http://192.168.0.2/">
<s>string</s>
<t>string</t>
</RetrieveS>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<RetrieveSResponse xmlns="http://192.168.0.2/">
<RetrieveSResult>xmlxml</RetrieveSResult>
</RetrieveSResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.
POST /MimsWeb/MimsWeb.asmx HTTP/1.1
Host: 192.168.0.2
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<RetrieveS xmlns="http://192.168.0.2/">
<s>string</s>
<t>string</t>
</RetrieveS>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<RetrieveSResponse xmlns="http://192.168.0.2/">
<RetrieveSResult>xmlxml</RetrieveSResult>
</RetrieveSResponse>
</soap12:Body>
</soap12:Envelope>
HTTP GET
The following is a sample HTTP GET request and response. The placeholders shown need to be replaced with actual values.
GET /MimsWeb/MimsWeb.asmx/RetrieveS?s=string&t=string HTTP/1.1
Host: 192.168.0.2
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<DataTable xmlns="http://192.168.0.2/">xmlxml</DataTable>
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.
POST /MimsWeb/MimsWeb.asmx/RetrieveS HTTP/1.1
Host: 192.168.0.2
Content-Type: application/x-www-form-urlencoded
Content-Length: length
s=string&t=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<DataTable xmlns="http://192.168.0.2/">xmlxml</DataTable>
は 'transporte.call一度executed'です。 transporteコールとは何ですか?残りの部分については、私はあなたの問題が何であるか理解していません。すべて非常に曖昧です。 – greenapps
'モバイルブラウザからウェブサービスが実行され、WiFiに問題はありません。すべてがうまくいくなら問題は何ですか?または、モバイル接続を使用する際に問題があることを意味しますか?あなたはあなたの設定を説明しませんでした。 – greenapps
ブラウザからwebserviceを呼び出すと、正常に動作します。 AndroidサービスからWebサービス呼び出しを実行すると、実行が完了するとエラーが発生します。HttpTransportSE transporte = new HttpTransportSE(URL); –