如何在android webservices中获取特定的SOAP对象结果排序? [英] How to get the perticular SOAP object result sorting in android webservices?

查看:57
本文介绍了如何在android webservices中获取特定的SOAP对象结果排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai guys,



我想要你们的帮助,



我得到了在服务器中使用android和SOAP中的Web服务的结果,但问题是我收到的结果却没有以正确的方式我希望将textcloumn数据输入到textView.Like中:BuSnumber-210,Source-xyz ,Destination-vbk喜欢这个如何在android中执行此操作???我已粘贴下面的代码...

package com.example.newr;



import java.sql.Array;

import java.util.Arrays;



import org.ksoap2.SoapEnvelope;

import org.ksoap2.serialization.PropertyInfo;

import org.ksoap2.serialization.SoapObject;

import org.ksoap2.serialization.SoapSerializationEnvelope ;

import org.ksoap2.transport.HttpTransportSE;



import android.os.Bundle;

import android.os.StrictMode;

import android.support.v7.app.ActionBarActivity;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android。 widget.ArrayAdapter;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;



公共类MainActivity扩展ActionBarActivity {

EditText数字;​​

Button bn;

TextView源,目标,通过;

String displayText;

String studentNo;

String str2array;

ArrayAdapter< ;串GT; list;



//私有静态字符串结果;

//私有字符串TAG =PGGURU;



private final String NAMESPACE =http://tempuri.org/;

private final String METHOD_NAME =Search_BusDetails;

private final String SOAP_ACTION =http://tempuri.org/Search_BusDetails\";// http:// localhost:55134 / WebSite2 / Service.asmx / findContact

private final String URL =http: //10.0.2.2:55129/WebSite1/Service.asmx;



//私有字符串ReadNumber;



@Override

protected void onCreate(Bundle savedInstanceState){

// TODO自动生成的方法存根

super.onCreate(savedInstanceState) );

setContentView(R.layout.activity_main);

if(android.os.Build.VERSION.SDK_INT> 9){

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()

.permitAll()。build();

StrictMode。 setThreadPolicy(policy);

}



Number =(EditText)findViewById(R.id.BusNumber);

source =(TextView)findViewById(R.id.Source);

destination =(TextView)findViewById(R.id.Destination);

via =(TextView )findViewById(R.id.via);



bn =(Button)findViewById(R.id.Search);

bn。 setOnClickListener(new OnClickListener(){

@Override

public void onClick(View v){

call(studentNo);

studentNo = Number.getText()。toString();

/ *

* AsynchCall text = new AsynchCall(); text.execute();

* /

}

});

}



public void call(String studentNo){



try {

SoapObject request = new SoapObject (NAMESPACE,METHOD_NAME);

PropertyInfo propertyInfo = new PropertyInfo();

propertyInfo.type = PropertyInfo.STRING_CLASS;

propertyInfo.name = eid;



request.addProperty(propertyInfo,studentNo);



SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (

SoapEnvelope.VER11);

envelope.dotNet = true;



envelope.setOutputSoapObject(request) ;



HttpTransportSE httpTransport = new HttpTransportSE(URL);

try {

httpTransport.call(SOAP_ACTION,信封);

// SoapObject response =(SoapObject)envelope.getResponse();

// String source1 =

// response.getProperty(getAlertsResult)。toString();

对象响应= envelope.getResult();



< br $> b $ b



} catch(Exception ex){

Log.i(ex.toString(),thevalue );

via.setText(ex.toString()

+或输入数字不可用!);

}

} catch(Exception ex){

ex.printStackTrace();

}

}

/ *

*私有类AsynchCall扩展了AsyncTask< string,> {

*

* @Override protected Void doInBackground(String ... params){// TODO

*自动生成方法存根

*

*返回null; }

*

* @Override protected void onPostExecute(Void result){

* nr.setText(displayText); super.onPostExecute(结果); }

*

*

*}

* /



}

Hai guys,

I want one help from you guys,

I am getting the result that are in the server using the web service in android and SOAP but the problem is that am receive the result but not in an proper manner i want the perticular coloumn data in to the textView.Like this:BuSnumber-210,Source-xyz,Destination-vbk like this how to do this in android???I have pasted my codes below...
package com.example.newr;

import java.sql.Array;
import java.util.Arrays;

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

import android.os.Bundle;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {
EditText Number;
Button bn;
TextView source, destination, via;
String displayText;
String studentNo;
String str2array;
ArrayAdapter<string> list;

// private static String Result;
// private String TAG = "PGGURU";

private final String NAMESPACE = "http://tempuri.org/";
private final String METHOD_NAME = "Search_BusDetails";
private final String SOAP_ACTION = "http://tempuri.org/Search_BusDetails";// http://localhost:55134/WebSite2/Service.asmx/findContact
private final String URL = "http://10.0.2.2:55129/WebSite1/Service.asmx";

// private String ReadNumber;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}

Number = (EditText) findViewById(R.id.BusNumber);
source = (TextView) findViewById(R.id.Source);
destination = (TextView) findViewById(R.id.Destination);
via = (TextView) findViewById(R.id.via);

bn = (Button) findViewById(R.id.Search);
bn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
call(studentNo);
studentNo = Number.getText().toString();
/*
* AsynchCall text=new AsynchCall(); text.execute();
*/
}
});
}

public void call(String studentNo) {

try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propertyInfo = new PropertyInfo();
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "eid";

request.addProperty(propertyInfo, studentNo);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(URL);
try {
httpTransport.call(SOAP_ACTION, envelope);
// SoapObject response = (SoapObject)envelope.getResponse();
// String source1=
// response.getProperty("getAlertsResult").toString();
Object response = envelope.getResult();




} catch (Exception ex) {
Log.i(ex.toString(), "thevalue");
via.setText(ex.toString()
+ " Or enter number is not Available!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
/*
* private class AsynchCall extends AsyncTask<string,> {
*
* @Override protected Void doInBackground(String... params) { // TODO
* Auto-generated method stub
*
* return null; }
*
* @Override protected void onPostExecute(Void result) {
* nr.setText(displayText); super.onPostExecute(result); }
*
*
* }
*/

}

推荐答案

这篇关于如何在android webservices中获取特定的SOAP对象结果排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆