Download presentation
Presentation is loading. Please wait.
1
WS/XML Service Utility Library (WS and LEGO?)
Aleksander Slominski
2
XML Web Services Fusion
Transport (ex. HTTP) Security (XML dsig.) WS/XML Service RPC style Reliable Messaging Type Mapping Future? WS-Stuff
3
WS/LEGO Game Puzzle of WS-Standards? How to connect blocks?
XML Infoset Unlimited Number Of Connections As much as you need?! Build Your Own LEGO Set Keep Experimenting! LEGO comes from Danish words "LEg GOdt" meaning "play well". Ironically, in Latin the lego means "I study" or "I put together"
4
More Bricks, More Fun Reliable Messaging Layer RPC Layer DSig Layer
HTTP Transport SMTP Transport
5
Virtual Laboratory Toolset: Very Quick XML Service Creation
Allow Building Any Kind of XML Services From XML router to RMI runtime Encourage Experimentations Set of Small Modules Allow Easy Code Recombination XML Infoset as connecting glue
6
XSUL Layers Client Stack Server Stack Soap RPC Client
Invoke Java interface Type Mapping (XML Java) Soap RPC Service Use Java Object Invoker send XML document Processor receive XML document Pluggable Module SOAP/HTTP Invoker SOAP/HTTP Processor Globus / XML Digital sig. HTTP 1.x Client (HTTP 1.x POST/GET) HTTP 1.x Server (HTTP 1.x POST/GET) Common / Utility Legend: depends on XML Infoset
7
Modules Theory vs. Practice
8
HTTP Client private HttpClientConnectionManager connMgr = HttpClientConnectionManager.newInstance(); HttpClientRequest req = connMgr.connect(host, port, 4 * 60 * 1000); req.setRequestLine("POST", requestUri, "HTTP/1.0"); HttpClientResponse resp = req.sendHeaders(); OutputStream out = resp.getBodyOutputStream(); Writer utf8Writer = new Utf8Writer(out, 8*1024); … more
9
Invoker (SOAP 1.1 / HTTP) Soap11HttpDynamicInfosetInvoker invoker = new Soap11HttpDynamicInfosetInvoker() invoker.setLocation(" XmlElement request = builder.parseFragmentFromReader(new StringReader("<getN><arg>/hello</></>")); XmlElement response = invoker.invokeMessage(request);
10
SOAP RPC Client TypeHandlerRegistry typeMapping = XsdTypeHandlerRegistry.getInstance(); Soap11InvocationHandler handler = new Soap11InvocationHandler(invoker, typeMapping); XDirectoryService ref = (XDirectoryService) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] { XDirectoryService.class }, handler); XmlNode result = ref.getNode("/hello");
11
Client Stack RPC Client Invoker (SOAP 1.1 / HTTP) HTTP Client
Translates Java Interface into XML message Invoker (SOAP 1.1 / HTTP) XML Message is wrapped into SOAP 1.1 Envelope and serialized into transport output stream HTTP Client Actual sending happens here! Design Issues Can add new transport (new invoker)? Can inject XML processing layers? XML transformations: digital signatures?
12
Adding DSig Module To Client App
Soap11HttpDynamicInfosetInvoker invoker = new Soap11HttpDynamicInfosetInvoker() { public XmlDocument invokeXml(XmlDocument request) throws DynamicInfosetInvokerException { // WSRMHandler.getInstance().augmentRequest(request); XmlDocument signedRequest = GlobusCredSOAPEnvelopeSigner.getInstance().signSoapMessage(request); XmlDocument response = super.invokeXml(signedRequest); GlobusCredSOAPEnvelopeVerifier.getInstance().verifySoapMessage(response); // WSRMHandler.getInstance().processResponse(response); return response; } };
13
HTTP Server server = new HttpMiniServer(serverPort);
servlet= new MyServlet(); server.useServlet(servlet); server.startServer(); class MyServlet extends HttpMiniServlet { public void service(HttpServerRequest req, HttpServerResponse res) { … more }
14
Processor (SOAP 1.1 / HTTP)
Soap11HttpDynamicInfosetProcessor processor = new Soap11HttpDynamicInfosetProcessor() { public XmlElement processMessage(XmlElement message) { message.setParent(null); message.setName(message.getName()+"Response"); return message; } }; processor.setServerPort(port); processor.start(); Full SOAP Echo Service Impl!
15
SOAP RPC Server TypeHandlerRegistry typeMapping = XsdTypeHandlerRegistry.getInstance() XDirectoryService serviceLogic = new XDirectoryServiceImpl(); final Soap11ReflectionBasedService service = new Soap11ReflectionBasedService(serviceLogic, typeMapping); … Soap11HttpDynamicInfosetProcessor processor = new Soap11HttpDynamicInfosetProcessor() { public XmlElement processMessage(XmlElement requestMsg) XmlElement responseMsg = service.processMessage(requestMsg); return responseMsg; } };
16
Server Stack RPC Server Processor (SOAP 1.1 / HTTP) HTTP Server
User Java Reflection to convert XML message into Java invocation Processor (SOAP 1.1 / HTTP) Accept XML Message that is wrapped into SOAP 1.1 Envelope and unwrap it HTTP Server Listen for XML messages! Design Issues Can add new transport (new listening server) Can inject XML processing layers XML transformations: digital signatures and authorization checks?
17
Using DSig/Authz in App
Soap11HttpDynamicInfosetProcessor processor = new Soap11HttpDynamicInfosetProcessor() { public XmlDocument processSoap11Envelope(XmlElement envelope) { XmlDocument respDoc = null; SignatureInfo si = SOAPEnvelopeVerifier.getInstance().verifySoapMessage(envelope); if(!isAuthorized(si.getSubjectDn(), envelope)) { XmlDocument fault = Soap11Util.wrapBodyContent(Soap11Util.generateSoap11Fault( XmlConstants.NS_URI_SOAP11, "Client", "unathorized access")); respDoc = fault; } else { respDoc = super.processSoap11Envelope(envelope); } XmlDocument signedDoc = GlobusCredSOAPEnvelopeSigner.getInstance().signSoapMessage(respDoc); return signedDoc; };
18
WORK IN PROGRESS!!! OSS site (CVS hosted in SourceForge)
WikiWiki And Blog portal.extreme.indiana.edu:3456/xsul Place to Track Progress And Gather Feedback Bugzilla Your Feedback is Welcome Use Modules and Build Your Own Module
19
Conclusions Encourages experimentation Easy to add new modules
LEGO “experience” Easy to add new modules WS-RM, WSS4J, WSDL Invoker, … Better Than CORBA? Maybe … … but higher “playability” level Add what needed Piece by piece …
20
Addendum As More is Better …
21
Adding Caching to Improve DSig Performance
Soap11HttpDynamicInfosetProcessor processor = new Soap11HttpDynamicInfosetProcessor() { public XmlDocument processSoap11Envelope(XmlElement envelope) { XmlDocument respDoc = null; if( (respDoc = lookupCachedResponse(envelope) ) != null ) { { //NOTE: needs to check that request is idempotent and resource is not changed! return respDoc; } SignatureInfo si = GlobusCredSOAPEnvelopeVerifier.getInstance().verifySoapMessage(envelope); if(!isAuthorized(si.getSubjectDn(), envelope)) { XmlDocument fault = Soap11Util.wrapBodyContent(Soap11Util.generateSoap11Fault( XmlConstants.NS_URI_SOAP11, "Client", "unathorized access")); respDoc = fault; } else { XmlDocument respDoc = super.processSoap11Envelope(envelope); XmlDocument signedDoc = GlobusCredSOAPEnvelopeSigner.getInstance().signSoapMessage(respDoc); return signedDoc; };
22
DSig Steps Breakdown Client Server Generate SOAP call Sign Send … wait
Receive Verify DSig Pass result Receive SOAP Message Verify DSig Reflection Based Invocation Sign Send SOAP Message
23
RPC Client implementation details (Using Dynamic Proxy, without WSDL)
class Soap11InvocationHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] params) throws Throwable { String methodName = method.getName(); XmlElement request = builder.newFragment( methodName ); for (int i = 0; i < params.length; i++) { XmlElement param = registry.javaToXmlElement(params[i],null, "param"+i); request.addChild(param); } XmlElement response = invoker.invokeMessage(request); // map back to Java return type or Exception if S:Fault …
24
Client Side APIs WSDL/RMI
GlobalWeatherSoap gws = (GlobalWeatherSoap) WsdlNaming.lookup(" String s = gws.GetWeather(cityName, countryName) WSDL/Dynamic Proxy Stub GlobalWeatherSoap ref = (GlobalWeatherSoap) WsdlNaming.lookup(" GlobalWeatherSoap.class); WSDL/Dynamic Invocation Interface (DII) WsdlDynamicInfosetInvoker dii = WsdlNaming.lookup(" //NOTE: invoke() uses new JDK 1.5 multi args. “...” instead new Object[] {}); XmlElement result = dii.invoke("GetWeather", cityName, countryName); String cityName = result.string("cityName");
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.