This application is mainly to use Http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx's number attribution to WebService to achieve the attribution of the query:
<?XML version= "1.0" encoding= "Utf-8"?> <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:paddingtop= "5dip"Android:paddingleft= "5dip"Android:paddingright= "5dip" > <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:text= "Please enter the phone number to be queried:" /> <EditTextAndroid:id= "@+id/phone_sec"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:inputtype= "Textphonetic"Android:singleline= "true"Android:hint= "For example: 1398547" /> <ButtonAndroid:id= "@+id/query_btn"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_gravity= "Right"Android:text= "Query" /> <TextViewAndroid:id= "@+id/result_text"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_gravity= "Center_horizontal|center_vertical" /> </LinearLayout>
CODE:
Here the face of simple edittext input check does not do, in addition here need to figure out namespace, methodname,asmx,action variable, in http://webservice.webxml.com.cn/ Webservices/mobilecodews.asmx? In the WSDL description document, it is clear that the ASMX is the WSDL document to remove the following parameters, in practice, found on the band can also request to the data. The action is the namespace plus the method name.
/*** Mobile phone number section attribution to search * *@paramphonesec Mobile phone number segment*/ Public voidGetremoteinfo (String phonesec) {//name SpaceString nameSpace = "http://WebXml.com.cn/"; //called method nameString methodName = "Getmobilecodeinfo"; //asmxString asmx = "Http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx"; //SOAP ActionString soapaction = "Http://WebXml.com.cn/getMobileCodeInfo"; //specifies the namespace of the WebService and the method name of the callSoapobject sobj =NewSoapobject (NameSpace, methodName); //set the two parameters that need to be passed in to call the WebService interface Mobilecode, UserIdSobj.addproperty ("Mobilecode", phonesec); Sobj.addproperty ("UserId", "" "); //generates SOAP request information that calls the WebService method and specifies the version of SoapSoapserializationenvelope envelope =NewSoapserializationenvelope (SOAPENVELOPE.VER10); Envelope.bodyout=Sobj; //sets whether to invoke the dotnet developed WebServiceEnvelope.dotnet =true; //equivalent to envelope.bodyout = RPC; Envelope.setoutputsoapobject (sobj); Httptransportse Transport=NewHttptransportse (ASMX); Try { //Call WebServiceTransport.call (soapaction, envelope); } Catch(Exception e) {e.printstacktrace (); } //get the returned dataSoapobject object = (soapobject) envelope.bodyin/ *. GetResponse ()* /; //gets the returned resultString result = Object.getproperty ("Getmobilecodeinforesult"/ *0* /). toString (); //Displays the results returned by WebService in TextViewResultview.settext (Result); }
There are two ways to see that you can get objects and get results. Are the methods provided in SAOP.
If there are multiple values in the retrieved data, you can get the number of results by Result.getpropertycount ()
At some point, some inexplicable exceptions may be reported, try to modify the SOPA version, or set the action to null (some do not need action)
Permissions:
Last thing: Don't forget to add permission
<android:name= "Android.permission.INTERNET"/>