Apr 12 2005

Which encoding is better for webservices?

Category: .architectureAmit Bahree @ 6:25 pm

There are two options when it comes to encoding in the context of webservices, e.g. .NET and Weblogic use document literal encoding while IBM and other vendors (Java) use RPC encoding. What is the difference and which one is better for which scenarios? Also, how easy is it to switch between the two?

Well for those new to webservices, there are two options that you can choose when encoding your wsdl messages.

So, how do they look like. If I “borrow” and example from Sun, if below was your original class in Java:


package com.examples.xmlstring;
import java.rmi.Remote;

import java.rmi.RemoteException;

public interface IStringService extends Remote {

    public String sayXMLHello(String xml)
        throws RemoteException;
    }

The rpc encoding for that looks like this:

<binding name="IStringServiceBinding" type="tns:IStringService">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc"/>
    <operation name="sayXMLHello">
        <soap:operation soapaction=""/>
            <input>
               
<soap:body encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="http://www.examples.com/wsdl/StringService"/>
            </input>
            <output>
               
<soap:body encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="http://www.examples.com/wsdl/StringService"/>
            </output>
    </operation>
</binding>

And the document encoding looks like:

<?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:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns0="http://www.examples.com/types">
        <env:body>
            <ns0:sayxmlhello>
                <string_1>Hello World</string_1>

            </ns0:sayxmlhello>

        </env:body>
</env:envelope>

I think in the end the real thing to keep in perspective is who and what will be consuming this? If your clients are primarily MS-based (COM/.NET) then you are better off with literal encoding, on the other hand if its primarily J2EE client then you are better off with the other one. But, more interestingly if you don’t know (or in other words can be both), then which road to take?

Share
Similar posts to check out:
  • April 18, 2012 -- Concurrency and CEP (0)
    The sooner we all understand the Concurrency ≠ CEP (Complex Event Processing), the better the world will be! CEP is generally used when we implement real-time systems (of course that is not the only area where CEP is used). Real-time does not mean concurrent or for that matter high-performing system. Of course there are correlations, but at the same time they are fundamentally different paradigms....
  • March 17, 2012 -- What I am working on today? Optimisation Algorithms (0)
    I often get the question – a what am I working on today? Some of the things I can’t discuss in an open forum, but some I can. Those that I can, I thought it was best to share via my blog and do quick small posts on it. Will this become a new series? Well time will tell – depends on how much bandwidth I will have. This weekend, I am researching Optimisation Algorithms – both Deterministic and Probabilistic. Specifically interested in Swarm Intelligence (which are a type of Monte Carlo algorithm)...
  • June 16, 2011 -- Occasionally Connected Architecture (0)
    When implementing an occasionally connected architecture for a solution, there are three fundamental requirements: Part of the overall solution, some smart client is deployed and installed on the desktop and a web only approach is not possible. The main rational being that a smart client can work in a disconnected mode which of course with a web application is not possible. Underlying infrastructure needs to be in place to support this. Infrastructure is not specifically networks and ser...

Tags:

Leave a Reply

*

Get Adobe Flash player