MTOM interoperability between Oracle app server and Sun wsit
A few months ago I wrote a couple of articles (WCF-ORA, ORA-WCF) about message transmission optimization Mechanic (MTOM) interoperability between Oracle Application Server and Microsoft Windows Communication Foundation (WCF ). most of the feedback I got from those posts was related with MTOM interoperability scenarios using other Web service technologies toolkits. based on that, I decided to post a few more demos that reflect MTOM interoperability scenarios for different vendors. specifically, this paper shows how to achieve MTOM interoperability between Oracle app server and Sun Web Service Interoperability Technology (wsit-Project tango ). believe it or not, I am sorry. NET developers; there is no. net code in this paper.
This post does not intend to provide a formal introduction to MTOM. suffice to say that after a few years and three predecessors 'specifications, MTOM has become the preferred standard for soap-encoded binary messaging optimization. MTOM relies on the XML optimized processing (xop) standard as the serialization mechanism to represent binary data as a mime/multipart related package. if you are interested in the importance of MTOM interoperability you might want to read my previous paper or this post by John evdemon.
Sun wsit and MTOM
wsit is part of Project Metro which is the Web Services Stack from Sun Microsystems. specifically, wsit is the component of Project Metro that implements some of the most important WS-* protocols emphasizing in interoperability with Microsoft WCF. needless to say, that wsit also interoperates really well with other Web Services technologies including Oracle app server. at the moment wsit implements some of the most important WS-* protocols for areas such as security, reliability, transactions and messaging optimization (. k. a mtom ). the typical scenarios for applying MTOM are Web services that handles binary data like byte [] as part of their contract. the following code used strates A wsit service that can be highly optimized with the use of MTOM.
@ WebService () public class filews { @ webmethod (Action = "printfilecontents ") Public int printfilecontents (byte [] buffer) {< br> for (INT I = 0; I <= buffer. length-1; I ++) system. out. println (buffer [I]); return buffer. length; }< BR >} |
Now we need to configure the service policy in order to optimize the message exchange using MTOM. the trick here, in order to achieve interoperability with Oracle app server, is to remove the default wsit WS-Addressing settings. this is due to the fact that Oracle app server and Sun wsit implement different versions of WS-Addressing. the change is not required if the client side supports MTOM with WS-Addressing 1.0 like WCF does. also, if you are using a development ide such as netbeans there is no need to manually configure the policy handle T for removing the use of WS-Addressing; instead you can the Web service configuration editor which provides a nice interface for processing the different WS-* protocols for a particle service.
<Definitions Xmlns = "http://schemas.xmlsoap.org/wsdl" Xmlns: WSDL = "http://schemas.xmlsoap.org/wsdl" Xmlns: XSD = "http://www.w3.org/2001/XMLSchema" Xmlns: Soap = "http://schemas.xmlsoap.org/wsdl/soap/" name = "filewsservice" targetnamespace = "http: // mtomws/" xmlns: TNS = "http: // mtomws/" xmlns: WSP = "http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns: wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns: wsaws = "http://www.w3.org/2005/08/addressing" xmlns: wsoma = "http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" > WSDL components .... <WSP: Policy wsu: Id = "filewsportbindingpolicy"> <WSP: exactlyone> <WSP: All> <! -- <Wsaws: usingaddressing xmlns: wsaws = "http://www.w3.org/2006/05/addressing/wsdl"/> --> <Wsoma: optimizedmimeserialization/> </WSP: All> </WSP: exactlyone> </WSP: Policy> </Definitions> |
Now we are ready to deploy the service, for the purposes of this demo we used Sun glassfish.
Oracle app server and MTOM
Now it's time to implement an Oracle client for the wsit service created on the previous section. the first natural step is to generate the proxy using the Web Service proxy wizard has ded in jdeveloper or the corresponding command-line tool. in order to interface with WCF using MTOM, the client code shoshould set the mtom_support property to "true" either programmatically or using the configuration file. the following code shows a sample client that interacts with the WCF Service created in the previous section
Public static void test () { Try { Filetransmitter transmitter = new filetransmitter (); Byte [] buffer = transmitter. getimg ("C: \ temp \ images \ p1.jpg "); Filewsportclient binding = new filewsportclient (); Filews proxy = binding. getport (); (Oraclestub) proxy). _ setproperty (stub. endpoint_address_property, service URL ); (Oraclestub) proxy). _ setproperty (clientconstants. mtom_support, true ); Int result = proxy. printfilecontents (buffer ); System. Out. println (result ); } Catch (exception ex) { System. Out. println (ex. getmessage ()); } } |
Messages messages
After hosting the wsit service in Sun glassfish and running the Oracle client the following message sequence is produced
Post, mtomservices, filewsservice, HTTP, 1.1 HOST: localhost: 8082 Connection: keep-alive, te Te: trailers, deflate, Gzip, compress User-Agent: Oracle httpclient version 10 h Soapaction: "printfilecontents" Accept-encoding: gzip, X-gzip, compress, X-compress Content-Type: multipart/related; type = "application/xop + XML"; boundary = "---- = _ part_0_13050435.1185038715262"; Start = "<release> "; start-Info = "text/XML; charset = UTF-8" Content-Length: 12849 ------ = _ Part_0_13050435.1185038715262 Content-Type: Application/xop + XML; charset = UTF-8; type = "text/XML; charset = UTF-8" Content-transfer-encoding: 8bit Content-ID: <97b2fe36f9184df3a6fa8792abd9a00c> <? XML version = "1.0" encoding = "UTF-8"?> <Env: envelope xmlns: ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: XSD = "http://www.w3.org/2001/XMLSchema" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: ns0 = "http: // mtomws/"> <env: Body> <ns0: printfilecontents> <arg0><Xop: Include xmlns: xop = "http://www.w3.org/2004/08/xop/include" href = "CID: b9abc481c3664db8b0b7f842d0886c30"/></Arg0> </ns0: printfilecontents> </ENV: Body> </ENV: envelope> ------ = _ Part_0_13050435.1185038715262 Content-Type: Application/octet-stream Content-transfer-encoding: Binary Content-ID: <b9abc481c3664db8b0b7f842d0886c30> |
SOAP request produced by the Oracle client
Content-ID: <rootpart * 74f72fe4-510e-48de-a29a-38896f03901d@example.jaxws.sun.com> Content-Type: Application/xop + XML; charset = UTF-8; type = "text/XML" Content-transfer-encoding: Binary <? XML version = "1.0"?> <S: envelope xmlns: S = "http://schemas.xmlsoap.org/soap/envelope/"> <s: Body> <NS2: printfilecontentsresponse xmlns: int32 = "http: // mtomws/"> <return> 12000 </return> </NS2: printfilecontentsresponse> </S: Body> </S: envelope> |
Soap response produced by the sun wsit Service
You can notice that the byte [] in the Request Message its been optimized using MTOM and xop.
In the next weeks I will be posting more demos about WS-* protocols interoperability between some of the top Web Services Technologies in the market.
Published Friday, July 27,200 am by gsusx
Filed under: SOA, Oracle, web services, Sun wsit, J2EE, Web Services Interoperability