[英]Get Empty response with Passing Arraylist to SOAP service in android
你好朋友我將arraylist中的緯度和經度值傳遞給Android中的肥皂網絡服務是我的代碼
演示Java
public class Demo extends Activity
{ ArrayList<ParserLatLong>mArrayListParserLatLongs;
ProgressDialog mProgressDialog;
public final String NAMESPACE = "***";
public final String URL = *****";
FrameLayout fram_map;
public final String SOAP_ACTION_9 = "****";
public final String METHOD_NAME_9 = "*****";
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setcontentView(R.layout.main);
fram_map = (FrameLayout) view.findViewById(R.id.fram_map);
mArrayListParserLatLongs=new ArrayList<ParserLatLong>();
fram_map.setOnTouchListener(new View.OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
float x = event.getX();
float y = event.getY();
int x_co = Math.round(x);
int y_co = Math.round(y);
projection = mMap.getProjection();
Point x_y_points = new Point(x_co, y_co);
LatLng latLng = mMap.getProjection().fromScreenLocation(x_y_points);
int eventaction = event.getAction();
if (MotionEvent.ACTION_DOWN == eventaction)
{
// finger touches the screen
if (Is_MAP_Moveable == false & val.size() != 0)
{
val.clear();
polygon.remove();
}
}
else if (MotionEvent.ACTION_MOVE == eventaction)
{
// finger moves on the screen
if (Is_MAP_Moveable == false)
{
System.out
.println("Lat "+latLng.latitude +"Lng "+latLng.longitude);
ParserLatLong mLatLong=new ParserLatLong();
mLatLong.setLat(String.valueOf(latLng.latitude));
mLatLong.setLng(String.valueOf(latLng.longitude));
mArrayListParserLatLongs.add(mLatLong);
val.add(new LatLng(latLng.latitude, latLng.longitude));
}
}
else if (MotionEvent.ACTION_UP == eventaction)
{
if (Is_MAP_Moveable == false && val.size() > 0)
{
rectOptions = new PolygonOptions();
rectOptions.addAll(val);
rectOptions.strokeColor(Color.BLUE);
rectOptions.strokeWidth(2);
rectOptions.fillColor(Color.CYAN);
polygon = mMap.addPolygon(rectOptions);
new FetchPolygondata().execute();
}
}
if (Is_MAP_Moveable == true)
{
return false;
} else
{
return true;
}
}
});
}
public class FetchPolygondata extends AsyncTask<Void, Void, Void>
{
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
mProgressDialog=ProgressDialog.show(getActivity(), "Wait", "Loading ");
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
if (mAllMethods.check_Internet()==true) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_9);
for (int i = 0; i < mArrayListParserLatLongs.size(); i++) {
System.out.println(" LT : "+mArrayListParserLatLongs.get(i).getLat() +" LN : "+mArrayListParserLatLongs.get(i).getLng());
request.addProperty("alPolygon",mArrayListParserLatLongs.get(i).getLat()+","+mArrayListParserLatLongs.get(i).getLng());
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);
try {
androidHttpTransport.call(SOAP_ACTION_9, envelope);
SoapObject mSoapObjectCompanyDetailResponse = (SoapObject)envelope.bodyIn;
Object re= null;
re = envelope.getResponse();
System.out.println("Response "+re.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
else {
mProgressDialog.dismiss();
mAllMethods.ShowDialog(getActivity(), "Validate", "Network not Available");
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (mProgressDialog!=null) {
mProgressDialog.dismiss();
}
}
}
}
**我的SOAP Web服務頁面如下所示**
當我在上面的代碼上運行時,它將給我空的響應,意味着沒有價值,所以我知道如何解決這個問題?
請僅檢查一個latitude-longitude
而不是全部latitude-longitude
。 並檢查響應是否not null
?
問題是latitude-longitude
為null
或""
。 因此,響應不正確。
請僅檢查一個latitude-longitude
輸出。您也可以嘗試輸入靜態值。
希望它能解決您的問題。
將HttpTransportSE的調試標志設置為true,並在Logcat中打印出SOAP服務調用的請求和響應轉儲。 然后將Logcat requestdump與類似SoapUI的軟件一起使用,以檢查從服務接收到的實際請求和響應。
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION_9, envelope);
Log.d("HTTP REQUEST ",androidHttpTransport.requestDump);
Log.d("HTTP RESPONSE", androidHttpTransport.responseDump);
....
} catch (Exception e) {
e.printStackTrace();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.