You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Tom Jordahl <to...@macromedia.com> on 2001/08/31 00:08:17 UTC

Update to wsdl2java emitter code for complex types

The change below correctly uses the schema namespace for the
BeanSerializer/DeserializerFactory in the generated client stub.

Thanks.
--
Tom Jordahl
MacroMedia Server Development


*** Emitter.java.ORIG	Thu Aug 30 17:56:36 2001
--- Emitter.java	Thu Aug 30 17:58:32 2001
***************
*** 82,87 ****
--- 82,88 ----
  import javax.wsdl.WSDLException;
  
  import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
  import org.w3c.dom.NamedNodeMap;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
***************
*** 778,786 ****
       * In the stub constructor, write the serializer code for the complex
types.
       */
      private void writeSerializationInit(PrintWriter pw, String type)
throws IOException {
          pw.println ("        try");
          pw.println ("        {");
!         pw.println ("            org.apache.axis.utils.QName qn1 = new
org.apache.axis.utils.QName (\"bogusNS\", \"" + type + "\");");
          pw.println ("            Class cls = " + type + ".class;");
          pw.println ("            call.addSerializer (cls, qn1, new
org.apache.axis.encoding.BeanSerializer (cls));");
          pw.println ("            call.addDeserializerFactory (qn1, cls,
org.apache.axis.encoding.BeanSerializer.getFactory ());");
--- 779,791 ----
       * In the stub constructor, write the serializer code for the complex
types.
       */
      private void writeSerializationInit(PrintWriter pw, String type)
throws IOException {
+         Element e = (Element)complexType(type).getParentNode();
+         String namespace = e.getAttribute("targetNamespace");
+ 
          pw.println ("        try");
          pw.println ("        {");
!         pw.println ("            org.apache.axis.utils.QName qn1 = new
org.apache.axis.utils.QName (\"" + namespace +
!                 "\", \"" + type + "\");");
          pw.println ("            Class cls = " + type + ".class;");
          pw.println ("            call.addSerializer (cls, qn1, new
org.apache.axis.encoding.BeanSerializer (cls));");
          pw.println ("            call.addDeserializerFactory (qn1, cls,
org.apache.axis.encoding.BeanSerializer.getFactory ());");

Re: Update to wsdl2java emitter code for complex types

Posted by Glen Daniels <gd...@macromedia.com>.
Thanks, Tom - checked in and (manually) tested.  We should start thinking
about what unit tests for the WSDL code (both directions) would look
like....

--G

----- Original Message -----
From: "Tom Jordahl" <to...@macromedia.com>
To: <ax...@xml.apache.org>
Sent: Thursday, August 30, 2001 6:08 PM
Subject: Update to wsdl2java emitter code for complex types


>
> The change below correctly uses the schema namespace for the
> BeanSerializer/DeserializerFactory in the generated client stub.
>
> Thanks.
> --
> Tom Jordahl
> MacroMedia Server Development
>
>
> *** Emitter.java.ORIG Thu Aug 30 17:56:36 2001
> --- Emitter.java Thu Aug 30 17:58:32 2001
> ***************
> *** 82,87 ****
> --- 82,88 ----
>   import javax.wsdl.WSDLException;
>
>   import org.w3c.dom.Document;
> + import org.w3c.dom.Element;
>   import org.w3c.dom.NamedNodeMap;
>   import org.w3c.dom.Node;
>   import org.w3c.dom.NodeList;
> ***************
> *** 778,786 ****
>        * In the stub constructor, write the serializer code for the
complex
> types.
>        */
>       private void writeSerializationInit(PrintWriter pw, String type)
> throws IOException {
>           pw.println ("        try");
>           pw.println ("        {");
> !         pw.println ("            org.apache.axis.utils.QName qn1 = new
> org.apache.axis.utils.QName (\"bogusNS\", \"" + type + "\");");
>           pw.println ("            Class cls = " + type + ".class;");
>           pw.println ("            call.addSerializer (cls, qn1, new
> org.apache.axis.encoding.BeanSerializer (cls));");
>           pw.println ("            call.addDeserializerFactory (qn1, cls,
> org.apache.axis.encoding.BeanSerializer.getFactory ());");
> --- 779,791 ----
>        * In the stub constructor, write the serializer code for the
complex
> types.
>        */
>       private void writeSerializationInit(PrintWriter pw, String type)
> throws IOException {
> +         Element e = (Element)complexType(type).getParentNode();
> +         String namespace = e.getAttribute("targetNamespace");
> +
>           pw.println ("        try");
>           pw.println ("        {");
> !         pw.println ("            org.apache.axis.utils.QName qn1 = new
> org.apache.axis.utils.QName (\"" + namespace +
> !                 "\", \"" + type + "\");");
>           pw.println ("            Class cls = " + type + ".class;");
>           pw.println ("            call.addSerializer (cls, qn1, new
> org.apache.axis.encoding.BeanSerializer (cls));");
>           pw.println ("            call.addDeserializerFactory (qn1, cls,
> org.apache.axis.encoding.BeanSerializer.getFactory ());");
>