mardi 21 février 2017

Soap web service through the error(SoapFault - faultcode: 'a:InternalServiceFault')

please help me to resolve the error.

public static HashMap<String, Object> callSOAPServer(StringBuffer soap /* YOUR XML GOES HERE*/,String action) {
    int count,size;
    int total=0;

    HashMap<String, Object> xMap = new HashMap<String, Object>();
    byte[] result = null;
    byte[] data = new byte[1024*1024];
    HttpClient httpclient = new DefaultHttpClient(); /* Your probably need to edit client for your needs, like timeout, scheme, etc */
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    DataInputStream is = null;
    boolean download = true;
   // HttpPost httppost = new HttpPost(/* YOUR URL GOES HERE */ );
    HttpPost httppost = new HttpPost("http://ift.tt/2m7ygcS");
    //httppost.setHeader("soapaction", action);
    httppost.setHeader("Content-Type", "text/xml; charset=utf-8");
    try {
        HttpEntity entity = new StringEntity(soap.toString(), HTTP.UTF_8);
        httppost.setEntity(entity);
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity r_entity = response.getEntity();
        if (r_entity != null) {
            result = new byte[(int) r_entity.getContentLength()];
            size = result.length;
            if (r_entity.isStreaming()) {
                is = new DataInputStream(r_entity.getContent());
                while((count = is.read(data, 0, data.length)) != -1) {
                    buffer.write(data, 0, count);
                    total +=count;
                }
            }
            buffer.flush();
            result = buffer.toByteArray();
            data = null;
            buffer = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
        result = null;
    }
    if(result !=null){
        try {
            String sb;
            String sn;
            sb = new String(result, "UTF-8");
            sn = sb.replace("&amp;", "AMP"); //Precaution for SAX parser
            result = sn.getBytes();
            Log.d("",result.toString());
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        xMap.put("STATUS", "OK");
        xMap.put("SOAP", result);
    }else{
        if(xMap.get("STATUS") == null) {
            xMap.put("STATUS", "ERROR");
        }
    }
    httpclient.getConnectionManager().shutdown();
    return xMap;
    // List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    //nameValuePairs.add(new BasicNameValuePair("Username", "Hari"));
    //nameValuePairs.add(new BasicNameValuePair("Password", "Hh123456"));
    // nameValuePairs.add(new BasicNameValuePair("soap.toString()", HTTP.UTF_8));
    //httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
}

Soap web service through the error(SoapFault - faultcode: 'a:InternalServiceFault')

Aucun commentaire:

Enregistrer un commentaire