'Unable to Capture Fingerprint using morpho fingerprint scanner device in android application

Device detail:

Morpho fingerprint scanner device

Method

Type : CAPTURE

URL : http://127.0.0.1:11100/capture

Headers

content-type : text/xml Accept : text/xml

Body

Response in Advanced RestClient:

ISSUE

When I am using this above API request in Advanced RestClient then I am getting the response shown above but when trying to achieve this by using OkHttpClient library in the android application but getting the following error:

Here is the code spinnet using OkHttpClient:

private void captureRdRequest(final String pidOpt, final String reqUrl) {

    String pidOpt = "<PidOptions ver=\"1.0\"><Opts fCount=\"1\" fType=\"0\" iCount=\"\" iType=\"\" pCount=\"\" pType=\"\" format=\"1\" pidVer=\"2.0\" timeout=\"10000\" otp=\"\" wadh=\"$WADH\" posh=\"\"/></PidOptions>";
    String url = "http://127.0.0.1:42200/capture";

    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            try  {

                OkHttpClient client = new OkHttpClient().newBuilder()
                        .build();
                MediaType mediaType = MediaType.parse("text/xml");
                RequestBody body = RequestBody.create(mediaType, pidOpt);
                okhttp3.Request request = new okhttp3.Request.Builder()
                        .url(url)
                        .method("CAPTURE", body)
                        .addHeader("Content-Type", "text/xml")
                        .addHeader("Accept", "text/xml")
                        .build();
                okhttp3.Response response = client.newCall(request).execute();
                Log.d("sdf", response.toString());

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    thread.start();

}

Error Deatil message :

failed to connect to /127.0.0.1 (port 42200) from /127.0.0.1 (port 42104) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)

REQUIRED SOLUTION:

Please help me with how to capture the fingerprint for the client app ??



Solution 1:[1]

All Capture Ports you will get on 11100 Scan All Ports from 11100 to 11105 on the port when you get reply as device is ready consider this is my port it can be any device

Solution 2:[2]

Please try this, it's working fine for me.

String pidOpt='<PidOptions ver=\"1.0\">'+'<Opts fCount=\"1\" fType=\"0\" iCount=\"0\" iType=\"0\" pCount=\"0\" pType=\"0\" format=\"0\" pidVer=\"2.0\" timeout=\"10000\" otp=\"\" wadh=\"\" posh=\"UNKNOWN\" env=\"PP\"/>'+'</PidOptions>';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Uma Shankar Pandey
Solution 2 Web Developer