ここに投稿する前に多くの選択肢を確認しました。
なぜこのエラーがUnKnownHost Exception
発生するのかわかりません。誰かが解決策を教えてください。
MyCallingクラス
public class AndroidLoginExampleActivity extends Activity
{
private static final String SOAP_ACTION ="urn:Mage_Api_Model_Server_HandlerAction";
private static final String NAMESPACE = "urn:Magento";
private static final String Method_Name="login";
private static final String URL ="http://cws24/machinetest/api/?wsdl";
TextView tv;
Context mContext;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.tv_status);
SoapObject request = new SoapObject(NAMESPACE,Method_Name);
request.addProperty("username", "android");
request.addProperty("apiKey", "android");
SoapSerializationEnvelope envelopes = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelopes.dotNet = false;
envelopes.setOutputSoapObject(request);
mContext=AndroidLoginExampleActivity.this;
try
{
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.debug =true;
androidHttpTransport.call(SOAP_ACTION, envelopes);//Getting the Exception here
SoapPrimitive resultString=(SoapPrimitive)envelopes.getResponse();
tv.setText("Status "+resultString);
new AlertDialog.Builder(mContext).setMessage(""+resultString).show();
}
catch (Exception e) {e.printStackTrace();
new AlertDialog.Builder(mContext).setMessage(""+e.toString()).show();
}
}
}
ログ出力::
07-17 02:20:43.376: WARN/System.err(25212): java.net.UnknownHostException: Host is unresolved: cws24:80
07-17 02:20:43.416: WARN/System.err(25212): at java.net.Socket.connect(Socket.java:1037)
07-17 02:20:43.466: WARN/System.err(25212): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
07-17 02:20:43.486: WARN/System.err(25212): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
07-17 02:20:43.496: WARN/System.err(25212): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
07-17 02:20:43.496: WARN/System.err(25212): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:821)
07-17 02:20:43.496: WARN/System.err(25212): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:807)
07-17 02:20:43.496: WARN/System.err(25212): at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:46)
07-17 02:20:43.506: WARN/System.err(25212): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:68)
07-17 02:20:43.506: WARN/System.err(25212): at com.magento.example.AndroidLoginExampleActivity.onCreate(AndroidLoginExampleActivity.java:44)
07-17 02:20:43.506: WARN/System.err(25212): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-17 02:20:43.506: WARN/System.err(25212): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
07-17 02:20:43.516: WARN/System.err(25212): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
07-17 02:20:43.516: WARN/System.err(25212): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-17 02:20:43.516: WARN/System.err(25212): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
07-17 02:20:43.546: WARN/System.err(25212): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 02:20:43.546: WARN/System.err(25212): at android.os.Looper.loop(Looper.java:123)
07-17 02:20:43.556: WARN/System.err(25212): at android.app.ActivityThread.main(ActivityThread.java:4363)
07-17 02:20:43.556: WARN/System.err(25212): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 02:20:43.567: WARN/System.err(25212): at java.lang.reflect.Method.invoke(Method.java:521)
07-17 02:20:43.567: WARN/System.err(25212): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-17 02:20:43.576: WARN/System.err(25212): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-17 02:20:43.576: WARN/System.err(25212): at dalvik.system.NativeStart.main(Native Method)