wcf 서비스에 연결하고 결과를 반환하는 android 응용 프로그램을 개발하고 있습니다. wcf는 비누로 작성되었으며 연결을 위해 KSOAP2를 사용하고 있습니다.android app가 호스트를 확인할 수 없습니다.
처음에는 특정 URL에 연결하고 모든 것이 잘 작동하고있었습니다. 그런 다음 URL을 변경해야만 알 수없는 예외가 발생합니다 unable to resolve host:No address associated with name
.
나는 내 연구를 수행했으며 다른 모든 유사한 문제에 대한 해결책은 Android Manifest 인터넷 연결에 추가되었습니다. 하지만 이미 해 봤어. 어떤 제안이 있니? 또 다른 세부 사항은 내 응용 프로그램이 정상적으로 작동하는 첫 번째 URL을 사용하는 것이므로 내 PC가이 서버에 제대로 연결되어 있어도 로컬 서버에 두 번째 일반 URL이 있다는 것입니다.
공용 클래스 KSoapConnector이 InstantiateConnection {
private SoapObject response;
private WcfReceivedClass identifier;
private WcfReceivedClass[] receivedData;
private final String NAMESPACE = "http://microsoft.com/webservices/";
private String METHOD_NAME="GetTeacherClass";
private String SOAP_ACTION = "http://microsoft.com/webservices/IVertiSchool_SRV/GetTeacherClass";
private final String URL = "http://vertiserv1:81/VertiSchool_SRV.svc";
//below is the url which was working fine
//private final String URL = "http://wcf.schoolportal.gr/VertiSchool_SRV.SVC";
public KSoapConnector(String methodName,int mode){
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
//here are the parameters for the wcf service and there values are correctly put
Request.addProperty("connString", "connectionString");
Request.addProperty("TeCode", "tCode");
Request.addProperty("Company", "cmp");
Request.addProperty("Lng", "lng");
Request.addProperty("MainPeriod", "mainPrd");
SoapSerializationEnvelope envelope = new SerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
envelope.addMapping(NAMESPACE, "SRV_Class",new SRV_Class().getClass());
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try{
//here is where i get the exception...
androidHttpTransport.call(SOAP_ACTION, envelope);
response = (SoapObject)envelope.getResponse();
receivedData = identifier.retrieveFromSoap(response);
}
catch(Exception e){
e.printStackTrace();
}
}
및 구현 : 브라우저에 URL을 내가 여기에 연결을 설정 클래스를 게시하도록하겠습니다 그와 연결 문제)
이 없습니다여기 내 manifet 파일입니다
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ListOfClasses"></activity>
</application>
내가 안드로이드에 로컬 호스트가 10.0.2.2 것을 알고는 있지만, 내 응용 프로그램은 로컬 서버에 곧장 연결 ... 난 어떤 포트를 전달해야합니까?
코드별로 구체적으로 표시 할 수 있습니까? – Michal
휴대 전화의 브라우저를 사용하여 URL에 연결할 수 있습니까? –
@subirkumarsao 나는 그것을 시도하지는 않았지만 다른 URL과 제대로 연결할 수 있었기 때문에 관련이 있습니까? – Libathos