ws/xml service utility library (ws and lego?)

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

Upload: dyanne

Post on 25-Feb-2016

27 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: WS/XML Service Utility Library (WS and LEGO?)

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

Aleksander Slominski

Page 2: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

XML Web Services Fusion

WS/XMLService

Transport

(ex. HTTP)

Secu

rity

(XM

L dsig.

)

RPCstyle

ReliableMessaging

Type

Map

ping

Future?

WS-Stuff

Page 3: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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"

Page 4: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

More Bricks,More Fun

HTTP Transport SMTP Transport

RPC Layer DSig LayerReliable Messaging Layer

Page 5: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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

Page 6: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

Legend: depends on

Server StackClient Stack

XSUL Layers

HTTP 1.x Client(HTTP 1.x POST/GET)

Common / Utility

Invokersend XML document

SOAP/HTTP Invoker

Soap RPC ClientInvoke Java interface

XML Infoset

HTTP 1.x Server(HTTP 1.x POST/GET)

Processorreceive XML document

SOAP/HTTP Processor

Soap RPC ServiceUse Java Object

Globus / XMLDigital sig.

Type Mapping(XML Java)

PluggableModule

Page 7: WS/XML Service Utility Library (WS and LEGO?)

Modules

Theory vs. Practice

Page 8: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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

Page 9: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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);

Page 10: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

SOAP RPC ClientTypeHandlerRegistry 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");

Page 11: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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?

Page 12: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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; }};

Adding DSig Module To Client App

Page 13: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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 }}

Page 14: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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!

Page 15: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

SOAP RPC ServerTypeHandlerRegistry 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; }};

Page 16: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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?

Page 17: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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; }};

Using DSig/Authz in App

Page 18: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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

Page 19: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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 …

Page 20: WS/XML Service Utility Library (WS and LEGO?)

Addendum

As More is Better …

Page 21: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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; }};

Adding Caching to Improve DSig Performance

Page 22: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

DSig Steps Breakdown

• Generate SOAP call• Sign• Send

… wait • Receive• Verify DSig• Pass result

• Receive SOAP Message• Verify DSig• Reflection Based Invocation• Sign• Send SOAP Message

Client Server

Page 23: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

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 …}

Page 24: WS/XML Service Utility Library (WS and LEGO?)

Indiana University Extreme! Lab

WSDL/RMIGlobalWeatherSoap gws = (GlobalWeatherSoap)

WsdlNaming.lookup("http://www.example.com/weather?WSDL");String s = gws.GetWeather(cityName, countryName)

WSDL/Dynamic Proxy StubGlobalWeatherSoap 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");

Client Side APIs