JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi...

25
JAVA CORE SERVICE CLIENT JAVA CORE SERVICE CLIENT & TOM.JAVA Mihai Cădariu yatb.mitza.net

Transcript of JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi...

Page 1: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

JAVA CORE SERVICE CLIENTJAVA CORE SERVICE CLIENT&TOM.JAVA

Mihai Cădariu yatb.mitza.net

Page 2: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

About Mihai

Principal Consultant, SDL WCM, San Jose, USAJ i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NLPreviously Java developer

Yet Another Tridion Blog (yatb mitza net)Yet Another Tridion Blog (yatb.mitza.net)

Page 3: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

AgendaAgenda

Java Core Service Client Proxy Generation

TOM.Java JNI

JAXB Custom Bindings Bindings and Endpoints

jni4net ProxyGeng p

Known Limitations Demo

y Demo

Demo

Page 4: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Java Core Service Client

Page 5: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Proxy GenerationProxy Generation

Core Service is a Web Communication Foundation (WCF) web service

Proxy (client) classes for each Core Service data model

.NET client proxies OOTB or trivial to generate in Visual StudioVisual Studio

What about Java?

Page 6: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Which Java Framework?Which Java Framework?

f Plethora of Java web service tools available WSIT (Web Services Interoperability Technologies) JAX-WS (Java API for XML Web Services) JAX-RS (Java API for RESTful Web Services) Apache Axis Apache CXF Metro …

Less is more Simple, standard, out-of-the-box, free?

Page 7: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

wsimport.exewsimport.exe

Part of and shipped with the JDK Command line Simple to use P i t t WSDL (W b S i D fi iti L ) Point to WSDL (Web Service Definition Language)

location and generate proxiesi t htt //l lh t/ b i /C S i 2012 ? dlwsimport.exe http://localhost/webservices/CoreService2012.svc?wsdl

Page 8: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

DemoDemo

Generation of simplest Java Core Service client

Page 9: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Custom JAXB BindingsCustom JAXB Bindings

A A f M JAXB – Java Architecture for XML Binding Do not generate the JAXB element Provide proper conversion for Date objects

<jxb:globalBindings generateElementProperty="false"><jxb:javaType name="java.util.Date" xmlType="xs:dateTime"

parseMethod="mitza.coreservice.util.Utils.parseStringToDate“printMethod="mitza.coreservice.util.Utils.parseDateToString" />p p g

</jxb:globalBindings>

Use custom bindings XMLwsimport.exe -b custombindings.xml

http://localhost/webservices/CoreService2012.svc?wsdl

Page 10: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

DemoDemo

Generate client with custom bindings

Page 11: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Full Java Core Service ClientFull Java Core Service Client

CoreServiceFactory class Provides authentication (BasicHttp)( p)

CoreServiceFactory.setDefault(“user", "password");

Possible to point to specific Core Service URLp pCoreServiceFactory.setDefault("http://staging.cme.example.com");

Provides easy access to different endpoints Provides easy access to different endpointsCoreServiceFactory.getBasicHttpClient();CoreServiceFactory.getBatchBasicHttpClient();CoreServiceFactory.getStreamDownloadBasicHttpClientClient();CoreServiceFactory.getStreamUploadBasicHttpClientClient();

Page 12: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Full Java Core Service ClientFull Java Core Service Client

Available online (link) core-service-client-2011sp1hr1.jar

i li 2013 j core-service-client-2013ga.jar

http://yatb mitza net/2013/04/a-java-core-service-client-for-sdl html http://yatb.mitza.net/2013/04/a java core service client for sdl.html

http://yatb.mitza.net/2013/04/streamlining-core-service-java-client.html

Page 13: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

DemoDemo

Full Java Core Service Client

Page 14: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Known LimitationsKnown Limitations

WsHttp endpoint not supported Metro WS has a potential implementation (incomplete) NTLM authentication not implemented

BasicHttp authentication not working on server ( t l )(remote only)

Page 15: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

ResourcesResources

http://yatb.mitza.net/search?q=java+core+service https://code.google.com/p/yet-another-tridion-blog// / / https://wsit.java.net https://metro java net https://metro.java.net

Page 16: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

TOM.Java

Page 17: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Still TOM.NET… only inside JavaStill TOM.NET… only inside Java

O M ( OM) N A Tridion Object Model (TOM) .NET API Execute .NET inside Java Virtual Machine (JVM) Java Native Interface (JNI) Intra-process execution (JVM inside CLR or CLR p (

inside JVM) CLR – Common Language Runtime CLR Common Language Runtime Proxy classes needed on the “other” side Real objects have “proxy” counterparts Real objects have proxy counterparts Need Java proxy classes from .NET classes

Page 18: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

jni4netjni4net

jni4net.sourceforge.net “bridge between Java and .NET” Thank you, Pavel Šavara!

Page 19: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

ProxyGenProxyGen

Generates Java proxies from .NET DLL Types mapping (Java->.NET and .NET->Java)yp pp g ( ) Primitives mapping – OOTB C ll ti i ibl th h Collection mapping – possible through wrappers Generics – not implemented TOM.NET uses generic collections

public IList<ComponentPresentation> ComponentPresentations { get; }

Page 20: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Build Your Own ProxyGenBuild Your Own ProxyGen

Thank you, Open Source! Added (limited) generics support to ProxyGen( ) g pp y

https://groups.google.com/forum/#!topic/jni4net/FZwTetghskA

https://jni4net.googlecode.com/svn/branches/0-8-generics/

Able to generate full TOM.NET API to Java Proxies

Page 21: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Collection MappingCollection Mapping

Java C#

java.util.List<E> System.Collections.Generic.IList<T>

java.util.Map<K, V> System.Collections.Generic.IDictionary<K, V>

java.util.Set<E> System.Collections.Generic.ISet<T>

java.util.Collection<E> System.Collections.Generic.ICollection<T>

java.lang.Iterable<E> System.Collections.Generic.IEnumerable<T>java.lang.Iterable<E> System.Collections.Generic.IEnumerable<T>

Page 22: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

ResourcesResources

// / / / http://yatb.mitza.net/2012/11/tomjava-now-with-generics-support.html

https://code.google.com/p/yet-another-tridion-blog/source/browse/trunk/Tom.Javablog/source/browse/trunk/Tom.Java

http://jni4net.sourceforge.net

https://groups.google.com/forum/#!forum/jni4net

Page 23: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

DemoDemo

Page 24: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

Questions & AnswersQuestions & Answers

?

Page 25: JAVA CORE SERVICE CLIENT TOM...About Mihai Principal Consultant, SDL WCM, San Jose, USA J i d T idi i 2005 A d NLJoined Tridion in 2005, Amsterdam, NL Previously Java developer Agenda

That’s all, folks!That s all, folks!