SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
Reenabling SOAP using ERJaxWS
Markus Stoll
WebServices using SOAP
• Why SOAP? I do love REST!	

• "Simple Object Access Protocol"
SOAP
• Standardized	

• self defining
JavaWebServices
• known bugs (e. g. problems with https)	

• bugs with mapping of complex data types (uses Axis 1.x)	

• clumsy (Axis 1.x)	

• complicated (Axis 1.x)	

• slow (Axis 1.x)	

• consider it broken
Alternatives?
• AXIS 2
‣ POJO for services and
mapped data	

‣ service definitions in
separate files	

‣ rewritten from scratch	

!
• Jax WS
‣ POJO for services and
mapped data	

‣ all definitions using Java
Annotations	

‣ part of Standard Java!
ERJaxWS
• Jax WS RI Libraries	

• ERJaxWebServiceRequestHandler

adapting WORequest to Jax WS internal engine for handling servlet requests	

• NOT API compatible to JavaWebServices

• provide new SOAP service	

• provide SOAP service based on imported WSDL	

• call external SOAP service based on imported WSDL
Provide own SOAP service - 1
package your.app.ws;	
!
import javax.jws.WebService;	
!
@WebService	
!
public class Calculator {	
!
	 public int add(int a, int b)	
	 {	
	 	 return a + b;	
	 }	
}
Provide own SOAP service - 2
package your.app;	
!
import javax.xml.ws.Endpoint;	
!
import er.extensions.appserver.ERXApplication;	
import er.extensions.appserver.ws.ERJaxWebService;	
import er.extensions.appserver.ws.ERJaxWebServiceRequestHandler;	
!
public class Application extends ERXApplication {	
!
	 public static void main(String[] argv) {	
	 	 ERXApplication.main(argv, Application.class);	
	 }	
!
	 public Application() {	
	 	 setAllowsConcurrentRequestHandling(true);	 	 	
	 	
	 // do it the WONDER way	
	 ERJaxWebServiceRequestHandler wsHandler = new ERJaxWebServiceRequestHandler();	
	 wsHandler.registerWebService("Calculator", new ERJaxWebService<Calculator>(Calculator.class));	
	 this.registerRequestHandler(wsHandler, this.webServiceRequestHandlerKey());	
!
	 // create a standalone endpoint using Jax WS mechanisms	
	 Endpoint.publish("http://localhost:9999/ws/Calculator", new Calculator());	
!
	 }	
}
Provide own SOAP service - 3	

!
LIVE-DEMO
Provide SOAP service based on WSDL
// Import WSDL and create interface and classes for mapped data	
$ wsimport -keep -s Sources http://localhost:port/cgi-bin/WebObjects/WebService1.woa/ws/Calculator?wsdl	
!
// Import WSDL and create jar	
$ wsimport -clientjar Libraries/myservice.jar http://localhost:port/cgi-bin/WebObjects/WebService1.woa/ws/Calculator?wsdl	
!
!
!
// create CalculatorImplementation	
package your.app;	
!
import javax.jws.WebService;	
!
@WebService(endpointInterface = "your.app.Calculator")	
!
public class CalculatorImpl implements Calculator	
{	
!
	 @Override	
	 public int add(int arg0, int arg1) {	
	 	 return arg0 + arg1;	
	 }	
!
}
Provide SOAP service based on WSDL 	

!
LIVE-DEMO
Java Annotations / WebService
• @WebService	

 	

 	

 name, namespace, service interface	

• @BindingType	

 	

 	

 SOAP version	

• @SOAPBinding	

	

 	

 WSDL document styles	

• @WebMethod	

	

 	

 name, exclusion	

• @WebParam	

 	

 	

 name	

• @WebResult	

 	

 	

 name
Call a remote SOAP service
	 	 URL url = new URL("http://127.0.0.1:3333/cgi-bin/WebObjects/JaxServerTest.woa/ws/Hello?wsdl");	
!
	 	 // 1st argument service URI, refer to wsdl document above	
	 	 // 2nd argument is service name, refer to wsdl document above	
	 	 QName qname = new QName("http://app.your/", "HelloImplService");	
!
	 	 Service service = Service.create(url, qname);	
!
	 	 Hello remoteHello = service.getPort(Hello.class);	
!
	 	 remoteHello.hello("Jon Doe“);	
!
!
!
	 	 // BETTER: use imported interface	
!
	 	 HelloImplService service = new HelloImplService(url);	
!
	 	 Hello remoteHello = service.getPort(Hello.class);	
!
	 	 remoteHello.hello("Jon Doe“);	
!
Data mapping
• JAXB	

• all native Java data types	

• all "Bean" classes	

• custom type adaptors
custom data mapping - 1
!
!
!
public class WSStruct 	
{	
!
public String name;	
!
public int zip;	
!
public MyCustomDate myDate;	
	
!
public NSTimestamp datetime;	
}
custom data mapping - 2
@XmlType(name = "WSStructType", propOrder = {"name", "zip", "datetime"})	
@XmlAccessorType(value = XmlAccessType.PUBLIC_MEMBER)	
!
public class WSStruct 	
{	
@XmlElement	
public String name;	
@XmlAttribute	
public int zip;	
@XmlTransient	
public MyCustomDate myDate;	
	
!
public NSTimestamp datetime;	
}
custom data mapping - 3
@XmlType(name = "WSStructType", propOrder = {"name", "zip", "datetime"})	
@XmlAccessorType(value = XmlAccessType.PUBLIC_MEMBER)	
!
public class WSStruct 	
{	
@XmlElement	
public String name;	
@XmlAttribute	
public int zip;	
@XmlTransient	
public MyCustomDate myDate;	
	
@XmlJavaTypeAdapter(value = NSTimestampAdapter.class)	
public NSTimestamp datetime;	
}	
class NSTimestampAdapter extends XmlAdapter<String, NSTimestamp>	
{	
private final NSTimestampFormatter formatter = new NSTimestampFormatter();	
public NSTimestamp unmarshal(String v) throws Exception {	
return (NSTimestamp) formatter.parseObject(v);	
}	
public String marshal(NSTimestamp v) throws Exception {	
return formatter.format(v);	
}	
}
Data mapping
• Directly map EOs? NO!	

• might change	

• would need to adapt your EO templates	

• avoid marshalling your complete data tree
WebFaults
• WebServices exceptions can be defined as WebFaults	

• Beware: serialized info is not in Exception but in a referred
WebFault bean	

• stack traces possible 

switch off with property

com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace=false
WebFault sample
@WebFault(faultBean = "TestServiceFaultInfo")	
public class TestServiceException extends Exception 	
{	
	 private TestServiceFaultInfo code;	
	 	
	 public TestServiceException(String message, TestServiceFaultInfo info) {	
	 	 super(message);	
	 	 this.code = info;	
	 }	
	 	
	 public TestServiceFaultInfo getFaultInfo() {	
	 	 return code;	
	 }	
}	
!
public class TestServiceFaultInfo 	
{	
	 public String msg;	
!
	 public TestServiceFaultInfo() {	
	 }	
!
	 public TestServiceFaultInfo(String msg) {	
	 	 this.msg = msg;	
	 }	
}
Stateful Services
• @Stateful - makes no sense in WebObjects env	

• Jax WS injects a RequestContext into your Service object	

• gives access to WOContext and by that to your Session	

• creates WebObjects Cookies as usual	

• enable session persistence in your client proxy
Stateful Services	

!
LIVE-DEMO
Secure WebServices
• basic auth by common means	

• create your own custom ERJaxWebService	

• @SOAPMessageHandler



declare your own Jax WS message handlers

for example for handling signed SOAP messages
Troubleshooting
• Test-Tools	

• SoapUI	

• http://wsdlbrowser.com	

• test against original javax.xml.ws.Endpoint	

• compare imported WSDL vs. recreated WSDL
Resources
• https://github.com/markusstoll/wonder/tree/ERJaxWS	

• https://jax-ws.java.net	

• http://www.techferry.com/articles/jaxb-annotations.html
Q&A
Markus Stoll	

junidas GmbH	

markus.stoll@junidas.de

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in Scala
 
Clojure & Scala
Clojure & ScalaClojure & Scala
Clojure & Scala
 
Scala.js: Next generation front end development in Scala
Scala.js:  Next generation front end development in ScalaScala.js:  Next generation front end development in Scala
Scala.js: Next generation front end development in Scala
 
Introduction to rx java for android
Introduction to rx java for androidIntroduction to rx java for android
Introduction to rx java for android
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Arquitetando seu app Android com Jetpack
Arquitetando seu app Android com JetpackArquitetando seu app Android com Jetpack
Arquitetando seu app Android com Jetpack
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Functional Reactive Programming (CocoaHeads Bratislava)
Functional Reactive Programming (CocoaHeads Bratislava)Functional Reactive Programming (CocoaHeads Bratislava)
Functional Reactive Programming (CocoaHeads Bratislava)
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutes
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJava
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014
 
Scala.js - yet another what..?
Scala.js - yet another what..?Scala.js - yet another what..?
Scala.js - yet another what..?
 
Resilient Applications with Akka Persistence - Scaladays 2014
Resilient Applications with Akka Persistence - Scaladays 2014Resilient Applications with Akka Persistence - Scaladays 2014
Resilient Applications with Akka Persistence - Scaladays 2014
 
RxJava 2.0 介紹
RxJava 2.0 介紹RxJava 2.0 介紹
RxJava 2.0 介紹
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich Android
 
Using akka streams to access s3 objects
Using akka streams to access s3 objectsUsing akka streams to access s3 objects
Using akka streams to access s3 objects
 
Scaling an ELK stack at bol.com
Scaling an ELK stack at bol.comScaling an ELK stack at bol.com
Scaling an ELK stack at bol.com
 

Destaque

D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
WO Community
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
WO Community
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
WO Community
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache Cayenne
WO Community
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
WO Community
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
WO Community
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real World
WO Community
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnit
WO Community
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systems
WO Community
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on Windows
WO Community
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" pattern
WO Community
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
WO Community
 

Destaque (18)

D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
iOS for ERREST
iOS for ERRESTiOS for ERREST
iOS for ERREST
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache Cayenne
 
WOver
WOverWOver
WOver
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
 
Life outside WO
Life outside WOLife outside WO
Life outside WO
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real World
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnit
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systems
 
High availability
High availabilityHigh availability
High availability
 
KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on Windows
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" pattern
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
 

Semelhante a Reenabling SOAP using ERJaxWS

Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
b_kathir
 
Java Web services
Java Web servicesJava Web services
Java Web services
Sujit Kumar
 

Semelhante a Reenabling SOAP using ERJaxWS (20)

Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
Jax ws
Jax wsJax ws
Jax ws
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Java web services using JAX-WS
Java web services using JAX-WSJava web services using JAX-WS
Java web services using JAX-WS
 
Apache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault ToleranceApache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault Tolerance
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 
London Cassandra Meetup 10/23: Apache Cassandra at British Gas Connected Home...
London Cassandra Meetup 10/23: Apache Cassandra at British Gas Connected Home...London Cassandra Meetup 10/23: Apache Cassandra at British Gas Connected Home...
London Cassandra Meetup 10/23: Apache Cassandra at British Gas Connected Home...
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
Soa 12 jax ws-xml Java API for web services
Soa 12 jax ws-xml Java API for web servicesSoa 12 jax ws-xml Java API for web services
Soa 12 jax ws-xml Java API for web services
 
Java EE 7, what's in it for me?
Java EE 7, what's in it for me?Java EE 7, what's in it for me?
Java EE 7, what's in it for me?
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Not your Grandma's XQuery
Not your Grandma's XQueryNot your Grandma's XQuery
Not your Grandma's XQuery
 
Java Web services
Java Web servicesJava Web services
Java Web services
 
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
 

Mais de WO Community (12)

Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languages
 
WOdka
WOdkaWOdka
WOdka
 
ERGroupware
ERGroupwareERGroupware
ERGroupware
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRoller
 
CMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanCMS / BLOG and SnoWOman
CMS / BLOG and SnoWOman
 
Using GIT
Using GITUsing GIT
Using GIT
 
Persistent Session Storage
Persistent Session StoragePersistent Session Storage
Persistent Session Storage
 
Back2 future
Back2 futureBack2 future
Back2 future
 
WebObjects Optimization
WebObjects OptimizationWebObjects Optimization
WebObjects Optimization
 
Dynamic Elements
Dynamic ElementsDynamic Elements
Dynamic Elements
 
Practical ERSync
Practical ERSyncPractical ERSync
Practical ERSync
 
ERRest: the Basics
ERRest: the BasicsERRest: the Basics
ERRest: the Basics
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Último (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 

Reenabling SOAP using ERJaxWS

  • 1. Reenabling SOAP using ERJaxWS Markus Stoll
  • 2. WebServices using SOAP • Why SOAP? I do love REST! • "Simple Object Access Protocol"
  • 4. JavaWebServices • known bugs (e. g. problems with https) • bugs with mapping of complex data types (uses Axis 1.x) • clumsy (Axis 1.x) • complicated (Axis 1.x) • slow (Axis 1.x) • consider it broken
  • 5. Alternatives? • AXIS 2 ‣ POJO for services and mapped data ‣ service definitions in separate files ‣ rewritten from scratch ! • Jax WS ‣ POJO for services and mapped data ‣ all definitions using Java Annotations ‣ part of Standard Java!
  • 6. ERJaxWS • Jax WS RI Libraries • ERJaxWebServiceRequestHandler
 adapting WORequest to Jax WS internal engine for handling servlet requests • NOT API compatible to JavaWebServices
 • provide new SOAP service • provide SOAP service based on imported WSDL • call external SOAP service based on imported WSDL
  • 7. Provide own SOAP service - 1 package your.app.ws; ! import javax.jws.WebService; ! @WebService ! public class Calculator { ! public int add(int a, int b) { return a + b; } }
  • 8. Provide own SOAP service - 2 package your.app; ! import javax.xml.ws.Endpoint; ! import er.extensions.appserver.ERXApplication; import er.extensions.appserver.ws.ERJaxWebService; import er.extensions.appserver.ws.ERJaxWebServiceRequestHandler; ! public class Application extends ERXApplication { ! public static void main(String[] argv) { ERXApplication.main(argv, Application.class); } ! public Application() { setAllowsConcurrentRequestHandling(true); // do it the WONDER way ERJaxWebServiceRequestHandler wsHandler = new ERJaxWebServiceRequestHandler(); wsHandler.registerWebService("Calculator", new ERJaxWebService<Calculator>(Calculator.class)); this.registerRequestHandler(wsHandler, this.webServiceRequestHandlerKey()); ! // create a standalone endpoint using Jax WS mechanisms Endpoint.publish("http://localhost:9999/ws/Calculator", new Calculator()); ! } }
  • 9. Provide own SOAP service - 3 ! LIVE-DEMO
  • 10. Provide SOAP service based on WSDL // Import WSDL and create interface and classes for mapped data $ wsimport -keep -s Sources http://localhost:port/cgi-bin/WebObjects/WebService1.woa/ws/Calculator?wsdl ! // Import WSDL and create jar $ wsimport -clientjar Libraries/myservice.jar http://localhost:port/cgi-bin/WebObjects/WebService1.woa/ws/Calculator?wsdl ! ! ! // create CalculatorImplementation package your.app; ! import javax.jws.WebService; ! @WebService(endpointInterface = "your.app.Calculator") ! public class CalculatorImpl implements Calculator { ! @Override public int add(int arg0, int arg1) { return arg0 + arg1; } ! }
  • 11. Provide SOAP service based on WSDL ! LIVE-DEMO
  • 12. Java Annotations / WebService • @WebService name, namespace, service interface • @BindingType SOAP version • @SOAPBinding WSDL document styles • @WebMethod name, exclusion • @WebParam name • @WebResult name
  • 13. Call a remote SOAP service URL url = new URL("http://127.0.0.1:3333/cgi-bin/WebObjects/JaxServerTest.woa/ws/Hello?wsdl"); ! // 1st argument service URI, refer to wsdl document above // 2nd argument is service name, refer to wsdl document above QName qname = new QName("http://app.your/", "HelloImplService"); ! Service service = Service.create(url, qname); ! Hello remoteHello = service.getPort(Hello.class); ! remoteHello.hello("Jon Doe“); ! ! ! // BETTER: use imported interface ! HelloImplService service = new HelloImplService(url); ! Hello remoteHello = service.getPort(Hello.class); ! remoteHello.hello("Jon Doe“); !
  • 14. Data mapping • JAXB • all native Java data types • all "Bean" classes • custom type adaptors
  • 15. custom data mapping - 1 ! ! ! public class WSStruct { ! public String name; ! public int zip; ! public MyCustomDate myDate; ! public NSTimestamp datetime; }
  • 16. custom data mapping - 2 @XmlType(name = "WSStructType", propOrder = {"name", "zip", "datetime"}) @XmlAccessorType(value = XmlAccessType.PUBLIC_MEMBER) ! public class WSStruct { @XmlElement public String name; @XmlAttribute public int zip; @XmlTransient public MyCustomDate myDate; ! public NSTimestamp datetime; }
  • 17. custom data mapping - 3 @XmlType(name = "WSStructType", propOrder = {"name", "zip", "datetime"}) @XmlAccessorType(value = XmlAccessType.PUBLIC_MEMBER) ! public class WSStruct { @XmlElement public String name; @XmlAttribute public int zip; @XmlTransient public MyCustomDate myDate; @XmlJavaTypeAdapter(value = NSTimestampAdapter.class) public NSTimestamp datetime; } class NSTimestampAdapter extends XmlAdapter<String, NSTimestamp> { private final NSTimestampFormatter formatter = new NSTimestampFormatter(); public NSTimestamp unmarshal(String v) throws Exception { return (NSTimestamp) formatter.parseObject(v); } public String marshal(NSTimestamp v) throws Exception { return formatter.format(v); } }
  • 18. Data mapping • Directly map EOs? NO! • might change • would need to adapt your EO templates • avoid marshalling your complete data tree
  • 19. WebFaults • WebServices exceptions can be defined as WebFaults • Beware: serialized info is not in Exception but in a referred WebFault bean • stack traces possible 
 switch off with property
 com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace=false
  • 20. WebFault sample @WebFault(faultBean = "TestServiceFaultInfo") public class TestServiceException extends Exception { private TestServiceFaultInfo code; public TestServiceException(String message, TestServiceFaultInfo info) { super(message); this.code = info; } public TestServiceFaultInfo getFaultInfo() { return code; } } ! public class TestServiceFaultInfo { public String msg; ! public TestServiceFaultInfo() { } ! public TestServiceFaultInfo(String msg) { this.msg = msg; } }
  • 21. Stateful Services • @Stateful - makes no sense in WebObjects env • Jax WS injects a RequestContext into your Service object • gives access to WOContext and by that to your Session • creates WebObjects Cookies as usual • enable session persistence in your client proxy
  • 23. Secure WebServices • basic auth by common means • create your own custom ERJaxWebService • @SOAPMessageHandler
 
 declare your own Jax WS message handlers
 for example for handling signed SOAP messages
  • 24. Troubleshooting • Test-Tools • SoapUI • http://wsdlbrowser.com • test against original javax.xml.ws.Endpoint • compare imported WSDL vs. recreated WSDL