Trouble you send a little bit of time to help me see why that can not afford to connect it!
package com.example.getservice;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
/ / Namespace
String nameSpace = "http://WebXml.com.cn/";
/ / Method name
callString methodName = "getMobileCodeInfo";
/ / EndPoint
String endPoint = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
/ / SOAP Action
String soapAction = "http://WebXml.com.cn/getMobileCodeInfo";
/ / Specify WebService namespace and method name to call
SoapObject rpc = new SoapObject (nameSpace, methodName);
/ / Set the required incoming call WebService interface requires two parameters mobileCode, userId
rpc.addProperty ("mobileCode", "13154668959");
rpc.addProperty ("userId", "");
/ / Generate method call WebService SOAP request message, and specify the version of SOAP
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11);
envelope.bodyOut = rpc;
/ / Set whether the call is
dotNet developmentenvelope.dotNet = true;
/ / Equivalent to envelope.bodyOut = rpc;
envelope.setOutputSoapObject (rpc);
HttpTransportSE transport = new HttpTransportSE (endPoint);
try {
/ / Call WebService
transport.call (soapAction, envelope);
} Catch (Exception e) {
e.printStackTrace ();
}
/ / Get the returned data
SoapObject object = (SoapObject) envelope.bodyIn;
/ / Get the results returned
String result = object.getProperty ("getMobileCodeInfoResult") toString ();.
TextView textView = (TextView) findViewById (R.id.text1);
/ / TextView.setText (result);
textView.setText (getlogindata ());
}
static final String SERVICE_NS = "http://WebXml.com.cn/";
static final String SERVICE_URL = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
/ / Accept the landing feedback data
public String getlogindata () {
final String methedName = "getMobileCodeInfo";
SoapObject soapObject = new SoapObject (SERVICE_NS, methedName);
soapObject.addProperty ("mobileCode", "13154668959");
soapObject.addProperty ("userId", "");
final HttpTransportSE ht = new HttpTransportSE (SERVICE_URL);
ht.debug = true;
final SoapSerializationEnvelope enveloper = new SoapSerializationEnvelope (SoapEnvelope.VER11);
enveloper.dotNet = true;
enveloper.bodyOut = soapObject;
FutureTask
@ Override
public SoapObject call () throws Exception {
ht.call (null, enveloper);
if (enveloper.getResponse ()! = null) {
/ / SoapObject result = (SoapObject) enveloper.getResponse ();
SoapObject result = (SoapObject) enveloper.bodyIn;
return result;
}
return null;
}
});
. new Thread (task) start ();
try {
String string = (String) task.get () getProperty ("getMobileCodeInfoResult");.
return string;
} Catch (Exception e) {
e.printStackTrace ();
}
return "0";
}
@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.activity_main, menu);.
return true;
}
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
trouble you to solve ah!
No comments:
Post a Comment