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

Services Web Java Discussion :

Probleme en envoyant un message


Sujet :

Services Web Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Mars 2010
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 19
    Par défaut Probleme en envoyant un message
    Salut, voilà ma classe 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
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    import java.io.File;
    import java.util.Iterator;
    import javax.activation.DataHandler;
    import javax.activation.FileDataSource;
    import javax.xml.soap.AttachmentPart;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.Name;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPException;
    import javax.xml.soap.SOAPFactory;
    import javax.xml.soap.SOAPMessage;
    public class Send {
            private String sendEndpoint = "http://localhost:8080/corvus/httpd/ebms/sender";
            private String nsURI = "http://service.ebms.edi.cecid.hku.hk/";
            private String nsPrefix = "tns";
            private String cpaId = "cpaid";
            private String service = " http://localhost:8080/corvus/httpd/ebms/inbound";
            private String action = "action";
            private String conversationId = "convId";
            private String fromPartyId = "fromPartyId";
            private String fromPartyType = "fromPartyType";
            private String toPartyId = "toPartyId";
            private String toPartyType = "toPartyType";
            private String refToMessageId = "";
            private String serviceType = "";
            public static void main(String[] args) throws Exception {
                    Send send = new Send();
                    send.run();
            }
            public void run() throws Exception {
                    envoie();
            }
            public void envoie () throws Exception {
                    System.out.println("Sending message to Hermes2!!...");
                    SOAPConnection soapConn=SOAPConnectionFactory.newInstance().createConnection();
                    SOAPMessage request =MessageFactory.newInstance().createMessage();
                    SOAPBody soapBody = request.getSOAPBody();
                    soapBody.addChildElement(createElement("cpaId",nsPrefix,nsURI,cpaId));
                    soapBody.addChildElement(createElement("service",nsPrefix,nsURI,service));
                    soapBody.addChildElement(createElement("action",nsPrefix,nsURI,action));
                    soapBody.addChildElement(createElement("convId",nsPrefix,nsURI,conversationId));
    soapBody.addChildElement(createElement("fromPartyId",nsPrefix,nsURI,fromPartyId));
    soapBody.addChildElement(createElement("fromPartyType",nsPrefix,nsURI,fromPartyType));
    soapBody.addChildElement(createElement("toPartyId",nsPrefix,nsURI,toPartyId));
    soapBody.addChildElement(createElement("toPartyType",nsPrefix,nsURI,toPartyType));
    soapBody.addChildElement(createElement("refToMessageId",nsPrefix,nsURI,refToMessageId));
                    soapBody.addChildElement(createElement("serviceType",nsPrefix,nsURI, serviceType));
                    AttachmentPart attachmentPart =request.createAttachmentPart();
                    FileDataSource fileDS = new FileDataSource(new File("tarek.xml"));
                    attachmentPart.setDataHandler(new DataHandler(fileDS));
                    attachmentPart.setContentType("application/xml");
                    request.addAttachmentPart(attachmentPart);
                    request.saveChanges();
                    /* Envoie la réponse à Hermes en retournant un id
    message deservice Web sender*/
                    SOAPMessage response =soapConn.call(request,sendEndpoint);
                    SOAPBody responseBody = response.getSOAPBody();
                  if (!responseBody.hasFault())
                   {
                       SOAPElement messageIdElement = getFirstChild(responseBody,"message_id", nsURI);
                       System.out.println("Le message est envoyé!!!");
                       System.out.println(messageIdElement == null ? null :messageIdElement.getValue());
                    }
                  else
                    {
                      System.out.println("message non envoyer");
                    throw new SOAPException(responseBody.getFault().getFaultString());
                    }
        }
            public SOAPElement createElement(String localName, String nsPrefix,String nsURI, String value) throws SOAPException {
                    SOAPElement soapElement = SOAPFactory.newInstance().createElement(localName, nsPrefix, nsURI);
                    soapElement.addTextNode(value);
                    return soapElement;
            }
            public SOAPElement getFirstChild(SOAPElement soapElement,String childLocalName, String childNsURI) throws SOAPException {
                    Name childName = SOAPFactory.newInstance().createName(childLocalName,null, childNsURI);
                    Iterator childIter =soapElement.getChildElements(childName);
                    if (childIter.hasNext())
                            return (SOAPElement) childIter.next();
                    return null;
            }
     
    }
    et voilà les exceptions
    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
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    Sending message to Hermes2!!...
    1 avr. 2011 03:23:24 com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection post
    GRAVE: SAAJ0009: Message send failed
    Exception in thread "main" com.sun.xml.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:180)
    	at org.esprit.Send.Send.envoie(Send.java:61)
    	at org.esprit.Send.Send.run(Send.java:36)
    	at org.esprit.Send.Send.main(Send.java:33)
    Caused by: java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:174)
    	... 3 more
    Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:378)
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:203)
    	... 5 more
    Caused by: java.net.ConnectException: Connection refused: connect
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    	at java.net.Socket.connect(Socket.java:519)
    	at java.net.Socket.connect(Socket.java:469)
    	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    	at sun.net.www.http.HttpClient.openServer(HttpClient.java:382)
    	at sun.net.www.http.HttpClient.openServer(HttpClient.java:509)
    	at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
    	at sun.net.www.http.HttpClient.New(HttpClient.java:304)
    	at sun.net.www.http.HttpClient.New(HttpClient.java:316)
    	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813)
    	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:765)
    	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690)
    	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:857)
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:335)
    	... 6 more
     
    CAUSE:
     
    java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:174)
    	at org.esprit.Send.Send.envoie(Send.java:61)
    	at org.esprit.Send.Send.run(Send.java:36)
    	at org.esprit.Send.Send.main(Send.java:33)
    Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:378)
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:203)
    	... 5 more
    Caused by: java.net.ConnectException: Connection refused: connect
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    	at java.net.Socket.connect(Socket.java:519)
    	at java.net.Socket.connect(Socket.java:469)
    	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    	at sun.net.www.http.HttpClient.openServer(HttpClient.java:382)
    	at sun.net.www.http.HttpClient.openServer(HttpClient.java:509)
    	at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
    	at sun.net.www.http.HttpClient.New(HttpClient.java:304)
    	at sun.net.www.http.HttpClient.New(HttpClient.java:316)
    	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813)
    	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:765)
    	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690)
    	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:857)
    	at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:335)
    	... 6 more
    SVP si vous pouvez m'aider je vous serez reconnaissant..

  2. #2
    Membre éclairé Avatar de rockley
    Homme Profil pro
    Inscrit en
    Décembre 2010
    Messages
    404
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Décembre 2010
    Messages : 404
    Par défaut
    Dois-tu t'authentifier. Il te manque peut-être des certificats.
    Je te dit ça car t'a :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Connection refused: connect

  3. #3
    Membre averti
    Inscrit en
    Mars 2010
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 19
    Par défaut
    Oui, je dois m'authetifier, et les fichiers XML sont bien configurés avec le login et le mot de passe, je les ai vérifié N fois !!!

  4. #4
    Membre éclairé Avatar de rockley
    Homme Profil pro
    Inscrit en
    Décembre 2010
    Messages
    404
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Décembre 2010
    Messages : 404
    Par défaut
    Tu utilise bien un trutStore et ketStore ?

  5. #5
    Membre averti
    Inscrit en
    Mars 2010
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 19
    Par défaut
    Non en fait je travaille sur hermes 2.0

Discussions similaires

  1. Réponses: 4
    Dernier message: 28/03/2005, 19h42
  2. probleme pour envoyer un Cold Start
    Par rocco4 dans le forum Développement
    Réponses: 2
    Dernier message: 21/09/2004, 15h00
  3. [ServerSocket] Envoyer un message vers un client
    Par Michel_57 dans le forum Web & réseau
    Réponses: 4
    Dernier message: 06/08/2004, 23h01
  4. Envoyer un message icmp (Echo Request)
    Par ovdz dans le forum Développement
    Réponses: 5
    Dernier message: 19/06/2003, 14h14

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