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 "Sedukhin, Igor" <Ig...@ca.com> on 2002/02/22 15:37:15 UTC

Default type mapping (another attempt)

I'm trying it again.

The WSDL2Java and Java2WSDL take care of properly mapping
http://my.app.corp.etc <http://my.app.corp.etc>  namespaces back to and from
etc.corp.app.my packages (see code fragments below). SOAP processing
pipeline does not. It always assumes the typemappings must have been
provided by the service deployer. I'd like to make an attempt to sligtly
modify DefaultTypeMappingsImpl to take care of this by default.
I know we had discussion before, but it has faded out and there was no
coherent +1 or -1 on this. So let me try to start my +1.

Here is the code in WSDL2Java and java2WSDL that I was referring to
=== in axis.wsdl.fromJava.Types.getTypeQName(Class type) ===
                String pkg = getPackageNameFromFullName(type.getName());
                String lcl = getLocalNameFromFullName(type.getName());

                String ns = namespaces.getCreate(pkg);
                String pre = namespaces.getCreatePrefix(ns);
                String localPart = lcl.replace('$', '_');
                qName = new javax.xml.rpc.namespace.QName(ns, localPart);

=== in axis.wsdl.toJava.Utils.makePackageName(String namespace) ===
        //convert illegal java identifier
        hostname = hostname.replace('-', '_');

        // tokenize the hostname and reverse it
        StringTokenizer st = new StringTokenizer( hostname, "." );
        String[] words = new String[ st.countTokens() ];
        for(int i = 0; i < words.length; ++i)
            words[i] = st.nextToken();

        StringBuffer sb = new StringBuffer(80);
        for(int i = words.length-1; i >= 0; --i) {
            String word = words[i];
            if (JavaUtils.isJavaKeyword(word)) {
                word = JavaUtils.makeNonJavaKeyword(word);
            }
            // seperate with dot
            if( i != words.length-1 )
                sb.append('.');

            // convert digits to underscores
            if( Character.isDigit(word.charAt(0)) )
                sb.append('_');
            sb.append( word );
        }
        return sb.toString();

-- Igor Sedukhin .. (Igor.Sedukhin@ca.com)
-- (631) 342-4325 .. 1 CA Plaza, Islandia, NY 11788