0

I'm supposed to consume a customized PeopleSoft SOAP service using Java.

The service is tested on Postman like this

Postman test

and the Okhttp snippet suggested works in Java 8 smoothly.

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/xml");
RequestBody body = RequestBody.create(mediaType, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Some XML>");
Request request = new Request.Builder()
  .url("urlToPeopleSoftService")
  .method("POST", body)
  .addHeader("Content-Type", "application/xml")
  .build();
Response response = client.newCall(request).execute();

The problem is when i use a jdk 7 to execute the project, getting an annoying Exception

Connection reset
java.net.SocketException: Connection reset
Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:196)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
    at sun.security.ssl.InputRecord.read(InputRecord.java:480)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
    at com.squareup.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:192)
    at com.squareup.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149)
    at com.squareup.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
    at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
    at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
    at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
    at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
    at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
    at com.squareup.okhttp.Call.getResponse(Call.java:286)
    at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
    at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
    at com.squareup.okhttp.Call.execute(Call.java:80)
    at de.gov.dee.journal.JournalData.postRequest(JournalData.java:372)
    at de.gov.dee.journal.JournalData.inquiryJournalStatus(JournalData.java:355)
    at de.gov.dee.journal.JournalData.checkJournalStatus(JournalDa
ta.java:131)
    at de.gov.dee.journal.JournalData.main(JournalData.java:516)

I've tried with okhttp 3.9.0 and okhttp 2.7.5 with no luck

<dependency>
    <groupId>com.squareup.okhttp</groupId>
    <artifactId>okhttp</artifactId>
    <version>2.7.5</version>
</dependency>

The bad news is that it MUST be run on Java 7. How can I solve this?

cigien
  • 57,834
  • 11
  • 73
  • 112
  • 1
    Might be duplicate, check this : if you enable Java's SSL debugging (via -Djavax.net.debug=ssl), do you see the SNI (server_name) TLS extension being sent? If not, this similar post might be useful: https://stackoverflow.com/questions/36323704/sni-client-side-mystery-using-java8/36343704#36343704 – Senthil Aug 30 '21 at 01:05
  • Could also be TLS 1.2 requirement. 3.12.13 is the most recent supported version of OkHttp for Java 7. Worth trying that also. – Yuri Schimke Aug 31 '21 at 18:40

0 Answers0