Posted by oracled on January 30, 2009
Sometimes, the business requirement mandates that a SOAP request/response should maintain leading or trailing spaces that are present in a variable. By default, this does not happen. For example, you may expect ” ABC” or “ABC “, but you get “ABC”. The spaces are removed. Also, you may encounter issues if you use a binding mechanism like JAXB to marshal/ unmarshal xml fragments. This requires modifying the default marshalling or unmarshalling behavior. This is how you can still maintain any whitespaces:
Before marshalling call
marshaller.setPropertyMarshaller.JAXB_ENCODING, “UTF-8″)
which informs MarshallerImpl#createWriter(…) to create a UTF8XmlOutput instead of SAXOutput.
UTF8XmlOutput escapes line-break into “
”, which will be preserved when unmarshalling is performed by any xml parser.
Posted in Web Services | Tagged: SOAP, Web Services, xml | Leave a Comment »
Posted by oracled on September 12, 2008
There has been lot of confusion on which style of web service is used but It is always recommended to use a Document-style webservice to realize SOA.
RPC style web service:
These web services are easier to create and are usually synchronous in nature.
The responsibility of marshalling and de marshalling lays with SOAP engine, This leads to significant performance degradations when message passed to an operation is large or complex.
Since large sized messages lead to performance degradation in RPC style web service, they are not suitable for implementing coarse grained functionality requiring information messages having more number of fields.
However fine grained functionalities is better implemented by RPC style web services.
Document style web service:
Document style web services are more time consuming to create, as it is the onus of the service to create the required objects from XML document.
These web services can consume large sized documents without any significant drop in performance as there are no overheads of marshalling and de marshalling associated with SOAP engine.
Document style web services are ideal for representing coarse rained functionality as a single large sized document can be used to transfer information required to implement a business functionality.
Document style web service are primarily used for implementing asynchronous service.
RPC encoded web services are easiest create but offers least control in terms of usage of custom data types, validation and interoperability.
RPC encoded web service are slower in performance because of added overheads of marshalling and un marshalling.
Document literal web services are harder to create but scores higher in all the above metrics and this is one of the reasons WS –I basic profile encourages the usage of document literal web services.
Document style web services are better suited for defining custom data types as they are not constrained by the usage of a particular encoding style. Document –literal web services offers the best performance and RPC –encoded web services offers the least performance as in document-literal web service overheads of marshalling and un marshalling no longer lies with SOAP engine. In a document –literal web service alternative techniques such as SAX based parsing or custom data binding tool like XML beans, castor can be used.In case SOAP engine does not maintain state a document –literal web service can be used to carry state related data in the document. While using RPC –encoded web service often platform specific data structures are exposed in WSDL, which might not be supported by other platforms.
Posted in Web Services | Tagged: Document, RPC, SAX, SOAP, Web Services, wsdl | 1 Comment »