2012-06-13 118 views
0

我創建了一個Android應用程序的支持: 這是我的代碼:java.net.SocketException異常:地址族不受協議

package com.retailer.client; 

import android.app.Activity; 
import android.os.Bundle; 
import org.ksoap2.SoapEnvelope; 
    import org.ksoap2.serialization.SoapObject; 
import org.ksoap2.serialization.SoapPrimitive; 
import org.ksoap2.serialization.SoapSerializationEnvelope; 
import org.ksoap2.transport.HttpTransportSE; 
import android.widget.TextView; 

public class RetailerActivity extends Activity { 
private static final String SOAP_ACTION = "http://ws.retailer.com/customerData"; 
private static final String METHOD_NAME = "customerData"; 
private static final String NAMESPACE = "http://ws.retailer.com"; 
private static final String URL = "http://10.0.0.55:8085/javaws/services/RetailerWS?wsdl"; 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 


    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

    envelope.setOutputSoapObject(request); 

    HttpTransportSE ht = new HttpTransportSE(URL); 
    try { 
     ht.call(SOAP_ACTION, envelope); 
     SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); 


     SoapPrimitive s = response; 
     String str = s.toString(); 
     String resultArr[] = str.split("&");//Result string will split & store in an array 

     TextView tv = new TextView(this); 

     for(int i = 0; i<resultArr.length;i++){ 
     tv.append(resultArr[i]+"\n\n"); 
     } 
     setContentView(tv); 

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

但是當我調試它出現了: 05-24 17:46: 26.031:D/SntpClient(71):請求時間失敗:java.net.SocketException:協議不支持地址系列

如何清除。請引導我。

+0

告訴我的朋友...我如何解決dis錯誤...請指導我 –

回答

0

您是否在AndroidManifest.xml中包含權限?

<uses-permission android:name="android.permission.INTERNET" /> 
+0

已經添加了 –

相關問題