You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Aleksander Slominski <as...@cs.indiana.edu> on 2000/10/03 06:21:28 UTC

soap styles (or on the fly MS and IBM SOAP)

George I Matkovits wrote:

> Hello Nathan,
> Thank you for the comments and just a quick reply. I will do more thinking later off line.
> 1.) Multiple calls: just in case I missed an entry point. The 'problem' with object programming is that it can be put together in many, many ways and I would like to have the properties defined  ASAP. Eventually I would like to use them even for code compatibility 'on the fly' reconfiguration, like 'MS compatibility' or 'Standard Soap Compatibility' depending on what server you want to talk to from your Java Client.

i have implemented something like this and it is called SoapStyle. you need only to worry about serialization format to be either MS or IBM SOAP compatible and to make sure that deserializer can handle both. SoapStyle is the class encapsulates SOAP "style" attributes:


/**
 * Define attributes for diffrent SOAP envelope styles.
 *
 * @author  Aleksander Slominski
 */

public class SoapStyle {
  public final static SoapStyle IBMSOAP = new SoapStyle(true, true, true);
  public final static SoapStyle MSSOAP = new SoapStyle(false, true, false);
  public final static SoapStyle SOAP11 = MSSOAP;
  public final static SoapStyle SOAP10 = MSSOAP;

  private SoapStyle(boolean deepSer, boolean useNs, boolean xsiTyped);

 /**
   * Make deep serialization (all references are expanded and serialzied).
   */
  public boolean getDeepSer();
  /**
   * Include namespaces for serialized element.
   */
  public boolean getUseNs();

  /**
   * Add xsi:type for each serialized element.
   */
  public boolean getXsiTyped();

}

and SoapStyle is passed in context object to soap serializer that will create different output depending on soap style attributes, ex:
....
      if(root && style.getUseNs()) {
        QName qtype = ctx.queryElementType(beanType);
        if(qtype == null) {
          throw new SoapException("Missing schema type mapping for "+beanType);
        }
        String uri = qtype.getNamespaceURI();
        boolean needNsDecl =  ctx.getPrefix(uri) == null;
        nsPrefix = ctx.pushNs(uri, true);
        out.write('<');
        out.write(nsPrefix);
        out.write(':');
        elName = qtype.getLocalPart();
        out.write(elName);
        if(needNsDecl) {
          out.write(" xmlns:");
          out.write(nsPrefix);
          out.write("='");
          out.write(uri);
          out.write('\'');
        }
      } else {
        throw new SoapException("Serialization of unnamed element not allowed (must be root and namespaced)");
      }
    } else {
      out.write('<');
      out.write(elName);
      if(style.getXsiTyped()) {
        writeXsiType(ctx, out, beanType, true);
      }
    }
...

hope it can be useful,

alek
--
Aleksander Slominski, LH 316, IU, http://www.extreme.indiana.edu/~aslom
As I look afar I see neither cherry Nor tinted leaves Just a modest hut
on the coast In the dusk of Autumn nightfall - Fujiwara no Teika (1162-1241)



Re: soap styles (or on the fly MS and IBM SOAP)

Posted by George I Matkovits <ma...@uswest.net>.
I am going to try this ASAP, like in the morning. Could you, please post the complete Apache Source tree with your mods included. This would make any tests much easier.
Thank you - George
p.s. I will try to drive it from a Soap.properties file. This way clients could be the same for all styles.

Aleksander Slominski wrote:

> George I Matkovits wrote:
>
> > Hello Nathan,
> > Thank you for the comments and just a quick reply. I will do more thinking later off line.
> > 1.) Multiple calls: just in case I missed an entry point. The 'problem' with object programming is that it can be put together in many, many ways and I would like to have the properties defined  ASAP. Eventually I would like to use them even for code compatibility 'on the fly' reconfiguration, like 'MS compatibility' or 'Standard Soap Compatibility' depending on what server you want to talk to from your Java Client.
>
> i have implemented something like this and it is called SoapStyle. you need only to worry about serialization format to be either MS or IBM SOAP compatible and to make sure that deserializer can handle both. SoapStyle is the class encapsulates SOAP "style" attributes:
>
> /**
>  * Define attributes for diffrent SOAP envelope styles.
>  *
>  * @author  Aleksander Slominski
>  */
>
> public class SoapStyle {
>   public final static SoapStyle IBMSOAP = new SoapStyle(true, true, true);
>   public final static SoapStyle MSSOAP = new SoapStyle(false, true, false);
>   public final static SoapStyle SOAP11 = MSSOAP;
>   public final static SoapStyle SOAP10 = MSSOAP;
>
>   private SoapStyle(boolean deepSer, boolean useNs, boolean xsiTyped);
>
>  /**
>    * Make deep serialization (all references are expanded and serialzied).
>    */
>   public boolean getDeepSer();
>   /**
>    * Include namespaces for serialized element.
>    */
>   public boolean getUseNs();
>
>   /**
>    * Add xsi:type for each serialized element.
>    */
>   public boolean getXsiTyped();
>
> }
>
> and SoapStyle is passed in context object to soap serializer that will create different output depending on soap style attributes, ex:
> ....
>       if(root && style.getUseNs()) {
>         QName qtype = ctx.queryElementType(beanType);
>         if(qtype == null) {
>           throw new SoapException("Missing schema type mapping for "+beanType);
>         }
>         String uri = qtype.getNamespaceURI();
>         boolean needNsDecl =  ctx.getPrefix(uri) == null;
>         nsPrefix = ctx.pushNs(uri, true);
>         out.write('<');
>         out.write(nsPrefix);
>         out.write(':');
>         elName = qtype.getLocalPart();
>         out.write(elName);
>         if(needNsDecl) {
>           out.write(" xmlns:");
>           out.write(nsPrefix);
>           out.write("='");
>           out.write(uri);
>           out.write('\'');
>         }
>       } else {
>         throw new SoapException("Serialization of unnamed element not allowed (must be root and namespaced)");
>       }
>     } else {
>       out.write('<');
>       out.write(elName);
>       if(style.getXsiTyped()) {
>         writeXsiType(ctx, out, beanType, true);
>       }
>     }
> ...
>
> hope it can be useful,
>
> alek
> --
> Aleksander Slominski, LH 316, IU, http://www.extreme.indiana.edu/~aslom
> As I look afar I see neither cherry Nor tinted leaves Just a modest hut
> on the coast In the dusk of Autumn nightfall - Fujiwara no Teika (1162-1241)


Re: soap styles (or on the fly MS and IBM SOAP)

Posted by George I Matkovits <ma...@uswest.net>.
I am going to try this ASAP, like in the morning. Could you, please post the complete Apache Source tree with your mods included. This would make any tests much easier.
Thank you - George
p.s. I will try to drive it from a Soap.properties file. This way clients could be the same for all styles.

Aleksander Slominski wrote:

> George I Matkovits wrote:
>
> > Hello Nathan,
> > Thank you for the comments and just a quick reply. I will do more thinking later off line.
> > 1.) Multiple calls: just in case I missed an entry point. The 'problem' with object programming is that it can be put together in many, many ways and I would like to have the properties defined  ASAP. Eventually I would like to use them even for code compatibility 'on the fly' reconfiguration, like 'MS compatibility' or 'Standard Soap Compatibility' depending on what server you want to talk to from your Java Client.
>
> i have implemented something like this and it is called SoapStyle. you need only to worry about serialization format to be either MS or IBM SOAP compatible and to make sure that deserializer can handle both. SoapStyle is the class encapsulates SOAP "style" attributes:
>
> /**
>  * Define attributes for diffrent SOAP envelope styles.
>  *
>  * @author  Aleksander Slominski
>  */
>
> public class SoapStyle {
>   public final static SoapStyle IBMSOAP = new SoapStyle(true, true, true);
>   public final static SoapStyle MSSOAP = new SoapStyle(false, true, false);
>   public final static SoapStyle SOAP11 = MSSOAP;
>   public final static SoapStyle SOAP10 = MSSOAP;
>
>   private SoapStyle(boolean deepSer, boolean useNs, boolean xsiTyped);
>
>  /**
>    * Make deep serialization (all references are expanded and serialzied).
>    */
>   public boolean getDeepSer();
>   /**
>    * Include namespaces for serialized element.
>    */
>   public boolean getUseNs();
>
>   /**
>    * Add xsi:type for each serialized element.
>    */
>   public boolean getXsiTyped();
>
> }
>
> and SoapStyle is passed in context object to soap serializer that will create different output depending on soap style attributes, ex:
> ....
>       if(root && style.getUseNs()) {
>         QName qtype = ctx.queryElementType(beanType);
>         if(qtype == null) {
>           throw new SoapException("Missing schema type mapping for "+beanType);
>         }
>         String uri = qtype.getNamespaceURI();
>         boolean needNsDecl =  ctx.getPrefix(uri) == null;
>         nsPrefix = ctx.pushNs(uri, true);
>         out.write('<');
>         out.write(nsPrefix);
>         out.write(':');
>         elName = qtype.getLocalPart();
>         out.write(elName);
>         if(needNsDecl) {
>           out.write(" xmlns:");
>           out.write(nsPrefix);
>           out.write("='");
>           out.write(uri);
>           out.write('\'');
>         }
>       } else {
>         throw new SoapException("Serialization of unnamed element not allowed (must be root and namespaced)");
>       }
>     } else {
>       out.write('<');
>       out.write(elName);
>       if(style.getXsiTyped()) {
>         writeXsiType(ctx, out, beanType, true);
>       }
>     }
> ...
>
> hope it can be useful,
>
> alek
> --
> Aleksander Slominski, LH 316, IU, http://www.extreme.indiana.edu/~aslom
> As I look afar I see neither cherry Nor tinted leaves Just a modest hut
> on the coast In the dusk of Autumn nightfall - Fujiwara no Teika (1162-1241)