Bonjour à tous,

Je fais face à un problème que je ne comprends pas très bien. Je souhaite accéder à un Web Service nommé RP programmé en .NET (et déployé sur serveur IIS 7.5 sur Windows 2008 Server). Le service est protégé par une authentification HTTP, non seulement pour appeler le service mais également pour récupérer le WSDL.

Mon client d'appel avait été fait sans authentification dans un premier temps, j'obtenais donc naturellement une erreur 401 tout en bas de ma trace d'erreur lorsque je tentais d'instancier mon service (les stubs sont créés de manière classiques par WSIMPORT).

Voici le code qui établit la connexion :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
      String name = this.properties.getProperty(ENDPOINT_NAME);
 
      URL url = (URL) this.properties.get(ENDPOINT_SERVICE_WSDL);
      QName serviceName = new QName(this.properties.getProperty(ENDPOINT_QNAME), name);
 
      if (LOG.isInfoEnabled()) {
        LOG.info("Attempting to instantiate Service(" + url + ", " + serviceName + ")");
      }
 
      Authenticator.setDefault(new Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication("######", "######".toCharArray());
        }
      });
 
      ServiceRP rp = new ServiceRP(url, serviceName);
      this.rpService = rp.getRpsBinding();
 
      BindingProvider bp = (BindingProvider) this.rpService;
      Map<String, Object> requestContext = bp.getRequestContext();
      requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.properties.get(ENDPOINT_SERVICE));
      requestContext.put(BindingProvider.USERNAME_PROPERTY, "######");
      requestContext.put(BindingProvider.PASSWORD_PROPERTY, "######");
Le champ properties contient les différentes adresses, namespace et autres informations nécessaires pour instancier le service.

Mon code vient de cette page : http://etfdevlab.blogspot.com/2009/1...th-jax-ws.html

J'ai réglé mon problème d'erreur 401 d'accès. Par contre, j'ai une nouvelle erreur dont voici le stack :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at ch.transformation.common.rps.dao.RpDAOImpl.getRpWsAdapter(RpDAOImpl.java:144)
	... 109 more
Caused by: javax.xml.ws.WebServiceException: Failed to access the WSDL at: #######. It failed with: 
	Server redirected too many  times (20).
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
	at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:264)
	at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:227)
	at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:175)
	at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
	at javax.xml.ws.Service.<init>(Service.java:56)
	at ch.transformation.common.rpsclient.ServiceRP.<init>(ServiceRP.java:50)
	at ch.transformation.common.rps.ws.RpServiceLocator.getRpService(RpServiceLocator.java:100)
	at ch.transformation.common.rps.ws.RpWsAdapterImpl.<init>(RpWsAdapterImpl.java:48)
	... 114 more
Caused by: java.net.ProtocolException: Server redirected too many  times (20)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1451)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
	at java.net.URL.openStream(URL.java:1010)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:805)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:262)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:129)
	... 122 more
Merci d'avance de vos suggestions, je sèche complètement...

Meilleures salutations !