0

大家好,我搜索了大约两天的问题,但我没有找到任何可以解决的问题。

public class DiplomatikiActivity extends Activity {


private String METHOD_NAME = "authenticate"; // our webservice method name
 private String NAMESPACE = "http://dbsample"; // Here package name in webservice with reverse order.
private String SOAP_ACTION = NAMESPACE + METHOD_NAME; // NAMESPACE + method name
private final String URL="http://xxx.xx.xxx.xxxx:8080//axis2/services/dbservice?wsdl";


 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);
    un=(EditText)findViewById(R.id.et_un);
    pw=(EditText)findViewById(R.id.et_pw);
    ok=(Button)findViewById(R.id.btn_login);
    error=(TextView)findViewById(R.id.tv_error);




new Thread(authenticate).start();

    }
});

 }




Thread authenticate = new Thread() {

 public void run() {


 try {


final ConnectivityManager conMgr =  (ConnectivityManager)         getSystemService(Context.CONNECTIVITY_SERVICE);
 final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();

 if (activeNetwork != null && activeNetwork.getState() == NetworkInfo.State.CONNECTED)  {
 try {

 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
 request.addProperty("name", un.getText().toString());
 request.addProperty("password", pw.getText().toString());

 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
 SoapEnvelope.VER11);
 envelope.dotNet = true;
 envelope.setOutputSoapObject(request);
 HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);    androidHttpTransport.call(SOAP_ACTION, envelope);
 Object result = envelope.getResponse();


.....

......



};

};                       

这是我的代码的一般模式。当 URL 采用这种形式时,私有最终字符串 URL="http://xxx.xx.xxx.xxx:8080//axis2/services/dbservice?wsdl"; 一切正常,webservice 运行,但是当我使用来自 no-ip 的 dns 并且 url 是 private static final String URL = "http://myname1985.zapto.org/axis2/services/dbservice?wsdl"; 它给了我一个错误。在这里我不得不说,当我在浏览器中运行 Web 服务时,上述两种形式都可以正常工作。第二种形式在我的 ip 中映射我的端口 (http://myname1985.zapto.org--->http://xxx.xx.xxx.xxx:8080)。

错误日志

07-27 13:45:51.460: W/System.err(599): org.xmlpull.v1.XmlPullParserException: expected: START_TAG     {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <    {http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='http://dbsample'>@2:507 in     java.io.InputStreamReader@412b3f00) 
07-27 13:45:51.490: W/System.err(599):  at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
07-27 13:45:51.490: W/System.err(599):  at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
07-27 13:45:51.530: W/System.err(599):  at org.ksoap2.transport.Transport.parseResponse    (Transport.java:63)
07-27 13:45:51.530: W/System.err(599):  at org.ksoap2.transport.HttpTransportSE.call    (HttpTransportSE.java:100)
07-27 13:45:51.550: W/System.err(599):  at com.woodripp3r.diplomatiki.DiplomatikiActivity$1.run    (DiplomatikiActivity.java:617)//points to androidHttpTransport.call(SOAP_ACTION, envelope);
07-27 13:45:51.550: W/System.err(599):  at java.lang.Thread.run(Thread.java:856)
07-27 13:45:51.570: W/System.err(599): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the     original thread that created a view hierarchy can touch its views.
07-27 13:45:51.640: W/System.err(599):  at android.view.ViewRootImpl.checkThread    (ViewRootImpl.java:4039)
07-27 13:45:51.640: W/System.err(599):  at android.view.ViewRootImpl.invalidateChild    (ViewRootImpl.java:722)
07-27 13:45:51.640: W/System.err(599):  at android.view.ViewRootImpl.invalidateChildInParent    (ViewRootImpl.java:771)
07-27 13:45:51.701: W/System.err(599):  at android.view.ViewGroup.invalidateChild(ViewGroup.java:4005)
07-27 13:45:51.701: W/System.err(599):  at android.view.View.invalidate(View.java:8576)
07-27 13:45:51.710: W/System.err(599):  at android.view.View.invalidate(View.java:8527)
07-27 13:45:51.710: W/System.err(599):  at android.widget.TextView.checkForRelayout(TextView.java:6752)
07-27 13:45:51.710: W/System.err(599):  at android.widget.TextView.setText(TextView.java:3306)
07-27 13:45:51.710: W/System.err(599):  at android.widget.TextView.setText(TextView.java:3162)
07-27 13:45:51.730: W/System.err(599):  at android.widget.TextView.setText(TextView.java:3137)
07-27 13:45:51.730: W/System.err(599):  at com.woodripp3r.diplomatiki.DiplomatikiActivity$1.run    (DiplomatikiActivity.java:930)
07-27 13:45:51.770: W/System.err(599):  at java.lang.Thread.run(Thread.java:856)

请大家帮助我,我不知道该怎么做才能解决我的问题

4

2 回答 2

0

answear 在 no-ip 中是 tha 我使用端口重定向,现在我更改为 DNS Host(A) 并在我的 url 中添加:8080

私有静态最终字符串 URL = "http://myname1985.zapto.org:8080/axis2/services/dbservice?wsdl";

于 2012-07-27T13:13:51.753 回答
0

在 DiplomatikiActivity.java:930 您访问视图,但线程未在 UI 线程中运行,因此抛出异常,请阅读指南

于 2012-07-27T11:25:26.483 回答