package com.github.wmixvideo.correios;

import br.com.correios.webservice.rastro.Rastro;
import br.com.correios.webservice.rastro.Service;
import br.com.correios.webservice.rastro.Sroxml;

import javax.xml.ws.BindingProvider;
import java.util.Collection;
import java.util.Map;

public class WSCorreiosRastreador {

    private static final String TIPO = "L";//todos
    private static final String RESULTADO = "T";//todos
    private static final String LINGUA = "101";//portugues

    private final Service service;
    private final String usuario;
    private final String senha;

    public WSCorreiosRastreador(final String usuario, final String senha) {
        this.service = new Rastro().getServicePort();
        this.usuario = usuario;
        this.senha = senha;
    }

    public WSCorreiosRastreador setTimeout(final int milliseconds) {
        final Map<String, Object> requestContext = ((BindingProvider) this.service).getRequestContext();
        requestContext.put("com.sun.xml.internal.ws.connect.timeout", milliseconds);
        requestContext.put("com.sun.xml.internal.ws.request.timeout", milliseconds);
        return this;
    }

    public Sroxml consultaObjeto(final String objeto) {
        return this.service.buscaEventos(this.usuario, this.senha, TIPO, RESULTADO, LINGUA, objeto);
    }

    public Sroxml consultaObjetos(final Collection<String> objetos) {
        return this.service.buscaEventos(this.usuario, this.senha, TIPO, RESULTADO, LINGUA, String.join("", objetos));
    }
}

@@ -33,16 +33,146 @@
 reios;%0A%0A
+import br.com.correios.webservice.calculador.CalcPrecoPrazoWS;%0Aimport br.com.correios.webservice.calculador.CalcPrecoPrazoWSSoap;%0A
 import b
@@ -617,22 +617,16 @@
 private 
-final 
 Service 
@@ -699,16 +699,61 @@
 g senha;
+%0A    private int timeoutMilliseconds = 15000;
 %0A%0A    pu
@@ -850,36 +850,11 @@
  = n
-ew Rastro().getServicePort()
+ull
 ;%0A  
@@ -983,24 +983,350 @@
 iseconds) %7B%0A
+        this.timeoutMilliseconds = milliseconds;%0A        return this;%0A    %7D%0A%0A    private Service getService() %7B%0A        System.setProperty(%22sun.net.client.defaultConnectTimeout%22, String.valueOf(this.timeoutMilliseconds));%0A        if (this.service == null) %7B%0A            this.service = new Rastro().getServicePort();%0A        %7D%0A
         fina
@@ -1480,33 +1480,40 @@
 nnect.timeout%22, 
-m
+timeoutM
 illiseconds);%0A  
@@ -1580,17 +1580,24 @@
 meout%22, 
-m
+timeoutM
 illiseco
@@ -1613,32 +1613,40 @@
      return this
+.service
 ;%0A    %7D%0A%0A    pub
@@ -1706,39 +1706,44 @@
     return this.
-s
+getS
 ervice
+()
 .buscaEventos(th
@@ -1897,23 +1897,28 @@
 rn this.
-s
+getS
 ervice
+()
 .buscaEv

Ajuste tratamento timeout construtor webservice rastreamento