Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Jee kurzus 8. het

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 12 Anuncio

Más Contenido Relacionado

Similares a Jee kurzus 8. het (18)

Anuncio

Jee kurzus 8. het

  1. 1. JEE KURZUS 8. HÉT SETENY.JANOS@TIGRA.HU 1
  2. 2. Web Service-ek Algoritmusok, illetve metódusok, amiket távoli számítógépről és/vagy más programozási nyelv használatával hívunk Előny, ha az adatokat kezelő algoritmusokat nem kell letölteni a fölhasználó gépére A szerveren kevesebb problémával lehet őket frissíteni A WSDL leíró nyelv segítségével tudnak egymással kommunikálni a Web Service-ek Ez egy XML alapú nyelv 2
  3. 3. Webservice projekt 3
  4. 4. Webservice projekt Legyen a projekt neve:
 Webservice and Arquillian in WebApp Válassz Yes-t erre: Create not existing directory? No-t erre: Elvárt eredmény: 4
  5. 5. HelloWorld.java package example; // InvocationTargetException enélkül @WebService()
 public class HelloWorld {
 @WebMethod
 public String sayHelloWorldFrom(String from) {
 String result = "Hello, world, from " + from;
 System.out.println(result);
 return result;
 }
 public static void main(String[] argv) {
 Object implementor = new HelloWorld ();
 String address = "http://localhost:9000/HelloWorld";
 Endpoint.publish(address, implementor);
 }
 } Kattints a zöld háromszögre (lejátszás jelre) az alábbi sor bal szélén
 “public class HelloWorld {“
  6. 6. Client module Ctrl+Shift+A Module … (New) Válaszd a bal oldali oszlopban fölül a Java-t és ne jelölj ki semmit a jobb oldali oszlopban Module name: Client Másold a böngésző címsorába a HelloWorld.java-ból:
 http://localhost:9000/HelloWorld Jobb gombbal kattints az alábbi linkre és a Link másolása -t válaszd
 http://localhost:9000/HelloWorld?wsdl Vissza az IntelliJ-be és Alt+F12 (terminál) mkdir Client/lib cd Client/lib wsimport -clientjar client.jar -d . http://localhost:9000/HelloWorld?wsdl rm -rf example Dokumentáció:
 http://docs.oracle.com/javase/7/docs/technotes/tools/share/wsimport.html 6
  7. 7. Client module Jobb klikk a Client/lib/client.jar -on Alulról a 3. Add as Library, OK Jobb klikk a Client/src mappán, New, Java Class Legyen az osztály neve Client Írd be az osztály belsejébe, hogy psvm Ctrl+J, Enter Utána pedig ezt a kódot írd be: String hello = 
 new HelloWorldService().getHelloWorldPort().sayHelloWorldFrom("92"); hello.sout Ctrl+J -t nyomj, utána pedig Enter-t Futtasd a Client osztályt a “public class Client” sor előtti zöld háromszögre kattintva 7
  8. 8. SOAP Request / Response Demonstráció arról hogy SOAP Request, illetve Response kerül küldésre amikor Webservice-el kommunikálunk mvn archetype:generate - Dfilter=org.jboss.ws.plugins.archetypes: A : fontos a sor végén IntelliJ-ben megnyitni Ctrl+Shift+A Edit Configurations… Glassfish Server, Local Server Domain: domain1 Fix gomb, exploded artifact 8
  9. 9. SOAP Request / Response Run http://localhost:4848, user: admin, a password-öt hagyd üresen Applications-t szétnyitni, alatta kattintani Jobb oldalt legalul View Endpoint xxxx/HelloWorldService?Tester http://… sayHi Gergely 9
  10. 10. WSDL fájl szerkezete <types> - Nyisd meg a schemaLocation = “valami” címet! <message> <portType> - interface <binding> <service> 10
  11. 11. JAX-WS tutorial-ok https://www.linkedin.com/learning/ building-web-services-with-java-ee https://docs.oracle.com/javaee/7/ tutorial/jaxws.htm http://docs.jboss.org/jbossws/ 5.0.0.Final/ 11
  12. 12. Failed to read schema document 'xjc.xsd' [WARNING] schema_reference: Failed to read schema document 'HelloWorld?xsd=1', because 'http' access is not allowed due to restriction set by the accessExternalSchema property. line 4 of http://localhost:9000/HelloWorld?wsdl#types?schema1 llian.class Caused by: org.xml.sax.SAXParseException; systemId: jar:file:/ Users/setenyjanos/prj/JEE/Forras-anyag/Ex_Files_WebSrvcs_JavaEE/ Webservice%20in%20WebApp/lib/jaxb-xjc.jar!/com/sun/tools/xjc/ reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.crea teSAXParseException(ErrorHandlerWrapper.java:203) A megoldás IntelliJ-vel generált kliens kód helyett terminálban wsimport -clientjar client.jar -d . http://localhost:9000/HelloWorld?wsdl

×