Webové služby, zjišťování souřadnic podniků. 12. díl
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 14 Apr 2010 00:12:32 +0200
changeset 10001be78803f73
parent 99 fd22f66e812d
child 101 d947b375d564
Webové služby, zjišťování souřadnic podniků.
java/nekurak.net-ejb/src/conf/Podnik.hbm.xml
java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.java
java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/Geo.java
java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java
java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Podnik.java
java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/PodnikRemote.java
java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java
java/nekurak.net-web/web/WEB-INF/casti/detail.jsp
java/nekurak.net-ws/nbproject/build-impl.xml
java/nekurak.net-ws/nbproject/genfiles.properties
java/nekurak.net-ws/nbproject/jax-ws.xml
java/nekurak.net-ws/nbproject/jaxws-build.xml
java/nekurak.net-ws/nbproject/project.properties
java/nekurak.net-ws/nbproject/project.xml
java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Podnik.java
java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Pokus.java
java/nekurak.net-ws/web/WEB-INF/wsit-cz.frantovo.nekurak.ws.Pokus.xml
java/nekurak.net-ws/web/index.jsp
     1.1 --- a/java/nekurak.net-ejb/src/conf/Podnik.hbm.xml	Mon Apr 12 12:09:45 2010 +0200
     1.2 +++ b/java/nekurak.net-ejb/src/conf/Podnik.hbm.xml	Wed Apr 14 00:12:32 2010 +0200
     1.3 @@ -21,6 +21,8 @@
     1.4  	    <list-index column="poradi"/>
     1.5  	    <one-to-many class="cz.frantovo.nekurak.dto.Fotka"/>
     1.6  	</list>
     1.7 +	<property name="sirka" column="sirka"/>
     1.8 +	<property name="delka" column="delka"/>
     1.9  
    1.10      </class>
    1.11  </hibernate-mapping>
    1.12 \ No newline at end of file
     2.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.java	Mon Apr 12 12:09:45 2010 +0200
     2.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.java	Wed Apr 14 00:12:32 2010 +0200
     2.3 @@ -25,6 +25,18 @@
     2.4  	return dotaz.getResultList();
     2.5      }
     2.6  
     2.7 +    /**
     2.8 +     * @return podniky, které nemají souřadnice (null, null)
     2.9 +     */
    2.10 +    public Collection<Podnik> getPodnikyBezSouradnic() {
    2.11 +	Query dotaz = em.createQuery("FROM " + DAO.t(Podnik.class) + " o WHERE sirka IS NULL AND delka IS NULL");
    2.12 +	return dotaz.getResultList();
    2.13 +    }
    2.14 +
    2.15 +    public Podnik getPodnik(int id) {
    2.16 +	return em.find(Podnik.class, id);
    2.17 +    }
    2.18 +
    2.19      public void zaloz(Podnik p) {
    2.20  	if (p.getDatum() == null) {
    2.21  	    p.setDatum(new Date());
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/Geo.java	Wed Apr 14 00:12:32 2010 +0200
     3.3 @@ -0,0 +1,102 @@
     3.4 +package cz.frantovo.nekurak.ejb;
     3.5 +
     3.6 +import java.io.UnsupportedEncodingException;
     3.7 +import java.net.URLEncoder;
     3.8 +import java.util.logging.Level;
     3.9 +import java.util.logging.Logger;
    3.10 +import javax.xml.parsers.DocumentBuilder;
    3.11 +import javax.xml.parsers.DocumentBuilderFactory;
    3.12 +import org.w3c.dom.Document;
    3.13 +import org.w3c.dom.Node;
    3.14 +import org.w3c.dom.NodeList;
    3.15 +
    3.16 +/**
    3.17 + * TODO: přesunout jinam a převést na EJB.
    3.18 + * @author fiki
    3.19 + */
    3.20 +public class Geo {
    3.21 +
    3.22 +    private static final Logger log = Logger.getLogger(Geo.class.getSimpleName());
    3.23 +
    3.24 +    /**
    3.25 +     * Převede poštovní adresu na zeměpisné souřadnice.
    3.26 +     * @param adresa
    3.27 +     * @return souřadnice k dané adrese nebo null, v případě chyby.
    3.28 +     */
    3.29 +    public Souradnice getSouradnice(String adresa) {
    3.30 +	try {
    3.31 +
    3.32 +	    /**
    3.33 +	     * TODO: naprosto zprasené → předělat →
    3.34 +	     * http://code.google.com/intl/cs/apis/maps/documentation/geocoding/#XMLParsing
    3.35 +	     */
    3.36 +	    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    3.37 +	    Document d = db.parse(sestavURL(adresa));
    3.38 +	    NodeList mista = d.getElementsByTagName("location");
    3.39 +	    Node misto = mista.item(0);
    3.40 +	    NodeList potomci = misto.getChildNodes();
    3.41 +	    String delka = null;
    3.42 +	    String sirka = null;
    3.43 +	    for (int i = 0; i < potomci.getLength(); i++) {
    3.44 +		Node p = potomci.item(i);
    3.45 +		System.out.println("XML:" + p.getNodeName() + "|" + p.getTextContent());
    3.46 +		if ("lat".equals(p.getNodeName())) {
    3.47 +		    sirka = p.getTextContent();
    3.48 +		}
    3.49 +		if ("lng".equals(p.getNodeName())) {
    3.50 +		    delka = p.getTextContent();
    3.51 +		}
    3.52 +	    }
    3.53 +
    3.54 +	    if (sirka == null || delka == null) {
    3.55 +		log.log(Level.WARNING, "Selhalo zjišťování souřadnic – šířka nebo délka jsou null – pro adresu: " + adresa);
    3.56 +		return null;
    3.57 +	    } else {
    3.58 +		return new Souradnice(Double.parseDouble(sirka), Double.parseDouble(delka));
    3.59 +	    }
    3.60 +	} catch (Exception e) {
    3.61 +	    log.log(Level.WARNING, "Selhalo zjišťování souřadnic pro adresu: " + adresa, e);
    3.62 +	    return null;
    3.63 +	}
    3.64 +    }
    3.65 +
    3.66 +    private static String sestavURL(String adresa) throws UnsupportedEncodingException {
    3.67 +	return "http://maps.google.com/maps/api/geocode/xml?sensor=false&address=" + URLEncoder.encode(adresa, "UTF-8");
    3.68 +    }
    3.69 +
    3.70 +    public class Souradnice {
    3.71 +
    3.72 +	private double sirka;
    3.73 +	private double delka;
    3.74 +
    3.75 +	@Override
    3.76 +	public String toString() {
    3.77 +	    return "šířka = " + sirka + "; délka = " + delka + ";";
    3.78 +	}
    3.79 +
    3.80 +	public Souradnice(double sirka, double delka) {
    3.81 +	    this.sirka = sirka;
    3.82 +	    this.delka = delka;
    3.83 +	}
    3.84 +
    3.85 +	public String getLoc() {
    3.86 +	    return "Loc: " + sirka + ", " + delka;
    3.87 +	}
    3.88 +
    3.89 +	public double getDelka() {
    3.90 +	    return delka;
    3.91 +	}
    3.92 +
    3.93 +	public double getSirka() {
    3.94 +	    return sirka;
    3.95 +	}
    3.96 +
    3.97 +	public void setDelka(double delka) {
    3.98 +	    this.delka = delka;
    3.99 +	}
   3.100 +
   3.101 +	public void setSirka(double sirka) {
   3.102 +	    this.sirka = sirka;
   3.103 +	}
   3.104 +    }
   3.105 +}
     4.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java	Mon Apr 12 12:09:45 2010 +0200
     4.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java	Wed Apr 14 00:12:32 2010 +0200
     4.3 @@ -2,6 +2,7 @@
     4.4  
     4.5  import cz.frantovo.nekurak.dao.PodnikDAO;
     4.6  import cz.frantovo.nekurak.dto.Podnik;
     4.7 +import cz.frantovo.nekurak.ejb.Geo.Souradnice;
     4.8  import java.util.Collection;
     4.9  import javax.annotation.Resource;
    4.10  import javax.annotation.security.RolesAllowed;
    4.11 @@ -26,6 +27,10 @@
    4.12  	return vysledek;
    4.13      }
    4.14  
    4.15 +    public Podnik getPodnik(int id) {
    4.16 +	return podnikDAO.getPodnik(id);
    4.17 +    }
    4.18 +
    4.19      @RolesAllowed("opravneny")
    4.20      public void zalozPodnik(Podnik p) {
    4.21  	p.setSpravce(ctx.getCallerPrincipal().getName());
    4.22 @@ -36,4 +41,25 @@
    4.23      public void upravPodnik(Podnik p) {
    4.24  	podnikDAO.uloz(p);
    4.25      }
    4.26 +
    4.27 +    public int dopocitejSouradnice() {
    4.28 +	/**
    4.29 +	 * TODO:    refaktorovat, změnit datové typy, souřadnice…
    4.30 +	 *	    dopočítávat jen ty, které ještě nemají souřadnice
    4.31 +	 */
    4.32 +	Geo g = new Geo();
    4.33 +	int pocetAktualizovanych = 0;
    4.34 +
    4.35 +	for (Podnik p : podnikDAO.getPodniky()) {
    4.36 +	    Souradnice s = g.getSouradnice(p.getUlice() + " " + p.getCisloPopisne() + ", " + p.getMesto());
    4.37 +	    if (s != null) {
    4.38 +		pocetAktualizovanych++;
    4.39 +		p.setSirka(s.getSirka());
    4.40 +		p.setDelka(s.getDelka());
    4.41 +		podnikDAO.uloz(p);
    4.42 +	    }
    4.43 +	}
    4.44 +
    4.45 +	return pocetAktualizovanych;
    4.46 +    }
    4.47  }
     5.1 --- a/java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Podnik.java	Mon Apr 12 12:09:45 2010 +0200
     5.2 +++ b/java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Podnik.java	Wed Apr 14 00:12:32 2010 +0200
     5.3 @@ -22,6 +22,8 @@
     5.4      private String mesto;
     5.5      private String spravce;
     5.6      private List<Fotka> fotky = new ArrayList<Fotka>();
     5.7 +    private Double sirka;
     5.8 +    private Double delka;
     5.9  
    5.10      public Podnik() {
    5.11      }
    5.12 @@ -110,4 +112,20 @@
    5.13      public void setFotky(List<Fotka> fotky) {
    5.14  	this.fotky = fotky;
    5.15      }
    5.16 +
    5.17 +    public Double getSirka() {
    5.18 +	return sirka;
    5.19 +    }
    5.20 +
    5.21 +    public void setSirka(Double sirka) {
    5.22 +	this.sirka = sirka;
    5.23 +    }
    5.24 +
    5.25 +    public Double getDelka() {
    5.26 +	return delka;
    5.27 +    }
    5.28 +
    5.29 +    public void setDelka(Double delka) {
    5.30 +	this.delka = delka;
    5.31 +    }
    5.32  }
     6.1 --- a/java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/PodnikRemote.java	Mon Apr 12 12:09:45 2010 +0200
     6.2 +++ b/java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/PodnikRemote.java	Wed Apr 14 00:12:32 2010 +0200
     6.3 @@ -17,4 +17,7 @@
     6.4  
     6.5      public void upravPodnik(Podnik p);
     6.6  
     6.7 +    public Podnik getPodnik(int id);
     6.8 +
     6.9 +    public int dopocitejSouradnice();
    6.10  }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java	Wed Apr 14 00:12:32 2010 +0200
     7.3 @@ -0,0 +1,51 @@
     7.4 +package cz.frantovo.nekurak.web;
     7.5 +
     7.6 +import cz.frantovo.nekurak.dto.Podnik;
     7.7 +import java.io.UnsupportedEncodingException;
     7.8 +import java.net.URLEncoder;
     7.9 +import java.util.logging.Level;
    7.10 +import java.util.logging.Logger;
    7.11 +
    7.12 +/**
    7.13 + *
    7.14 + * @author fiki
    7.15 + */
    7.16 +public class Detail {
    7.17 +
    7.18 +    private HledacSluzby hledac = new HledacSluzby();
    7.19 +    private int id;
    7.20 +    private Podnik podnik;
    7.21 +
    7.22 +    /**
    7.23 +     * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic
    7.24 +     */
    7.25 +    public String getMapa() {
    7.26 +	Podnik p = getPodnik();
    7.27 +
    7.28 +	if (p == null || p.getSirka() == null || p.getDelka() == null) {
    7.29 +	    return null;
    7.30 +	} else {
    7.31 +	    try {
    7.32 +		String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8");
    7.33 +		return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false&center=" + souradnice;
    7.34 +	    } catch (UnsupportedEncodingException e) {
    7.35 +		return null;
    7.36 +	    }
    7.37 +	}
    7.38 +    }
    7.39 +
    7.40 +    public int getId() {
    7.41 +	return id;
    7.42 +    }
    7.43 +
    7.44 +    public void setId(int id) {
    7.45 +	this.id = id;
    7.46 +    }
    7.47 +
    7.48 +    public Podnik getPodnik() {
    7.49 +	if (podnik == null) {
    7.50 +	    podnik = hledac.getPodnikEJB().getPodnik(id);
    7.51 +	}
    7.52 +	return podnik;
    7.53 +    }
    7.54 +}
     8.1 --- a/java/nekurak.net-web/web/WEB-INF/casti/detail.jsp	Mon Apr 12 12:09:45 2010 +0200
     8.2 +++ b/java/nekurak.net-web/web/WEB-INF/casti/detail.jsp	Wed Apr 14 00:12:32 2010 +0200
     8.3 @@ -6,8 +6,36 @@
     8.4  	  xmlns:nk="urn:jsptagdir:/WEB-INF/tags/nekurak"
     8.5  	  version="2.0">
     8.6  
     8.7 -    <nk:stranka titulek="TODO: Detail podniku">
     8.8 -	<p>TODO: Detail podniku (<c:out value="${param.podnik}"/>).</p>
     8.9 +    <jsp:useBean id="detail" class="cz.frantovo.nekurak.web.Detail" scope="request"/>
    8.10 +
    8.11 +    <jsp:setProperty name="detail" property="id" value="${param.podnik}"/>
    8.12 +
    8.13 +    <nk:stranka titulek="${fn:escapeXml(detail.podnik.nazev)}">
    8.14 +
    8.15 +	<h1><c:out value="${detail.podnik.nazev}" /></h1>
    8.16 +
    8.17 +
    8.18 +	<c:choose>
    8.19 +	    <c:when test="${detail.mapa == null}">
    8.20 +		<p>
    8.21 +		    Souřadnice tohoto podniku nejsou známé.<br/>
    8.22 +		    (možná ještě nebyl proveden jejich výpočet)
    8.23 +		</p>
    8.24 +	    </c:when>
    8.25 +	    <c:otherwise>
    8.26 +		<p>
    8.27 +		    Zeměpisná šířka: ${detail.podnik.sirka}<br/>
    8.28 +		    Zeměpisná délka: ${detail.podnik.sirka}<br/>
    8.29 +		    Loc: ${detail.podnik.sirka}, ${detail.podnik.delka}<br/>
    8.30 +		</p>
    8.31 +		<p>
    8.32 +		    <img alt="mapa" src="${fn:escapeXml(detail.mapa)}"/>
    8.33 +		</p>
    8.34 +	    </c:otherwise>
    8.35 +	</c:choose>
    8.36 +
    8.37 +
    8.38 +
    8.39      </nk:stranka>
    8.40  
    8.41  </jsp:root>
     9.1 --- a/java/nekurak.net-ws/nbproject/build-impl.xml	Mon Apr 12 12:09:45 2010 +0200
     9.2 +++ b/java/nekurak.net-ws/nbproject/build-impl.xml	Wed Apr 14 00:12:32 2010 +0200
     9.3 @@ -391,8 +391,16 @@
     9.4      <!--
     9.5                  COMPILATION SECTION
     9.6              -->
     9.7 -    <target depends="init" if="no.dist.ear.dir" name="deps-module-jar" unless="no.deps"/>
     9.8 -    <target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps"/>
     9.9 +    <target depends="init" if="no.dist.ear.dir" name="deps-module-jar" unless="no.deps">
    9.10 +        <ant antfile="${project.nekurak_net-lib}/build.xml" inheritall="false" target="jar">
    9.11 +            <property name="deploy.on.save" value="false"/>
    9.12 +        </ant>
    9.13 +    </target>
    9.14 +    <target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps">
    9.15 +        <ant antfile="${project.nekurak_net-lib}/build.xml" inheritall="false" target="jar">
    9.16 +            <property name="deploy.on.save" value="false"/>
    9.17 +        </ant>
    9.18 +    </target>
    9.19      <target depends="init, deps-module-jar, deps-ear-jar" name="deps-jar" unless="no.deps"/>
    9.20      <target depends="init,deps-jar" name="-pre-pre-compile">
    9.21          <mkdir dir="${build.classes.dir}"/>
    9.22 @@ -528,10 +536,13 @@
    9.23      </target>
    9.24      <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
    9.25      <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
    9.26 +        <copyfiles files="${reference.nekurak_net-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
    9.27          <mkdir dir="${build.web.dir}/META-INF"/>
    9.28          <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
    9.29      </target>
    9.30 -    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir"/>
    9.31 +    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
    9.32 +        <copyfiles files="${reference.nekurak_net-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
    9.33 +    </target>
    9.34      <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
    9.35          <delete dir="${build.web.dir}/WEB-INF/lib"/>
    9.36      </target>
    9.37 @@ -827,7 +838,9 @@
    9.38                  
    9.39                  CLEANUP SECTION
    9.40              -->
    9.41 -    <target depends="init" if="no.dist.ear.dir" name="deps-clean" unless="no.deps"/>
    9.42 +    <target depends="init" if="no.dist.ear.dir" name="deps-clean" unless="no.deps">
    9.43 +        <ant antfile="${project.nekurak_net-lib}/build.xml" inheritall="false" target="clean"/>
    9.44 +    </target>
    9.45      <target depends="init" name="do-clean">
    9.46          <condition property="build.dir.to.clean" value="${build.web.dir}">
    9.47              <isset property="dist.ear.dir"/>
    10.1 --- a/java/nekurak.net-ws/nbproject/genfiles.properties	Mon Apr 12 12:09:45 2010 +0200
    10.2 +++ b/java/nekurak.net-ws/nbproject/genfiles.properties	Wed Apr 14 00:12:32 2010 +0200
    10.3 @@ -3,8 +3,8 @@
    10.4  build.xml.stylesheet.CRC32=c0ebde35@1.21.2.1
    10.5  # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    10.6  # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    10.7 -nbproject/build-impl.xml.data.CRC32=4cb22909
    10.8 -nbproject/build-impl.xml.script.CRC32=2e1faad3
    10.9 +nbproject/build-impl.xml.data.CRC32=e6e63e07
   10.10 +nbproject/build-impl.xml.script.CRC32=222fc177
   10.11  nbproject/build-impl.xml.stylesheet.CRC32=b139b33b@1.21.2.1
   10.12  nbproject/wsit-deploy.xml.data.CRC32=4cb22909
   10.13  nbproject/wsit-deploy.xml.script.CRC32=deb039de
    11.1 --- a/java/nekurak.net-ws/nbproject/jax-ws.xml	Mon Apr 12 12:09:45 2010 +0200
    11.2 +++ b/java/nekurak.net-ws/nbproject/jax-ws.xml	Wed Apr 14 00:12:32 2010 +0200
    11.3 @@ -4,6 +4,9 @@
    11.4      <service name="Pokus">
    11.5        <implementation-class>cz.frantovo.nekurak.ws.Pokus</implementation-class>
    11.6      </service>
    11.7 +    <service name="Podnik">
    11.8 +      <implementation-class>cz.frantovo.nekurak.ws.Podnik</implementation-class>
    11.9 +    </service>
   11.10    </services>
   11.11    <clients/>
   11.12  </jax-ws>
    12.1 --- a/java/nekurak.net-ws/nbproject/jaxws-build.xml	Mon Apr 12 12:09:45 2010 +0200
    12.2 +++ b/java/nekurak.net-ws/nbproject/jaxws-build.xml	Wed Apr 14 00:12:32 2010 +0200
    12.3 @@ -24,6 +24,11 @@
    12.4              <classpath path="${java.home}/../lib/tools.jar:${build.classes.dir}:${j2ee.platform.wsgen.classpath}:${javac.classpath}"/>
    12.5          </wsgen>
    12.6      </target>
    12.7 +    <target name="wsgen-Podnik" depends="wsgen-init">
    12.8 +        <wsgen sourcedestdir="${build.generated.sources.dir}/jax-ws" resourcedestdir="${build.generated.sources.dir}/jax-ws/resources/" destdir="${build.generated.sources.dir}/jax-ws" verbose="true" xendorsed="true" keep="true" genwsdl="true" sei="cz.frantovo.nekurak.ws.Podnik">
    12.9 +            <classpath path="${java.home}/../lib/tools.jar:${build.classes.dir}:${j2ee.platform.wsgen.classpath}:${javac.classpath}"/>
   12.10 +        </wsgen>
   12.11 +    </target>
   12.12      <!--
   12.13                  ===================
   12.14                  JAX-WS WSIMPORT SECTION
    13.1 --- a/java/nekurak.net-ws/nbproject/project.properties	Mon Apr 12 12:09:45 2010 +0200
    13.2 +++ b/java/nekurak.net-ws/nbproject/project.properties	Wed Apr 14 00:12:32 2010 +0200
    13.3 @@ -26,7 +26,8 @@
    13.4  j2ee.platform=1.6-web
    13.5  j2ee.server.type=gfv3ee6
    13.6  jar.compress=false
    13.7 -javac.classpath=
    13.8 +javac.classpath=\
    13.9 +    ${reference.nekurak_net-lib.jar}
   13.10  # Space-separated list of extra javac options
   13.11  javac.compilerargs=
   13.12  javac.debug=true
   13.13 @@ -55,6 +56,8 @@
   13.14  no.dependencies=false
   13.15  persistence.xml.dir=${conf.dir}
   13.16  platform.active=default_platform
   13.17 +project.nekurak_net-lib=../nekurak.net-lib
   13.18 +reference.nekurak_net-lib.jar=${project.nekurak_net-lib}/dist/nekurak.net-lib.jar
   13.19  resource.dir=setup
   13.20  run.test.classpath=\
   13.21      ${javac.test.classpath}:\
    14.1 --- a/java/nekurak.net-ws/nbproject/project.xml	Mon Apr 12 12:09:45 2010 +0200
    14.2 +++ b/java/nekurak.net-ws/nbproject/project.xml	Wed Apr 14 00:12:32 2010 +0200
    14.3 @@ -8,7 +8,12 @@
    14.4          <data xmlns="http://www.netbeans.org/ns/web-project/3">
    14.5              <name>nekurak.net-ws</name>
    14.6              <minimum-ant-version>1.6.5</minimum-ant-version>
    14.7 -            <web-module-libraries/>
    14.8 +            <web-module-libraries>
    14.9 +                <library dirs="200">
   14.10 +                    <file>${reference.nekurak_net-lib.jar}</file>
   14.11 +                    <path-in-war>WEB-INF/lib</path-in-war>
   14.12 +                </library>
   14.13 +            </web-module-libraries>
   14.14              <web-module-additional-libraries/>
   14.15              <source-roots>
   14.16                  <root id="src.dir" name="Source Packages"/>
   14.17 @@ -17,5 +22,15 @@
   14.18                  <root id="test.src.dir" name="Test Packages"/>
   14.19              </test-roots>
   14.20          </data>
   14.21 +        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
   14.22 +            <reference>
   14.23 +                <foreign-project>nekurak_net-lib</foreign-project>
   14.24 +                <artifact-type>jar</artifact-type>
   14.25 +                <script>build.xml</script>
   14.26 +                <target>jar</target>
   14.27 +                <clean-target>clean</clean-target>
   14.28 +                <id>jar</id>
   14.29 +            </reference>
   14.30 +        </references>
   14.31      </configuration>
   14.32  </project>
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Podnik.java	Wed Apr 14 00:12:32 2010 +0200
    15.3 @@ -0,0 +1,28 @@
    15.4 +package cz.frantovo.nekurak.ws;
    15.5 +
    15.6 +import cz.frantovo.nekurak.ejb.PodnikRemote;
    15.7 +import javax.ejb.EJB;
    15.8 +import javax.jws.WebMethod;
    15.9 +import javax.jws.WebService;
   15.10 +
   15.11 +/**
   15.12 + *
   15.13 + * @author fiki
   15.14 + */
   15.15 +@WebService(serviceName = "podnikSluzba", targetNamespace = "podnikNS", portName = "podnikPort")
   15.16 +public class Podnik {
   15.17 +
   15.18 +    @EJB
   15.19 +    PodnikRemote ejb;
   15.20 +
   15.21 +    /**
   15.22 +     * Projde podniky, které nemají vyplněné souřadnice,
   15.23 +     * a pokusí se je doplnit na základě poštovní adresy podniku.
   15.24 +     * @return počet podniků, u nichž jsme doplnili souřadnice
   15.25 +     */
   15.26 +    @WebMethod(operationName = "dopocitejSouradnicePodleAdres")
   15.27 +    public int dopocitejSouradnice() {
   15.28 +	return ejb.dopocitejSouradnice();
   15.29 +    }
   15.30 +
   15.31 +}
    16.1 --- a/java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Pokus.java	Mon Apr 12 12:09:45 2010 +0200
    16.2 +++ b/java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Pokus.java	Wed Apr 14 00:12:32 2010 +0200
    16.3 @@ -7,10 +7,14 @@
    16.4  
    16.5  /**
    16.6   *
    16.7 + * Jedinou povinnou anotací je zde @WebService – ostatní nejsou nutné 
    16.8 + * a slouží k například k upřesnění názvu WS operace (pokud se má jmenovat jinak než metoda v Javě)
    16.9 + * nebo k definování názvů parametrů.
   16.10 + *
   16.11   * @author fiki
   16.12   */
   16.13 -@WebService(serviceName = "pokusnaSluzba", targetNamespace = "pokusNS")
   16.14 -@SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.ENCODED)
   16.15 +@WebService(serviceName = "pokusnaSluzba", targetNamespace = "pokusNS", portName = "pokusnyPort")
   16.16 +@SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.ENCODED)
   16.17  public class Pokus {
   16.18  
   16.19      /**
   16.20 @@ -20,7 +24,6 @@
   16.21       */
   16.22      @WebMethod(operationName = "pozdravOsobu")
   16.23      public String pozdrav(@WebParam(name = "jmenoOsoby") String koho) {
   16.24 -	System.out.println("Čeština? : koho=" + koho);
   16.25  	return "Ahoj, " + koho + "!";
   16.26      }
   16.27  }
    17.1 --- a/java/nekurak.net-ws/web/WEB-INF/wsit-cz.frantovo.nekurak.ws.Pokus.xml	Mon Apr 12 12:09:45 2010 +0200
    17.2 +++ b/java/nekurak.net-ws/web/WEB-INF/wsit-cz.frantovo.nekurak.ws.Pokus.xml	Wed Apr 14 00:12:32 2010 +0200
    17.3 @@ -5,19 +5,19 @@
    17.4      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    17.5      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="PokusService" targetNamespace="http://ws.nekurak.frantovo.cz/" xmlns:tns="http://ws.nekurak.frantovo.cz/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrmp/200702" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sc="http://schemas.sun.com/2006/03/wss/server" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy"
    17.6      >
    17.7 -    <message name="pozdravOsobu"/>
    17.8 -    <message name="pozdravOsobuResponse"/>
    17.9 -    <portType name="Pokus">
   17.10 -	<operation name="pozdravOsobu">
   17.11 -	    <input message="tns:pozdravOsobu"/>
   17.12 -	    <output message="tns:pozdravOsobuResponse"/>
   17.13 -	</operation>
   17.14 -    </portType>
   17.15 + <message name="pozdravOsobu"/>
   17.16 + <message name="pozdravOsobuResponse"/>
   17.17 + <portType name="Pokus">
   17.18 +  <operation name="pozdravOsobu">
   17.19 +   <input message="tns:pozdravOsobu"/>
   17.20 +   <output message="tns:pozdravOsobuResponse"/>
   17.21 +  </operation>
   17.22 + </portType>
   17.23      <binding name="PokusPortBinding" type="tns:Pokus">
   17.24 -	<operation name="pozdravOsobu">
   17.25 -	    <input/>
   17.26 -	    <output/>
   17.27 -	</operation>
   17.28 +     <operation name="pozdravOsobu">
   17.29 +      <input/>
   17.30 +      <output/>
   17.31 +     </operation>
   17.32      </binding>
   17.33      <service name="PokusService">
   17.34  	<port name="PokusPort" binding="tns:PokusPortBinding"/>
   17.35 @@ -27,9 +27,11 @@
   17.36  	    <wsp:All>
   17.37  		<sp:EncryptedParts>
   17.38  		    <sp:Body/>
   17.39 +		 <sp:Body/>
   17.40  		</sp:EncryptedParts>
   17.41  		<sp:SignedParts>
   17.42  		    <sp:Body/>
   17.43 +		 <sp:Body/>
   17.44  		</sp:SignedParts>
   17.45  	    </wsp:All>
   17.46  	</wsp:ExactlyOne>
   17.47 @@ -39,13 +41,41 @@
   17.48  	    <wsp:All>
   17.49  		<sp:EncryptedParts>
   17.50  		    <sp:Body/>
   17.51 +		 <sp:Body/>
   17.52  		</sp:EncryptedParts>
   17.53  		<sp:SignedParts>
   17.54  		    <sp:Body/>
   17.55 +		 <sp:Body/>
   17.56  		</sp:SignedParts>
   17.57  	    </wsp:All>
   17.58  	</wsp:ExactlyOne>
   17.59      </wsp:Policy>
   17.60 + <wsp:Policy wsu:Id="PokusPortBinding_pozdravOsobu_Input_Policy">
   17.61 +  <wsp:ExactlyOne>
   17.62 +   <wsp:All>
   17.63 +    <sp:EncryptedParts>
   17.64 +     <sp:Body/>
   17.65 +    </sp:EncryptedParts>
   17.66 +    <sp:SignedParts>
   17.67 +     <sp:Body/>
   17.68 +    </sp:SignedParts>
   17.69 +   </wsp:All>
   17.70 +  </wsp:ExactlyOne>
   17.71 + </wsp:Policy>
   17.72 + <wsp:Policy wsu:Id="PokusPortBinding_pozdravOsobu_Output_Policy">
   17.73 +  <wsp:ExactlyOne>
   17.74 +   <wsp:All>
   17.75 +    <sp:EncryptedParts>
   17.76 +     <sp:Body/>
   17.77 +    </sp:EncryptedParts>
   17.78 +    <sp:SignedParts>
   17.79 +     <sp:Body/>
   17.80 +    </sp:SignedParts>
   17.81 +   </wsp:All>
   17.82 +  </wsp:ExactlyOne>
   17.83 + </wsp:Policy>
   17.84  </definitions>
   17.85  
   17.86  
   17.87 +
   17.88 +
    18.1 --- a/java/nekurak.net-ws/web/index.jsp	Mon Apr 12 12:09:45 2010 +0200
    18.2 +++ b/java/nekurak.net-ws/web/index.jsp	Wed Apr 14 00:12:32 2010 +0200
    18.3 @@ -19,12 +19,20 @@
    18.4  	    <h1>WS SOAP</h1>
    18.5  	    <p>API postavené na webových službách</p>
    18.6  
    18.7 +	    <!-- TODO: generovat dynamicky  -->
    18.8 +
    18.9  	    <h2>Pokusná služba</h2>
   18.10  	    <ul>
   18.11  		<li><a href="pokusnaSluzba?WSDL">WSDL – popis služby</a></li>
   18.12  		<li><a href="pokusnaSluzba?Tester">Webové rozhraní pro vyzkoušení</a></li>
   18.13  	    </ul>
   18.14  
   18.15 +	    <h2>Podnik – služba</h2>
   18.16 +	    <ul>
   18.17 +		<li><a href="podnikSluzba?WSDL">WSDL – popis služby</a></li>
   18.18 +		<li><a href="podnikSluzba?Tester">Webové rozhraní pro vyzkoušení</a></li>
   18.19 +	    </ul>
   18.20 +
   18.21  	</body>
   18.22      </html>
   18.23