Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 16
  1. #1
    Utente di HTML.it L'avatar di Fra
    Registrato dal
    Oct 1999
    Messaggi
    221

    [Java & SOAP] che librerie?

    Che librerie mi consigliate (quelle della SUN, di Apache, ...) per creare, inviare, elaborare messaggi SOAP?
    SO : Windows XP - Linux Gentoo
    Java - Visual Basic - C++

  2. #2
    Utente di HTML.it L'avatar di Angelo1974
    Registrato dal
    Feb 2003
    Messaggi
    1,107
    Ciao.... sebbene sia da poco tempo che studio SOAP e Java Web Service da quanto ho visto e per quanto ho utilizzato questa tecnologia mi son trovato molto bene con JAXM della SUN....penso che sia buona per creare, inviare ed elaborare messaggi SOAP, almeno dal mio punto di vista.....ciao
    Se vuoi trovare l'arcobaleno, devi sopportare la pioggia

  3. #3
    Utente di HTML.it L'avatar di Fra
    Registrato dal
    Oct 1999
    Messaggi
    221
    Cosa hai installato per far funzionare la comunicazione SOAP? Java Web Services Developer Pack ?
    SO : Windows XP - Linux Gentoo
    Java - Visual Basic - C++

  4. #4
    Utente di HTML.it L'avatar di Angelo1974
    Registrato dal
    Feb 2003
    Messaggi
    1,107
    Ho scaricato il Java Web Services Developer Pack solo che non l'ho utilizzato ancora visto che sto facendo degli esempi e sto studiando da un libro preferisco interagire, per ora, con la libreria JAXM e JBuilder con cui mi trovo a mio agio, tra un po', poi, devo passare al Java Web Services Developer Pack perchè ho notato sul sito della Sun degli esempi molto interessanti...spero d'esserti stato d'aiuto e di non averti solo confuso di più le idee...ciaoooo
    Se vuoi trovare l'arcobaleno, devi sopportare la pioggia

  5. #5
    Utente di HTML.it L'avatar di Fra
    Registrato dal
    Oct 1999
    Messaggi
    221
    Grazie Angelo!
    C'è qualcuno invece che è a favore di APACHE?
    SO : Windows XP - Linux Gentoo
    Java - Visual Basic - C++

  6. #6
    Utente di HTML.it L'avatar di Fra
    Registrato dal
    Oct 1999
    Messaggi
    221

    x Angelo1974

    Mi spiegheresti come fare x implementare questo esempio (cn JAXM) ?

    Connessione tra Client e Server. Il client richiede dei dati al server inviandoli la richiesta sotto forma di messaggio SOAP.

    Grazie
    SO : Windows XP - Linux Gentoo
    Java - Visual Basic - C++

  7. #7
    Utente di HTML.it L'avatar di Angelo1974
    Registrato dal
    Feb 2003
    Messaggi
    1,107
    Ciao Fra ( uso il tuo nick name ) Stamani non posso postarti l'esempio perchè ho da fare al lavoro e tutte le librerie riguardanti JAXM le ho a casetta perchè sono cose che studio per me stasera o al più domani ti posto l'esempio....ciao
    Se vuoi trovare l'arcobaleno, devi sopportare la pioggia

  8. #8
    Utente di HTML.it L'avatar di Fra
    Registrato dal
    Oct 1999
    Messaggi
    221
    Ok aspetto una tua risposta ... :adhone:
    SO : Windows XP - Linux Gentoo
    Java - Visual Basic - C++

  9. #9
    Utente di HTML.it L'avatar di Fra
    Registrato dal
    Oct 1999
    Messaggi
    221
    Angelo, nel frattempo puoi dirmi cosa hai installato per far funzionare JAXM? C'è bisogno di J2EE?
    Ho provato a scaricare JAXM dal sito della sun, l'ho inserito nel CLASSPATH, però l'editor che uso (JCreator) nn mi rileva la libreria.
    SO : Windows XP - Linux Gentoo
    Java - Visual Basic - C++

  10. #10
    Utente di HTML.it L'avatar di Angelo1974
    Registrato dal
    Feb 2003
    Messaggi
    1,107
    Ciao... come promesso ti invio questo esempio..
    In questo esempio, il classico esempio "Hello world", c'è
    un destinatario ( una servlet ) ( HelloWorldReceiver ) ed un mittente
    ( HelloWorldSender ) il risultato sarà stampato a video
    Destinatario:

    /*
    * HelloWorldReceiver
    * Receive a JAXM message and reply in the time-honored fashion.
    */

    // General JDK
    import java.io.IOException;
    // JAXM
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPBodyElement;
    import javax.xml.soap.SOAPException;
    import javax.xml.messaging.JAXMServlet;
    import javax.xml.messaging.ReqRespListener;
    // Servlet
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;

    public class HelloWorldReceiver
    extends JAXMServlet
    implements ReqRespListener {
    MessageFactory messageFactory = null;
    public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    try {
    messageFactory = MessageFactory.newInstance();
    } catch (SOAPException e) {
    System.err.println("Exception caught instantiating MessageFactory:");
    e.printStackTrace();
    } // Catch
    }
    public SOAPMessage onMessage(SOAPMessage requestSoapMsg) {
    System.out.println(
    "HelloWorldReceiver recv the following JAXM msg in onMessage():");
    try {
    requestSoapMsg.writeTo(System.out);
    System.out.println("\n");

    SOAPMessage responseSoapMsg = messageFactory.createMessage();

    /*
    * Note that a header element is not defined here.
    * Although this is an optional element, JAXM will implicitly
    * nevertheless create an empty header.
    */
    // Create Body element containing response.
    SOAPEnvelope responseSoapEnv = responseSoapMsg.getSOAPPart()
    .getEnvelope();
    SOAPBody responseSoapBody = responseSoapEnv.getBody();
    SOAPBodyElement responseSoapBodyEl =
    responseSoapBody.addBodyElement(responseSoapEnv.cr eateName("Response"));
    responseSoapBodyEl.addTextNode("Hello world");

    responseSoapMsg.saveChanges();
    System.out.println(
    "HelloWorldReceiver responding with the following JAXM message:");
    responseSoapMsg.writeTo(System.out);
    System.out.println("\n");

    return responseSoapMsg;

    } catch (SOAPException e) {
    System.err.println("Error in processing or replying to a message");
    e.printStackTrace();
    return null;
    } catch (IOException e) {
    System.err.println(
    "Encountered IOException writing SOAPMessage to System.out: ");
    e.printStackTrace();
    return null;
    }
    } // onMessage()
    } // HelloWorldReceiver



    Mittente:
    /*
    * HelloWorldSender
    * Very basic demonstration of JAXM SOAP profile with no provider.
    * This shows synchronous, client/server-style call.
    */
    // General JDK
    import java.io.IOException;
    // JAXM
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.soap.SOAPHeaderElement;
    import javax.xml.soap.Name;
    import javax.xml.soap.SOAPException;
    import javax.xml.messaging.URLEndpoint;

    public class HelloWorldSender {

    public static void main(String args[]) {

    URLEndpoint urlEndpoint = null;
    if (args.length == 1)
    urlEndpoint = new URLEndpoint(args[0]);
    else {
    System.err.println("Usage: java HelloWorldSender targetURL");
    System.exit(0);
    } // Else

    try {
    // Initialize connection and SOAP Profile.
    System.out.println("Opening connection...");
    SOAPConnectionFactory soapConnFct = SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection = soapConnFct.createConnection();

    System.out.println("Creating message...");
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage requestSoapMsg = messageFactory.createMessage();

    // Create references to SOAP message components
    SOAPPart requestSoapPart = requestSoapMsg.getSOAPPart();
    SOAPEnvelope requestSoapEnv = requestSoapPart.getEnvelope();
    SOAPHeader requestSoapHdr = requestSoapEnv.getHeader();

    // Add header field. Header fields are optional.
    Name questionName = requestSoapEnv.createName("Question");
    SOAPHeaderElement questionElement =
    requestSoapHdr.addHeaderElement(questionName);
    questionElement.setMustUnderstand(true);
    questionElement.addTextNode("Are you there?");

    /*
    * Note that a body element is not defined here.
    * Because this is a required field, JAXM
    * implicitly creates an empty body.
    */

    // Save all changes to message before printing.
    // Sending will also implictly save changes.
    requestSoapMsg.saveChanges();

    System.out.println("HelloWorldSender is sending the following message:");
    try {
    requestSoapMsg.writeTo(System.out);
    } catch (IOException e) {
    System.err.println(
    "Encountered IOException trying to write SOAPMessage to System.out: ");
    e.printStackTrace();
    }
    System.out.println("\nTo URL: ");
    System.out.println(urlEndpoint.getURL() + "\n");

    // Send request and block until reply appears.
    SOAPMessage responseSoapMsg = soapConnection.call(requestSoapMsg, urlEndpoint);

    System.out.println("HelloWorldSender received the following reponse message:");
    try {
    responseSoapMsg.writeTo(System.out);
    System.out.println("\n");
    } catch (IOException e) {
    System.err.println(
    "Encountered IOException trying to write SOAPMessage to System.out: ");
    e.printStackTrace();
    }

    // Clean up
    soapConnection.close();
    System.out.println("Connection closed.");

    } catch (SOAPException e) {
    System.err.println("Encountered general SOAPException: ");
    e.printStackTrace();
    }
    System.out.println("Done.");
    } // main()
    } // HelloWorldSender
    Questo esempio è stato tratto dal libro "Java Web service Tutto&Oltre"
    della Apogeo e lo trovo molto buono ( ciò se può esserti utile ). Inoltre ti
    posto un altro esempio in cui c'è un semplice file server che effettua il
    trasferemnto di un file dal client al server, la particolarità di questo esempio
    è che il server NON HA NESSUN TIPO DI SICUREZZA quindi sta attento, quando lo usi,
    ad evitare che qualcuno possa entrare nel tuo PC. Lo metto nel prossimo post, il msg originale era troppo lungo
    Se vuoi trovare l'arcobaleno, devi sopportare la pioggia

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.