WebService İstemcisi üzerinde çalışıyorum ve WebService Çağrısı için bir Zaman Aşımı ayarlamak istiyorum. Farklı yaklaşımları denedim ama yine de bunu başaramıyorum. WSDL'den kod oluşturma için JAX-WS kullanıyorum. JBoss-eap-5.1'i Uygulama Sunucusu ve JDK1.6.0_27 olarak kullanıyorum. Zaman aşımı için bu farklı yaklaşımları buldum ama hiçbiri benim için çalışmıyor. Şimdi ben ne yaptım İçin JAX-WS WebService Çağrısı için Zaman Aşımı Nasıl Ayarlanır
URL mbr_service_url = new URL(null,GlobalVars.MemberService_WSDL, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL url) throws IOException {
URL clone_url = new URL(url.toString());
HttpURLConnection clone_urlconnection = (HttpURLConnection) clone_url.openConnection();
// TimeOut settings
clone_urlconnection.setConnectTimeout(10000);
clone_urlconnection.setReadTimeout(10000);
return (clone_urlconnection);
}
});
MemberService service = new MemberService(mbr_service_url);
MemberPortType soap = service.getMemberPort();
ObjectFactory factory = new ObjectFactory();
MemberEligibilityWithEnrollmentSourceRequest request = factory.createMemberEligibilityWithEnrollmentSourceRequest();
request.setMemberId(GlobalVars.MemberId);
request.setEligibilityDate(value);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.ws.client.BindingProviderProperties.REQUEST_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.ws.client.BindingProviderProperties.CONNECT_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.internal.ws.client.BindingProviderProperties.REQUEST_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.internal.ws.client.BindingProviderProperties.CONNECT_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.ws.developer.JAXWSProperties.REQUEST_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.ws.developer.JAXWSProperties.CONNECT_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.internal.ws.developer.JAXWSProperties.REQUEST_TIMEOUT, 10000);
((BindingProvider) soap).getRequestContext().put(com.sun.xml.internal.ws.developer.JAXWSProperties.CONNECT_TIMEOUT, 10000);
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
MemberEligibilityWithEnrollmentSourceResponse response = soap.getMemberEligibilityWithEnrollmentSource(request);
logger.log("Call to member service finished.");
, ben bir vasiyet içinden benim webservice yöntemi çağrıda edilir. Onun iyi bir yaklaşım olmadığını biliyorum, ama benim için çalışıyor. Çocuklar lütfen bunu doğru bir şekilde yapmam için bana yardım edin.
javax.xml.ws.client.connectionTimeout
javax.xml.ws.client.receiveTimeout
:
logger.log("Parameters set for createorUpdateContact call.\nGoing in Executor Service.");
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
response = soap.getMemberEligibilityWithEnrollmentSource(request);
} catch (MemberServiceException ex) {
logger.log("Exception in call to WebService", ex.fillInStackTrace());
}
}
});
executorService.shutdown();
try {
executorService.awaitTermination(GlobalVars.WSCallTimeOut, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
logger.log("Thread Interrupted!", ex);
executorService.shutdownNow();
}
StubExt.PROPERTY_CLIENT_TIMEOUT benim için çalıştı, ancak istisna içindir sonra '3 * timeoutMillisecond' atılır com.sun.xml.internal.ws.developer.JAXWSProperties yukarıdaki alanların
Değerler Örnek: Eğer 9000 milisaniye sonra istisna haricinde timeoutMillisecond = 3000' ise, ancak 'Timeout: 3000ms' günlük dosyasına yazılır – mariami
Teşekkürler @mariami Benim için çalıştı. Ve istisna 3 * timeoutMillisecond sonra değil, uygun zamanda atılıyor. Çalışmak için olsa da jax ile ilgili jboss lib gelen bazı kavanoz kaldırmak zorunda kaldı aksi halde NoClassDefFoundError: javax/xml/ws/spi/Provider21 veriyordu. –