Creazione di una struttura di bean Java da un documento WSDL mediante l'ambiente runtime Apache Axis

La procedura guidata Servizio Web consente di creare un bean di struttura da un documento WSDL esistente. Il bean della struttura contiene un insieme di metodi che corrispondono alle operazioni descritte nel documento WSDL. Quando viene creato il bean, ciascun metodo presenta un'implementazione di prova che viene sostituita modificando il bean.

Prerequisiti:

  1. Se si desidera utilizzare il servlet Apache Jakarta Tomcat come server, è necessario installarlo, configurare una istanza relativa e creare un progetto Web come descritto nella sezione Creazione di un server Apache Tomcat e di un progetto Web.
  2. Creare o importare un file WSDL nella cartella Contenuto di origine del progetto Web. È possibile utilizzare solo un file WSDL che contiene un elemento di servizio.
Per creare un servizio Web da un file WSDL mediante l'ambiente runtime Apache Axis 1.0:
  1. Passare alla prospettiva J2EE (Finestra > Apri prospettiva > J2EE).
  2. In the Project Explorer view, select the WSDL file that you created or imported into the Web Content folder of your Web project.
  3. Scegliere File > Nuovo > Altro. Selezionare Servizi Web per visualizzare le procedure guidate disponibili. Selezionare la procedura guidata Servizio Web. Fare clic su Avanti.
  4. Web Services page: select Top down Java bean Web service as your Web service type, and select the artifact from which the service will be created.
    1. Select the stages of Web services development that you want to complete using the slider:
      • Sviluppa: questa opzione crea il codice del servizio
      • Assembla:
      • Distribuisci: questa opzione crea il codice di distribuzione per il servizio
      • Installa: questa opzione installa il servizio sul server scelto
      • Avvia: questa opzione avvia il server una volta installato il servizio
      • Verifica: questa opzione fornisce diverse possibilità per la verifica del servizio
    2. Select your server: the default server is displayed. If you want to deploy your service to a different server click the link to specify a different server.
    3. Select your runtime: the default runtime is displayed. If you want to deploy your service to a different runtime click the link to specify a different runtime.
    4. Select the service project: the project containing the project selected in your workspace is displayed. To select a different project and EAR click on the project link. Assicurarsi che il progetto selezionato come progetto Web client sia diverso dal progetto Web di servizio, altrimenti il servizio verrà sovrascritto dalle risorse generate del client.
    5. If you want to create a client, select the type of proxy to be generated and repeat the above steps for the client.
    6. Publish the Web service: this will launch the Web Services Explorer to publish your Web service to a UDDI registry.
    7. Monitor the Web service: this will send the Web service traffic through the TCP/IP Monitor, which allows you to watch the SOAP traffic generated by the Web service and to test this traffic for WS-I compliance. In alternativa, è possibile impostare manualmente un controllo TCP/IP come descritto in Utilizzo del controllo TCP/IP per la verifica dei servizi Web.
  5. Web Services Skeleton Java™ Bean Configuration page: Select the folder where the generated Java will be stored. Se si desidera verificare o modificare le associazioni tra pacchetti e spazi nomi, selezionare la casella di controllo Definisci un'associazione personalizzata da spazio nomi a pacchetto. Fare clic su Avanti.
  6. Web Service Namespace to Package Mappings page: if you selected Define custom mapping for package to namespace on the previous panel, you can enter your custom mapping pairs on this panel by clicking Add. Fare clic su Avanti.
  7. Web Service Test page: If you selected to test the Web service, select the test facility for the generated Web service. Il servizio Web verrà aperto in Esplora servizi Web. Selezionare l'operazione che si desidera verificare, immettere le operazioni richieste e fare clic su Vai. Il risultato verrà visualizzato nel pannello Stato. Fare clic su Avanti.
  8. Web Service Proxy page: If you have selected to generate a proxy, this page shows the options for the proxy. Essa riporta la cartella in cui verrà generato il proxy e da cui è possibile facoltativamente creare associazioni personalizzate tra spazi nomi e pacchetti. Scegliere Avanti.
  9. Web Service Client Test page: Use this page to select the following options:
    1. Select your test facility. You can test the generated proxy in the Web Service Explorer, or you can generate a sample Web service JSP.
    2. If you selected to test the proxy through a JSP, you can select the folder where the JSP will be located, and you can select the methods that will be included in the JSP.
    3. Select Run test on server to start the server for you automatically.
  10. Web Service Publication page: If you have selected to publish your Web service to a UDDI registry, use this page to launch the Web Services Explorer and select the UDDI registry to which the Web service will be published. Fare clic su Fine.
Una volta creato il servizio Web, è possibile che si verifichi quanto riportato di seguito in base alle opzioni selezionate:
  • Se si preferisce verificare il proxy generato utilizzando le pagine JSP del servizio Web, il proxy viene avviato in un browser Web al seguente URL: http://hostlocale: porta/ WebProjectClient/sampleBeanName/ WebServiceName/TestClient.jsp. È possibile utilizzare questa applicazione di esempio per verificare il servizio Web selezionando un metodo, immettendo unvalore per il metodo e facendo clic su Richiama. Il risultato del metodo verrà visualizzato nel riquadro dei risultati.
  • Se è stata selezionata la verifica del servizio Web mediante Esplora servizi Web, questo verrà aperto. Selezionare l'operazione che si desidera verificare, immettere le operazioni richieste e fare clic su Vai. Il risultato verrà visualizzato nel pannello Stato.
  • Se è stata selezionata la pubblicazione del servizio Web, Esplora servizi Web verrà avviato visualizzando la pagina richiesta per pubblicare il servizio Web. Seguire le istruzioni riportate in Pubblicazione del servizio Web per completare questa attività.