Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Content
Index.......................................................................................................................................3 WSS WebServiceServlet.......................................................................................................3 License...................................................................................................................................3 Live picture of WSS wsdl on Google App Engine .................................................................3 Quiq start for creating WSS Web Serivce..............................................................................4 Create Google App Engine project without GWT..............................................................4 Create MyWebService.java file into package org.vnetcon.wss.test..................................4 Create Employee.java file into package org.vnetcon.wss.test..........................................4 Add following configuration to just created web.xml..........................................................5 add wss-0.5b.jar to projects classpath. ............................................................................5 Create schema file for classes you use in your Web Service. .........................................5 Start Google App Engine development server..................................................................6 1 .point your browser at http://localhost:8888/wss........................................................6 2. To see the wsdl for your webservice add ?wsd to url................................................6 3. to see xsd used with this webservice add ?xsd=1 to url...........................................6 Now your done. .................................................................................................................6 Creating client java code for calling WSS Web Service from client side...............................7 wsimport.............................................................................................................................7 Example client....................................................................................................................7 WSS little deeper...................................................................................................................8 What Web Service actually is?..........................................................................................8 Why I have to create schema file for WSS?......................................................................8 How web methods are called?..........................................................................................8 Supported datatypes and java classes..............................................................................9 How to use complex java objects like byte[], ArrayList, HashMap?..................................9 About class annotations.....................................................................................................9 WSS vs. Standard Web Service..........................................................................................10 Misc......................................................................................................................................10 About namespaces..........................................................................................................10 About method names.......................................................................................................10 About content...................................................................................................................10 XMLGregorianCalendar, Qname, Duration behavior......................................................10 About coding....................................................................................................................10 Deploying to Google App Engine.....................................................................................11
Index
User Guid for developers to create WSS (WebServiceServlet) based WebServices.
WSS WebServiceServlet
WSS is a regular servlet that can be run on any servlet container like Google App Engine, Tomcat, Glassfish etc. WSS acts to outer world like any simple regular Web Service.
License
WSS is licensed under GPL.
You may remove the "startup servlet config" from web.xml and also delete the "startup servlet java file" from project
Create schema file for classes you use in your Web Service.
In this example case for Employee.java 1. 2. 3. 4. open dos command prompt navigate to your projects src folder type: schemagen org.vnetcon.wss.test.dao.Employee copy created schema1.xsd to your war/WEB-INF/classes/org/vnetcon/wss/test directory
Creating client java code for calling WSS Web Service from client side
The most common way to do this is to autogenerate the code using IDE's build in functionalities. Here we do it on command line using java's wsimport program.
wsimport
Create Web Service client code with two easy step 1. Open dosprompt and navigate to directory where you want to generate client code 2. type: wsimport -keep http://localhost:8888/wss?wsdl Now your done. If everything went well you should have generated code in your direcotry which you can import to your project.
Example client
Below is a simple client program where our example WSS Web Service call is made from client code. Note that wsimport generated code is imported to this client code.
package org.vnetcon.wss.testclient; import org.vnetcon.wss.test.Employee; import org.vnetcon.wss.test.MyWebService; import org.vnetcon.wss.test.MyWebServiceService; public class WSSExampleClient { public static void main(String[] args){ try{ MyWebServiceService mwss = new MyWebServiceService(); MyWebService myws = mwss.getMyWebServicePort(); Employee emp = new Employee(); String s = myws.addEmployee(emp); System.out.println("WebService returned: " + s); }catch(Exception e){ e.printStackTrace(); } } }
Misc
About namespaces
When you create your web service you might have different packages on your code (e.g. mainpackage, dao package, util package etc.). When WSS generates wsdl and xsd=1 information to client all these classes are put to same namespace which is your webservice package. In general this means that you must not have classes with same name even they are in different packages.
About content
WSS uses regular expression when cleaning namespaces from xml. This might cause some unwanted behaviour if your data contains xml like text (e.g. <sfda:). If you need to send xml in your messages we suggest you create a wrapper class where you put your xml as binary data when making web service calls.
About coding
WSS generates for each method both parameters and return messages in wsdl. So you should always return something from your methods. We think that this is in general good to do so the caller will always get some kind of information about the method call and if it was successful.