发布XML请求和XML响应Volley库

编程入门 行业动态 更新时间:2024-10-24 06:30:18
本文介绍了发布XML请求和XML响应Volley库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经集成了与JSON配合良好的排球库.现在,我正在尝试访问WCF SOAP,但我不知道如何将XML字符串作为请求传递,以及如何将XML字符串作为响应传递.

I have already integrated volley library working good with JSON. Now am trying to access WCF SOAP I do not know how to pass XML string as request and how to get XML string as response.

推荐答案

// Tag used to cancel the request String tag_string_req = "string_req"; //String url = "URL......"; final ProgressDialog pDialog = new ProgressDialog(this); pDialog.setMessage("Loading..."); pDialog.show(); StringRequest strReq = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d(TAG, response.toString()); pDialog.hide(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { VolleyLog.d(TAG, "Error: " + error.getMessage()); pDialog.hide(); } }){ @Override public String getBodyContentType() { return "application/xml; charset=" + getParamsEncoding(); } @Override public byte[] getBody() throws AuthFailureError { String postData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<sampletag>\n" + "\t<sampletag>data</sampletag>\n" + "</sampletag>"; // TODO get your final output try { return postData == null ? null : postData.getBytes(getParamsEncoding()); } catch (UnsupportedEncodingException uee) { // TODO consider if some other action should be taken return null; } } };

//将请求添加到请求队列 AppController.getInstance().addToRequestQueue(strReq,tag_string_req);

// Adding request to request queue AppController.getInstance().addToRequestQueue(strReq, tag_string_req);

更多推荐

发布XML请求和XML响应Volley库

本文发布于:2023-10-12 16:46:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:XML   Volley

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!