Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 6962: Server-side Design and Programming Web Services.

Similar presentations


Presentation on theme: "CSCI 6962: Server-side Design and Programming Web Services."— Presentation transcript:

1 CSCI 6962: Server-side Design and Programming Web Services

2 Remote Function Calls Function calls: –Caller passes parameters to function –Function returns value Advantages –Much cleaner syntax than passing parameters in request public int add (int a, int b) { return a + b; } Function public int whatever () { … x = 7; y = 5; z = add(x, y); … } Call

3 Remote Function Calls Key idea: Function call should still work even if caller, callee at different locations in network Example: RMI for Java (Remote Method Invocation) –Passed “serializable” objects with built-in methods to convert to/from string public int add (int a, int b) { return a + b; } public int whatever () { … z = add(x, y); … } Call over network Consumer Producer

4 Remote Function Calls Problem: Passing complex parameters over network –Information sent as strings over network public int add (int a, int b) { return a + b; } public void whatever () { x = 7; y = 5; z = add(x, y); } Easy to pass 5 and 7 as strings public void storeCart (ShoppingCart c) { … } public void whatever () { storeCart(myCart) } What does a “ShoppingCart” look like when sent over network?

5 Remote Method Call Problems Requires client and server to use same language –Should be more flexible Remote calls often seen as attacks by firewalls –Html preferable for sending information int add (int a, int b) { return a + b; } whatever () { cin >> x >> y; z = add(x, y); } Method in Java Function in C

6 Web Services Solution Simulate remote method calls with existing client/server structure –Method call = request –Return value = response –Not considered attack by firewall –Also supports https: for secure transmissions Common standards: –SOAP (Simple Object Access Protocol) –REST (Representational State Transfer)

7 Web Services Solution Simulate remote method calls with existing client/server structure –Method call = request –Return value = response –Not considered attack by firewall –Also supports https: for secure transmissions Format of calls based on XML –Common language specification for internet

8 SOAP Format of calls based on XML –Common language specification for internet –Generally requires proxy classes in client to translate objects into XML format JAX-WS libraries for Java WCF (Windows Communication Foundation) libraries in ASP Cliente Client code Proxy classes Servere Web Service method SOAP

9 XML Format Simple example: web service to compute k = i + j

10 REST Services Alternative: REST (Representational State Transfer) –Information transmitted in JSON (JavaScript Object Notation) –Can be directly consumed by JavaScript Good if AJAX used

11 Creating a Web Service in NetBeans Reference: https://netbeans.org/kb/docs/websvc/jax-ws.html#extschema https://netbeans.org/kb/docs/websvc/jax-ws.html#extschema Will probably need to modify configuration files of IDE/Glassfish Create new web site project Add new web service to the project –Must have a package in URL format (fake address of org.me.greeter) Added to project as web service node

12 Adding a Web Service Operation Right click service node and choose Add Operation Will be prompted for: –Return type –Types and names of parameters New operation added as node to project

13 Adding a Web Service Operation Note that NetBeans can handle complex parameter classes –Must implement serializable interface

14 Adding a Web Service Operation Source code will now contain “skeleton” of method Modify as necessary

15 Testing a Web Service Operation Right click project and deploy Right click web service and choose Test Web Service Will get “test window” for each method to enter parameters Can view return value and underlying XML

16 Creating a Web Client Create as Java application Add new Web Service Client –Will be prompted for the web service in projects New (empty) method automatically generated in source packages

17 Creating a Web Client Expand Web Service References –Will have nodes for all operations in the corresponding web service Drag node of operation to call into the class

18 Creating a Web Client Add code (probably in main) to call that method with desired parameters The method then invokes the corresponding method in the web service


Download ppt "CSCI 6962: Server-side Design and Programming Web Services."

Similar presentations


Ads by Google