1 / 24

WS/XML Service Utility Library (WS and LEGO?)

WS/XML Service Utility Library (WS and LEGO?). Aleksander Slominski. XML Web Services Fusion. Transport (ex. HTTP). Security (XML dsig.). WS/XML Service. RPC style. Reliable Messaging. Type Mapping. Future? WS-Stuff. Puzzle of WS-Standards? How to connect blocks? XML Infoset

dyanne
Download Presentation

WS/XML Service Utility Library (WS and LEGO?)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WS/XML Service Utility Library(WS and LEGO?) Aleksander Slominski

  2. XML Web Services Fusion Transport (ex. HTTP) Security (XML dsig.) WS/XMLService RPC style Reliable Messaging Type Mapping Future?WS-Stuff

  3. 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" WS/LEGO Game

  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 HttpClientConnectionManagerconnMgr = 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("http://localhost:"+port); XmlElement request = builder.parseFragmentFromReader(new StringReader("<getN><arg>/hello</></>")); XmlElement response = invoker.invokeMessage(request);

  10. SOAP RPC Client TypeHandlerRegistrytypeMapping= XsdTypeHandlerRegistry.getInstance(); Soap11InvocationHandlerhandler = 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 • 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 TypeHandlerRegistrytypeMapping= 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 • 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) • www.extreme.indiana.edu/xgws/xsul • www.extreme.indiana.edu/viewcvs/xsul • WikiWiki And Blog • portal.extreme.indiana.edu:3456/xsul • Place to Track Progress And Gather Feedback • Bugzilla • www.extreme.indiana.edu/bugs • Your Feedback is Welcome • Use Modules and Build Your Own Module

  19. Conclusions • Encourages experimentation • 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. Generate SOAP call Sign Send … wait Receive Verify DSig Pass result Receive SOAP Message Verify DSig Reflection Based Invocation Sign Send SOAP Message DSig Steps Breakdown Client Server

  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("http://www.example.com/weather?WSDL"); String s = gws.GetWeather(cityName, countryName) WSDL/Dynamic Proxy Stub GlobalWeatherSoap ref = (GlobalWeatherSoap) WsdlNaming.lookup("http://www.example.com/weather?WSDL“, GlobalWeatherSoap.class); String s = gws.GetWeather(cityName, countryName) WSDL/Dynamic Invocation Interface (DII) WsdlDynamicInfosetInvoker dii = WsdlNaming.lookup("http://www.example.com/weather?WSDL"); //NOTE: invoke() uses new JDK 1.5 multi args. “...” instead new Object[] {}); XmlElement result = dii.invoke("GetWeather", cityName, countryName); String cityName = result.string("cityName");

More Related