web services experiences

16
Web Services Web Services Experiences Experiences Machiel Jansen Vrije Universiteit (VU) Amsterdam

Upload: bina

Post on 06-Jan-2016

35 views

Category:

Documents


0 download

DESCRIPTION

Web Services Experiences. Machiel Jansen Vrije Universiteit (VU) Amsterdam. Building web services in Java. Prior Experience: none. Using NetBeans IDE: Making Webservives on the fly IDE generates stubs and hooks Provides container and servlets. Pro’s and cons- SUN. Pro’s: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Web Services Experiences

Web ServicesWeb ServicesExperiencesExperiences

Machiel Jansen

Vrije Universiteit (VU)Amsterdam

Page 2: Web Services Experiences

Building web services in JavaBuilding web services in Java

Prior Experience: none.Prior Experience: none.

Using NetBeans IDE:Using NetBeans IDE:

Making Webservives on the flyMaking Webservives on the fly

IDE generates stubs and hooksIDE generates stubs and hooks

Provides container and servletsProvides container and servlets

Page 3: Web Services Experiences

Pro’s and cons- SUNPro’s and cons- SUN

Pro’s:Pro’s:

No need to write WSDLNo need to write WSDL

Write application and ”publish” it as Write application and ”publish” it as webservice. webservice.

Cons:Cons:Sun webservices want the Sun Sun webservices want the Sun

Application Server – not in GT4.Application Server – not in GT4.

Page 4: Web Services Experiences

Apache AxisApache Axis

Axis can be easy.Axis can be easy.

Deploy your webservice rapidly (jws):Deploy your webservice rapidly (jws):

All public methods are availableAll public methods are available

But: Not configurableBut: Not configurable

Keep to global return Keep to global return datatypesdatatypes

Page 5: Web Services Experiences

Apache AxisApache Axis

Two approaches:Two approaches:

Start building application, or class library.Start building application, or class library.Let Axis generate WSDL Let Axis generate WSDL (?wsdl)(?wsdl)

Write WSDLWrite WSDL Use WSDL2Java to generate stubs (clients)Use WSDL2Java to generate stubs (clients) and hooks (services)and hooks (services)

Page 6: Web Services Experiences

Axis server sideAxis server side

Page 7: Web Services Experiences

More difficult side of WSMore difficult side of WS

Serialize your datastructures:Serialize your datastructures:

Easy when you stick to:Easy when you stick to:

Global types (int, double, String, array Global types (int, double, String, array etc.) etc.)

Java beans (set and get methods)Java beans (set and get methods)

Otherwise: write custom serializers.Otherwise: write custom serializers.

Page 8: Web Services Experiences

Wrapping existing Wrapping existing applicationapplication

Execute application from Java. Execute application from Java.

(use runTime)(use runTime)

Redirect the output.Redirect the output.

Deploy as webservice.Deploy as webservice.

Page 9: Web Services Experiences

Wrapping existing Wrapping existing applicationapplication

public int run(String cmd, Writer out) throws IOException {public int run(String cmd, Writer out) throws IOException {

RunTime r = Runtime.getRuntime(); RunTime r = Runtime.getRuntime();

Process p = r.exec(cmd);Process p = r.exec(cmd);

FileIO.copyFile(new FileIO.copyFile(new InputStreamReader(p.getInputStream( )), InputStreamReader(p.getInputStream( )), out, out, true);true);

try { p.waitFor( ); // wait for process to completetry { p.waitFor( ); // wait for process to complete

} catch (InterruptedException e) {} catch (InterruptedException e) {

return -1; }return -1; }

return p.exitValue( );return p.exitValue( );

}}

Page 10: Web Services Experiences

WS Clients – 3 typesWS Clients – 3 types

Stub based Stub based

(easy: use (easy: use WSDL2JavaWSDL2Java) )

Service endpoint is staticService endpoint is static

Dynamic proxyDynamic proxy

Service endpoint dynamically at runtimeService endpoint dynamically at runtime

Dynamic Invocation Interface (DII)Dynamic Invocation Interface (DII)

Discover services at runtime then invoke Discover services at runtime then invoke methodsmethods

Page 11: Web Services Experiences

Clients - DIIClients - DII

Axis user guide uses Call object Axis user guide uses Call object (DII) in examples.(DII) in examples.

WSRF and GT4 examples uses WSRF and GT4 examples uses stubs.stubs.

Page 12: Web Services Experiences

I used a DII client – should I used a DII client – should you?you?

DYNAMIC BUT HARDER THAN STUBSDYNAMIC BUT HARDER THAN STUBS

// Register your (un)serializer// Register your (un)serializer

call.registerTypeMapping(Result.class, qm, new call.registerTypeMapping(Result.class, qm, new org.apache.axis.encoding.ser.BeanSerializerFactory(Result.class, qm), org.apache.axis.encoding.ser.BeanSerializerFactory(Result.class, qm),

new new org.apache.axis.encoding.ser.BeanDeserializerFactory(Result.class, qm));org.apache.axis.encoding.ser.BeanDeserializerFactory(Result.class, qm));

call.registerTypeMapping(Result[].class, ar,call.registerTypeMapping(Result[].class, ar,

new org.apache.axis.encoding.ser.ArraySerializerFactory(),new org.apache.axis.encoding.ser.ArraySerializerFactory(),

new org.apache.axis.encoding.ser.ArrayDeserializerFactory());new org.apache.axis.encoding.ser.ArrayDeserializerFactory());

Page 13: Web Services Experiences

WSRF and GT4WSRF and GT4

Working on it.Working on it.

You can work with GT4: use the WSCore You can work with GT4: use the WSCore library.library.

http://www-128.ibm.com/developerworks/edu/gr-dw-gr-eclipseide-i.htmlhttp://www-128.ibm.com/developerworks/edu/gr-dw-gr-eclipseide-i.html

Note: GT4 WSRF is a little different from Apache WSRFNote: GT4 WSRF is a little different from Apache WSRF GT4 uses GAR files and JNDI deployment.GT4 uses GAR files and JNDI deployment.

Eclipse has a GT4 plugin…Eclipse has a GT4 plugin…

Page 14: Web Services Experiences

What we would have What we would have liked…liked…

INDEXER/SEARCHER

CLIENT

NODE NODE NODE

Use Resource aware WS’son different nodes to processindexes and search queries

WS on some nodes.Use SRB or local storage.user and system resources.

Page 15: Web Services Experiences

What we would like – part What we would like – part 22

Scenario taken from: Scenario taken from: Building a grid using Web services standards.

http://www-128.ibm.com/developerworks/edu/gr-dw-gr-movie1-i.html?S_TACT=105AGX07&S_CMP=HP

Page 16: Web Services Experiences

QuestionsQuestions

How do we make good use of GT4 – the WS enabled How do we make good use of GT4 – the WS enabled part?part?

How do we get access to GT4?How do we get access to GT4?How are WS’s (best) used in PoC infrastructure?How are WS’s (best) used in PoC infrastructure?Why use WS’s at all? Why use WS’s at all? Why can’t we use a WS outside the PoC? Does it matter?Why can’t we use a WS outside the PoC? Does it matter?

Technical hurdles still to take:Technical hurdles still to take: More experience in WSRFMore experience in WSRF Writing (de)serializers for custom datatypes.Writing (de)serializers for custom datatypes.