IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Développement Web en Java Discussion :

Problème de consommation d’un web service SOAP


Sujet :

Développement Web en Java

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Juin 2019
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juin 2019
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Problème de consommation d’un web service SOAP
    Bonjour à tous,

    J'ai pour mission de développer une application web en utilisant JSF2, EJB3 sur un serveur d’application JBOSS7.
    L'application est très simple, cependant je dois consommer un web service développé par d'autres personnes (soap/wsdl).
    A l’aide de SOAPUI, le dit web service fonctionne parfaitement.
    Le problème : lors de l’intégration dans un code Java, le message d’erreur s’affiche :« The server sent HTTP status code 404: null «

    Puis-je avoir vos conseils ?
    Merci


    WSDL: Nom : wsdl.PNG
Affichages : 819
Taille : 69,4 Ko

    Test avec SoapUi: Nom : soupuireponse.PNG
Affichages : 803
Taille : 52,9 Ko

    Remarque: lors de la phase de test avec soapUi, il faut intégrer manuellement l’URL endpoint ainsi la valeur de soapaction.


    Classe : ResponseHeader.java
    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
     
    package com.myproject.site;
     
    public class ResponseHeader {
    	private int code;
    	public ResponseHeader() {
    		super();
    		// TODO Auto-generated constructor stub
    	}
    	public ResponseHeader(int code) {
    		super();
    		this.code = code;
    	}
    	public int getCode() {
    		return code;
    	}
    	public void setCode(int code) {
    		this.code = code;
    	}
    }
    Interface SiteService.java:

    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
     
    package com.myproject.site;
     
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
     
    @WebService(targetNamespace = "http://www.monsite.com/webservices/app-homeSecurityValidation-ws", name = "app-homeSecurityValidation-ws")
    public interface SiteService {
        @WebMethod
        public ResponseHeader HomeSecurityValidationRequest(
            @WebParam(name = "verif", targetNamespace = "")
            java.lang.String verif,
            @WebParam(name = "login", targetNamespace = "")
            java.lang.String account,
            @WebParam(name = "password", targetNamespace = "")
            java.lang.String password
        ) ;    
    }
    La classe main Test.java:

    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
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
     
    package com.myproject.site;
     
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.xml.namespace.QName;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.MimeHeaders;
    import javax.xml.soap.SOAPException;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.ws.BindingProvider;
    import javax.xml.ws.Service;
     
    public class Test {
    public static void main(String[] args) throws SOAPException, IOException {
     
    		try {			
    			String soapEndpointUrl = "http://10.168.12.12:8080/homeSecurityValidation/app-homeSecurityValidation-ws";
    			String soapAction = "homeSecurityValidation";
     
                URL url = new URL("http://10.168.12.12:8080/homeSecurityValidation/app-homeSecurityValidation-ws.wsdl"); 
                QName qName = new QName("http://www.monsite.com/webservices/app-homeSecurityValidation-ws",
                        "app-homeSecurityValidation-ws");
     
                /*********/
                MessageFactory messageFactory = MessageFactory.newInstance();
                SOAPMessage soapMessage = messageFactory.createMessage();
     
     
                MimeHeaders headers = soapMessage.getMimeHeaders();
                headers.addHeader("SOAPAction", soapAction);
                soapMessage.saveChanges();
     
     
                Service service = Service.create(url, qName);         
     
                SiteService hello = (SiteService) service.getPort(SiteService.class);
     
                BindingProvider bp = (BindingProvider) hello;
                bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, soapEndpointUrl);
     
     
     
                ResponseHeader r = hello.HomeSecurityValidationRequest("OK", 
         			   "mylogin",
         			   "mypassword");
     
         		  System.out.println("response: " + r.getCode()); 
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }			
    	}
    }
    Console Eclipse :
    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
     
    Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 404: null
    atcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(HttpTransportPipe.java:296)
    	at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:245)
    	at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:203)
    	at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:122)
    	at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:123)
    	at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:626)
    	at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:585)
    	at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:570)
    	at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:467)
    	at com.sun.xml.internal.ws.client.Stub.process(Stub.java:308)
    	at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:163)
    	at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
    	at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
    	at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
    	at com.sun.proxy.$Proxy10.homeSecurityValidationRequest(Unknown Source)
    	at com.myproject.site.Test.main(Test.java:112)
    Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="Sun Microsystems Inc."

  2. #2
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    241
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Février 2005
    Messages : 241
    Points : 399
    Points
    399
    Par défaut
    Bonjour,

    êtes-vous certain de l'URL d'accès au WSDL?
    on trouve typiquement le wsdl à une URL qui aurait plutôt la forme
    Dans l'attente,
    Sébastien

Discussions similaires

  1. Problème envoi image depuis iPhone vers web service SOAP
    Par grivinia dans le forum Développement iOS
    Réponses: 1
    Dernier message: 06/05/2015, 14h25
  2. Réponses: 2
    Dernier message: 29/04/2012, 00h01
  3. Réponses: 0
    Dernier message: 10/07/2009, 17h08
  4. Consommer un web service SOAP/XML
    Par wifsimster dans le forum XML/XSL et SOAP
    Réponses: 23
    Dernier message: 23/05/2009, 14h38
  5. Réponses: 5
    Dernier message: 15/04/2008, 15h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo