2013年9月5日星期四

android ksoap packet access the web using the simulator operating normally, simulator on the error , the solution , the error message is as follows :

12-14 16:17:35.926: WARN / System.err (3483): java.net.SocketException: The operation timed out
12-14 16:17:35.926: WARN / System.err (3483): at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl (Native Method)
12-14 16:17:35.926: WARN / System.err (3483): at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocket (OSNetworkSystem.java: 130)
12-14 16:17:35.926: WARN / System.err (3483): at org.apache.harmony.luni.net.PlainSocketImpl.connect (PlainSocketImpl.java: 246)
12-14 16:17:35.926: WARN / System.err (3483): at org.apache.harmony.luni.net.PlainSocketImpl.connect (PlainSocketImpl.java: 533)
12-14 16:17:35.936: WARN / System.err (3483): at java.net.Socket.connect (Socket.java: 1055 )
12-14 16:17:35.936: WARN / System.err (3483): at org.apache.harmony.luni.internal.net.www . protocol.http.HttpConnection. (HttpConnection.java: 62)
12-14 16:17:35.936: WARN / System.err (3483): at org.apache.harmony.luni.internal.net.www . protocol.http.HttpConnectionPool.get (HttpConnectionPool.java: 88)
12-14 16:17:35.936: WARN / System.err (3483): at org.apache.harmony.luni.internal.net.www . protocol.http.HttpURLConnectionImpl.getHTTPConnection (HttpURLConnectionImpl.java: 927)
12-14 16:17:35.936: WARN / System.err (3483): at org.apache.harmony.luni.internal.net.www . protocol.http.HttpURLConnectionImpl.connect (HttpURLConnectionImpl.java: 909)
12-14 16:17:35.946: WARN / System.err (3483): at org.ksoap2.transport.ServiceConnectionSE.connect (ServiceConnectionSE.java : 76 )
12-14 16:17:35.946: WARN / System.err (3483): at org.ksoap2.transport.HttpTransportSE.call (HttpTransportSE.java : 146 )
12-14 16:17:35.946: WARN / System.err (3483): at org.ksoap2.transport.HttpTransportSE.call (HttpTransportSE.java : 95 )
12-14 16:17:35.956: WARN / System.err (3483): at com.menten.until.ServerHelper.Call (ServerHelper.java : 31 )
12-14 16:17:35.956: WARN / System.err (3483): at com.menten.until.mainSevice.doTask (mainSevice.java : 139 )
12-14 16:17:35.956: WARN / System.err (3483): at com.meten.ui.Login $ 2.onClick (Login. java: 85)
12-14 16:17:35.956: WARN / System.err (3483): at android.view.View.performClick (View.java: 2408 )
12-14 16:17:35.956: WARN / System.err (3483): at android.view.View $ PerformClick.run (View.java : 8816 )
12-14 16:17:35.956: WARN / System.err (3483): at android.os.Handler.handleCallback (Handler.java: 587 )
12-14 16:17:35.956: WARN / System.err (3483): at android.os.Handler.dispatchMessage (Handler.java: 92 )
12-14 16:17:35.966: WARN / System.err (3483): at android.os.Looper.loop (Looper.java: 123 )
12-14 16:17:35.966: WARN / System.err (3483): at android.app.ActivityThread.main (ActivityThread.java: 4669 )
12-14 16:17:35.966: WARN / System.err (3483): at java.lang.reflect.Method.invokeNative (Native Method )
12-14 16:17:35.966: WARN / System.err (3483): at java.lang.reflect.Method.invoke (Method.java : 521 )
12-14 16:17:35.976: WARN / System.err (3483): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 876)
12-14 16:17:35.976: WARN / System.err (3483): at com.android.internal.os.ZygoteInit.main (ZygoteInit . java: 634)
12-14 16:17:35.976: WARN / System.err (3483): at dalvik.system.NativeStart.main (Native Method)

------ Solution ------------------------------------ --------

+ Q: 371278698
------ For reference only ------------------- --------------------
java.net.SocketException: The operation timed out timeout exception , not the server is not in the public network .
------ For reference only -------------------------------------- -
seems not the problem, I use my mobile browser can be opened to connect url
------ For reference only ----------------- ----------------------
yesterday before doing experiments. . . . Like a real machine using kosap library is somewhat problematic. . . .
------ For reference only -------------------------------------- -
not it . . Hundreds of thousands of packages with ksoap total success of it, that the project is not to hang . Do you want to change josn Khan resolve ? I faint , client service have been written , simulator test no problem, stuck in this . . . .
------ For reference only -------------------------------------- -
your title makes me dizzy , and in the end an error on the emulator is not being given
------ For reference only ----------------- ----------------------
wrong. Real machine error
------ For reference only ----------------------------------- ----

not be accessed with a real machine GPRS LAN it.
ksoap package is not a problem.
------ For reference only -------------------------------------- -
indeed GPRS access , but not the LAN ah. . .
------ For reference only -------------------------------------- -

I use the browser to access that you want to connect to my Url ah
------ For reference only ---------------- -----------------------


convenient, the webservice URL , namespace, call the method and parameters sent , I tested under
------ For reference only ------------ ---------------------------
amount . . This is the company's projects . . . I did this right . Decided ah. . . Tangle . . .
------ For reference only -------------------------------------- -

also , I have recently done and the project is using KSOAP WEBSERVICE communication .
previously been tested in a simulator ( compatible with multiple resolutions ) . See your post, I was a virtual , in the real machine with GPRS test a little , but fortunately can be connected .
facie access point is not the problem I use : cmnet.
at the time of the connection length: 30 seconds .
------ For reference only -------------------------------------- -

Thank you, you look at what you can do with cmwap I use this, after all, what the user is free to use . I have to make sure all wrong , I use the 2.5.7 package timeout setting is HttpTransportSE ht = new HttpTransportSE (serviceURL, 30000);
------ For reference only ---------------------------------------
I tried, changed cmnet connection is still the same error . .
------ For reference only -------------------------------------- -
which version you are using the ksoap package ?
------ For reference only -------------------------------------- -

ksoap2-android-assembly-2.4-jar-with-dependencies.jar
------ For reference only --------------- ------------------------
then you write your own timeout method it. ksoap2-android-assembly-2.5.7-jar-with-dependencies of the package has parameters HttpTransportSE ht = new HttpTransportSE (serviceURL, 30000); setting timeout does not seem easy to use, have a look at your own writing What that means timeout . . Thank you. .
------ For reference only -------------------------------------- -
my simulator unsuccessful solving
code below

package com.glServiceTest;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class GlServiceTestActivity extends Activity implements OnClickListener
{

/ ** Called when the activity is first created. * /
@ Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
Button button = (Button) findViewById (R.id.btn);
button.setOnClickListener (this);
}

public void onClick (View v)
{
/ / TODO Auto-generated method stub
EditText etBook = (EditText) findViewById (R.id.etBookName);
TextView tvResult = (TextView) findViewById (R.id.tvResult);
/ / private static final String NAMESPACE = "http://WebXml.com.cn/";
/ / WSDL document's URL, 10.0.2.2 for android platform on the local PC 's localhost alias
/ / String serviceUrl = "http://10.168.13.251:8080/axis2/services/glService?wsdl";
/ / String serviceUrl = "http://10.0.2.2:8080/axis2/services/glService?wsdl";
/ / BookService是. arr file name
String serviceUrl = "http://10.0.2.2:8080/axis2/services/glService?wsdl";
/ / define the name of the method to call web service
String methodName = "getBook";
/ / Create SoapObject objects
SoapObject request = new SoapObject ("http://service", methodName);
request.addProperty ("bookName", etBook.getText (). toString ());
System.out.println ("----------------------- 1");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11);
System.out.println ("----------------------- 2");
envelope.bodyOut = request;
HttpTransportSE ht = new HttpTransportSE (serviceUrl);
try {
ht.call (null, envelope);
if (envelope.getResponse ()! = null)
{
SoapObject soapObject = (SoapObject) envelope.getResponse ();
System.out.println ("----------------------- 3");
String result = " Title :" + soapObject.getProperty ("name") + "\ n";
result + = " Author :" + soapObject.getProperty ("editor") + "\ n";
result + = " Price :" + soapObject.getProperty ("price");
/ / WebService returned results will be displayed in the TextView
tvResult.setText (result);
System.out.println ("----------------------- 4");
}
else
{
tvResult.setText (" None of that book ." ) ;
System.out.println ("----------------------- 5");
}

} catch (Exception e) {
e.printStackTrace ();
/ / TODO: handle exception
System.out.println ("----------------------- 6");
}

}
}

没有评论:

发表评论