Creazione di un servizio Web da un bean Javamediante l'ambiente runtime Apache Axis

La procedura guidata Servizio Web consente di creare un nuovo servizio Web, di configurarlo per la distribuzione e distribuirlo su un server. Una volta distribuito il servizio Web, la procedura guidata consentirà di generare il proxy client e l'applicazione di esempio per verificare il servizio Web. Una volta completata la fase di verifica, è possibile pubblicare il servizio Web su un UDDI Business Registry mediante la procedura di esportazione.

Prerequisiti:
  1. Create or import a bean into the Java™ source folder of the Web project.
Per creare un servizio Web da un bean mediante l'ambiente runtime Apache Axis:
  1. Passare alla prospettiva J2EE (Finestra > Apri prospettiva > J2EE).
  2. In the Project Explorer view, select the bean that you created or imported into the source folder of your Web project.
  3. Click File > New > Other. Selezionare Servizi Web per visualizzare le procedure guidate disponibili. Selezionare la procedura guidata Servizio Web. Fare clic su Avanti.
  4. Web Services page: select Bottom up Java bean Web service as your Web service type, and enter the URI to the WSDL, WSIL, or HTML file that will be used to generate the service.
    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 Service Java Bean Identity page: the Web service WSDL name will be listed. Sono disponibili le seguenti opzioni:
    • Selezionare i metodi da utilizzare.
    • Selezionare lo stile di codifica. RPC/Encoded è lo stile di codifica consigliato per l'ambiente runtime Axis. Questo metodo di codifica non è conforme a WS-I.
    • Selezionare se si desidera personalizzare le associazioni tra pacchetti e spazi nomi.
    Fare clic su Avanti
  6. Web Service Package to Namespace 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.
  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, select if you want to customize the package to namespace mappings.
  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: Select whether or not you want to publish this Web service to a UDDI registry. Click Finish Note: you may see a warning stating Error in generating WSDL from Java. ClassNotFound: <nome bean>. Questo errore può essere tranquillamente ignorato.
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à.

Importante: se i metodi contengono tipi non supportati dall'esempio, come ad esempio le array, le proprietà indicizzate e le raccolte, i metodi verranno omessi dall'esempio e verrà ricevuto un messaggio di avvertenza.