如何使用android中的“volley library”向soap web服务发送请求

时间:2016-07-04 07:19:40

标签: android web-services soap android-volley

我正在尝试使用Volley库与我的Soap Web服务进行通信。     搜索后,我只得到与网址通信的响应,但我没有 知道如何向soap web服务发送请求,其中包含url,Namespace和web 方法名称等,我也必须发送参数请求获得响应, 这里我有一个例子,它只根据网址发送请求

String url = "http://httpbin.org/html";

// Request a string response
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {

        // Result handling 
        System.out.println(response.substring(0,100));

    }
}, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {

        // Error handling
        System.out.println("Something went wrong!");
        error.printStackTrace();

    }
});

// Add the request to the queue
Volley.newRequestQueue(this).add(stringRequest);

目前正在申请肥皂网服务,

public static String invokecreatepostfm(int posttypeid, byte[] picture,byte[] Fullimage,long postedbyid,String postcontent,String langitude,String latitude,String locationname,String webMethName, Context mContext) {           

        // Create request
        SoapObject request = new SoapObject(NAMESPACE, webMethName);
        SOAP_ACTION = NAMESPACE + webMethName;
        // Property which holds input parameters

        request.addProperty("PostTypeID", posttypeid);
        request.addProperty("Picture", org.kobjects.base64.Base64.encode(picture));
        request.addProperty("FullImage", org.kobjects.base64.Base64.encode(Fullimage));
        request.addProperty("PostedByID", postedbyid);
        request.addProperty("PostContent", postcontent);
        request.addProperty("Langitude", langitude);
        request.addProperty("Latitude", latitude);
        request.addProperty("LocationName", locationname);

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

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

            LStatus = response.toString();

        } catch (Exception e) {
                e.printStackTrace();
            LStatus = e.toString();
        }
        //Return booleam to calling object
        return LStatus;
    }

我想使用排球库请求肥皂网服务,但我不知道如何使用排球库请求这种肥皂网服务,任何人都可以帮助我吗?提前感谢。

0 个答案:

没有答案