public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);        setContentView(R.layout.main);
        SoapObject request = new SoapObject("http://tempuri.org/", "HelloWorld");  
        
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);   
      
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        AndroidHttpTransport  ht = new AndroidHttpTransport("http://192.168.1.101/Service/Service1.asmx");
        try {
         //这一步报错java.net.SocketException: Permission denied
         ht.call("http://tempuri.org/HelloWorld",envelope);

SoapObject soapObject = (SoapObject) envelope.getResponse();  

TextView tvResult = (TextView)findViewById(R.string.hello); 

tvResult.setText(soapObject.getProperty(0)+""); 

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}对java.net.SocketException: Permission denied
网上说加权限<uses-permission android:name="android.permission.INTERNET" /> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test.web"
      android:versionCode="1"
      android:versionName="1.0">    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".ActivityWeb"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<uses-permission android:name="android.permission.INTERNET" /> 
    </application>
</manifest>
最后还是报那个错!有专家分析下

解决方案 »

  1.   


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.test.web"
          android:versionCode="1"
          android:versionName="1.0">    <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".ActivityWeb"
                      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>    <uses-permission android:name="android.permission.INTERNET" /> 
    </manifest>
    这样试下,权限语句放在application外面。
      

  2.   

    对啊,我记得权限应该加在applicaiton的外边的啊
      

  3.   

    对我忘了,我放下面了,
    但现在又报下面错误,帮我看看程序代码 正确否public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);        setContentView(R.layout.main);
            SoapObject request = new SoapObject("http://tempuri.org/", "HelloWorld");  
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);   
          
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            AndroidHttpTransport  ht = new AndroidHttpTransport("http://192.168.1.101/Service/Service1.asmx");
            try {
                          ht.call("http://tempuri.org/HelloWorld",envelope);
                //报java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive
                SoapObject soapObject = (SoapObject) envelope.getResponse();  
                
                TextView tvResult = (TextView)findViewById(R.string.hello); 
                
                tvResult.setText(soapObject.getProperty(0)+""); 
                
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (XmlPullParserException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
      

  4.   

     SoapObject request = new SoapObject("http://tempuri.org/", "HelloWorld");
    引用不对。、
    把引用路径全部写上可过、
    如:
    org.ksoap2.serialization.SoapObject soa=new org.ksoap2.serialization.SoapObject("http://tempuri.org/", "HelloWorld");
    检查引用ksoap包时是否有错误!
      

  5.   

    不是权限的问题,我试过了,在    SoapObject soapObject = (SoapObject) envelope.getResponse(); 这一句有问题我改成这样 Object oj=envelope.getResult();
    就通过了,虽然成功了,不知道为什么