WS: skript pro vyzkoušení webových služeb.
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon Apr 12 12:09:45 2010 +0200 (2010-04-12)
changeset 99fd22f66e812d
parent 98 75dec396f0e3
child 100 01be78803f73
WS: skript pro vyzkoušení webových služeb.
java/nekurak.net-ws/nbproject/genfiles.properties
java/nekurak.net-ws/nbproject/wsit.createuser
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
test/ws/pokus-data.xml
test/ws/vyzkoušej.sh
     1.1 --- a/java/nekurak.net-ws/nbproject/genfiles.properties	Mon Apr 12 10:50:39 2010 +0200
     1.2 +++ b/java/nekurak.net-ws/nbproject/genfiles.properties	Mon Apr 12 12:09:45 2010 +0200
     1.3 @@ -9,3 +9,4 @@
     1.4  nbproject/wsit-deploy.xml.data.CRC32=4cb22909
     1.5  nbproject/wsit-deploy.xml.script.CRC32=deb039de
     1.6  nbproject/wsit-deploy.xml.stylesheet.CRC32=beb36995@3.9.1
     1.7 +nbproject/jaxws-build.xml.stylesheet.CRC32=83928735
     2.1 --- a/java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Pokus.java	Mon Apr 12 10:50:39 2010 +0200
     2.2 +++ b/java/nekurak.net-ws/src/java/cz/frantovo/nekurak/ws/Pokus.java	Mon Apr 12 12:09:45 2010 +0200
     2.3 @@ -9,7 +9,7 @@
     2.4   *
     2.5   * @author fiki
     2.6   */
     2.7 -@WebService(serviceName = "pokusnaSluzba", targetNamespace="pokusNS")
     2.8 +@WebService(serviceName = "pokusnaSluzba", targetNamespace = "pokusNS")
     2.9  @SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.ENCODED)
    2.10  public class Pokus {
    2.11  
    2.12 @@ -18,8 +18,9 @@
    2.13       * @param koho jméno osoby v pátém pádě
    2.14       * @return věta – pozdrav
    2.15       */
    2.16 -    @WebMethod(operationName="pozdravOsobu")
    2.17 +    @WebMethod(operationName = "pozdravOsobu")
    2.18      public String pozdrav(@WebParam(name = "jmenoOsoby") String koho) {
    2.19 +	System.out.println("Čeština? : koho=" + koho);
    2.20  	return "Ahoj, " + koho + "!";
    2.21      }
    2.22  }
     3.1 --- a/java/nekurak.net-ws/web/WEB-INF/wsit-cz.frantovo.nekurak.ws.Pokus.xml	Mon Apr 12 10:50:39 2010 +0200
     3.2 +++ b/java/nekurak.net-ws/web/WEB-INF/wsit-cz.frantovo.nekurak.ws.Pokus.xml	Mon Apr 12 12:09:45 2010 +0200
     3.3 @@ -1,50 +1,50 @@
     3.4  <?xml version="1.0" encoding="UTF-8"?> 
     3.5 - <definitions 
     3.6 - xmlns="http://schemas.xmlsoap.org/wsdl/" 
     3.7 - xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
     3.8 - xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     3.9 - 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"
    3.10 - >
    3.11 +<definitions 
    3.12 +    xmlns="http://schemas.xmlsoap.org/wsdl/"
    3.13 +    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    3.14 +    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    3.15 +    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"
    3.16 +    >
    3.17      <message name="pozdravOsobu"/>
    3.18      <message name="pozdravOsobuResponse"/>
    3.19      <portType name="Pokus">
    3.20 -        <operation name="pozdravOsobu">
    3.21 -            <input message="tns:pozdravOsobu"/>
    3.22 -            <output message="tns:pozdravOsobuResponse"/>
    3.23 -        </operation>
    3.24 +	<operation name="pozdravOsobu">
    3.25 +	    <input message="tns:pozdravOsobu"/>
    3.26 +	    <output message="tns:pozdravOsobuResponse"/>
    3.27 +	</operation>
    3.28      </portType>
    3.29      <binding name="PokusPortBinding" type="tns:Pokus">
    3.30 -        <operation name="pozdravOsobu">
    3.31 -            <input/>
    3.32 -            <output/>
    3.33 -        </operation>
    3.34 +	<operation name="pozdravOsobu">
    3.35 +	    <input/>
    3.36 +	    <output/>
    3.37 +	</operation>
    3.38      </binding>
    3.39      <service name="PokusService">
    3.40 -        <port name="PokusPort" binding="tns:PokusPortBinding"/>
    3.41 +	<port name="PokusPort" binding="tns:PokusPortBinding"/>
    3.42      </service>
    3.43      <wsp:Policy wsu:Id="PokusPortBinding_pozdrav_Input_Policy">
    3.44 -        <wsp:ExactlyOne>
    3.45 -            <wsp:All>
    3.46 -                <sp:EncryptedParts>
    3.47 -                    <sp:Body/>
    3.48 -                </sp:EncryptedParts>
    3.49 -                <sp:SignedParts>
    3.50 -                    <sp:Body/>
    3.51 -                </sp:SignedParts>
    3.52 -            </wsp:All>
    3.53 -        </wsp:ExactlyOne>
    3.54 +	<wsp:ExactlyOne>
    3.55 +	    <wsp:All>
    3.56 +		<sp:EncryptedParts>
    3.57 +		    <sp:Body/>
    3.58 +		</sp:EncryptedParts>
    3.59 +		<sp:SignedParts>
    3.60 +		    <sp:Body/>
    3.61 +		</sp:SignedParts>
    3.62 +	    </wsp:All>
    3.63 +	</wsp:ExactlyOne>
    3.64      </wsp:Policy>
    3.65      <wsp:Policy wsu:Id="PokusPortBinding_pozdrav_Output_Policy">
    3.66 -        <wsp:ExactlyOne>
    3.67 -            <wsp:All>
    3.68 -                <sp:EncryptedParts>
    3.69 -                    <sp:Body/>
    3.70 -                </sp:EncryptedParts>
    3.71 -                <sp:SignedParts>
    3.72 -                    <sp:Body/>
    3.73 -                </sp:SignedParts>
    3.74 -            </wsp:All>
    3.75 -        </wsp:ExactlyOne>
    3.76 +	<wsp:ExactlyOne>
    3.77 +	    <wsp:All>
    3.78 +		<sp:EncryptedParts>
    3.79 +		    <sp:Body/>
    3.80 +		</sp:EncryptedParts>
    3.81 +		<sp:SignedParts>
    3.82 +		    <sp:Body/>
    3.83 +		</sp:SignedParts>
    3.84 +	    </wsp:All>
    3.85 +	</wsp:ExactlyOne>
    3.86      </wsp:Policy>
    3.87  </definitions>
    3.88  
     4.1 --- a/java/nekurak.net-ws/web/index.jsp	Mon Apr 12 10:50:39 2010 +0200
     4.2 +++ b/java/nekurak.net-ws/web/index.jsp	Mon Apr 12 12:09:45 2010 +0200
     4.3 @@ -18,6 +18,13 @@
     4.4  	<body>
     4.5  	    <h1>WS SOAP</h1>
     4.6  	    <p>API postavené na webových službách</p>
     4.7 +
     4.8 +	    <h2>Pokusná služba</h2>
     4.9 +	    <ul>
    4.10 +		<li><a href="pokusnaSluzba?WSDL">WSDL – popis služby</a></li>
    4.11 +		<li><a href="pokusnaSluzba?Tester">Webové rozhraní pro vyzkoušení</a></li>
    4.12 +	    </ul>
    4.13 +
    4.14  	</body>
    4.15      </html>
    4.16  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/ws/pokus-data.xml	Mon Apr 12 12:09:45 2010 +0200
     5.3 @@ -0,0 +1,8 @@
     5.4 +<?xml version='1.0' encoding='UTF-8'?>
     5.5 +<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
     5.6 +    <S:Body>
     5.7 +	<ns2:pozdravOsobu xmlns:ns2="pokusNS">
     5.8 +	    <jmenoOsoby>češtino</jmenoOsoby>
     5.9 +	</ns2:pozdravOsobu>
    5.10 +    </S:Body>
    5.11 +</S:Envelope>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/ws/vyzkoušej.sh	Mon Apr 12 12:09:45 2010 +0200
     6.3 @@ -0,0 +1,23 @@
     6.4 +#!/bin/bash
     6.5 +
     6.6 +# Zavolá webovou službu a vypíše odpověď na standardní výstup
     6.7 +
     6.8 +# Soubor se vstupními daty
     6.9 +data="pokus-data.xml";
    6.10 +
    6.11 +# URL služby
    6.12 +url="http://nekurak.net/ws/pokusnaSluzba";
    6.13 +
    6.14 +# XML přicházející jako odpověď ze serveru není odsazené →
    6.15 +# pokud máme XML odsazovač, hezky si ho naformátujeme.
    6.16 +odsazovac="cat";
    6.17 +xmlindent="/usr/bin/xmlindent";
    6.18 +if [ -f ${xmlindent} ]
    6.19 +then
    6.20 +    odsazovac=${xmlindent};
    6.21 +fi
    6.22 +
    6.23 +# -s = skryjeme statistiky (chybový výstup)
    6.24 +# -H = nastavíme správný typ dat (jinak by se použil application/x-www-form-urlencoded)
    6.25 +# -d @ = načteme data ze souboru
    6.26 +curl -s  -H "Content-Type: text/xml"  -d @${data} ${url} | ${odsazovac};