Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:25:10+00:00 2026-06-14T21:25:10+00:00

I am looking for a possibility to convert two Axis Datatypes (generated by WSDL2Java)

  • 0

I am looking for a possibility to convert two Axis Datatypes (generated by WSDL2Java) into each other. Both DataTypes consists of exactly the same Attributes because they are both from the same XSD.

The Problem is Axis generates them as Seperated Datatypes.

DataType1:

public static class AbstractAsynchronousResponse extends AbstractResponse implements org.apache.axis2.databinding.ADBBean {

        /*
         * This type was generated from the piece of schema that had name =
         * AbstractAsynchronousResponse Namespace URI =
         * http://www.example.org/AllCallbackTypes Namespace Prefix = ns2
         */
.........}

DataType2:

public static class AbstractAsynchronousResponse extends AbstractResponse implements org.apache.axis2.databinding.ADBBean {

        /*
         * This type was generated from the piece of schema that had name =
         * AbstractAsynchronousResponse Namespace URI =
         * http://www.example.org/AllCallbackTypes Namespace Prefix = ns2
         */
.........}

Now I want to do Something like this:

AbstractAsynchronousResponse1 response1 = new AbstractAsynchronousResponse1();
AbstractAsynchronousResponse2 response2 = (AbstractAsynchronousResponse2) response1;

Is there a solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:25:11+00:00Added an answer on June 14, 2026 at 9:25 pm

    Here is a Method I created to solve this Problem. However this isn’t really nice but it works.

    /**
         * This will cast an {@link ADBBean} implementation to another
         * {@link ADBBean}, but the Implementation will be a subClass of
         * <b>parentLocationOfSourceClass</b>.<br>
         * This only is possible because of the structure of all ADBBean
         * implementations created by <code>Axis2 ADB-Databinding</code>. If you
         * cange the Databinding you probably have to adapt this Method.
         * 
         * @param inputADBBean
         *            An ADBBean Implementation created by
         *            <code>Axis2 ADB-Databinding</code>
         * @param parentLocationOfSourceClass
         *            This is meant to be the <code>ClientStub</code> Class created
         *            by <code>Axis2 ADB-Databinding</code>. The Implementation of
         *            the <code>inputADBBean</code> has to be available with the
         *            same name in the <code>ClientStub</code>
         * @return An {@link ADBBean} implementation defined as SubClass of the
         *         <code>ClientStub</code> Class created by
         *         <code>Axis2 ADB-Databinding</code>
         * @throws Exception
         */
        public static ADBBean castADBBean(ADBBean inputADBBean, String parentLocationOfSourceClass) throws Exception {
            Class clazz = CallbackResponsePoolClient.getClassForParentLocation(inputADBBean, parentLocationOfSourceClass);
            ADBBean outputADBBean = CallbackResponsePoolClient.getInstanceForADBBean(clazz);
            for (Method method : outputADBBean.getClass().getMethods()) {
                String methodName = method.getName();
                if (methodName.startsWith("set")) {
                    CallbackResponsePoolClient.logger.debug("Found a setter: " + methodName);
                    String getterName = methodName.replaceFirst("set", "get");
                    Object arg = inputADBBean.getClass().getMethod(getterName).invoke(inputADBBean);
                    // We need to check if arg lives in the namespace:
                    // org.example.www.callbackresponsepoolinterface
                    // This will happen if we have nested Objects. E.g.
                    // EndpointType inside of EndpointResponse
                    // TODO: instanceof ADBBean could lead to problems, maybe
                    // sometimes we don't want to cast an ADBBean, but I can't think
                    // a scenario right now
                    if (arg instanceof ADBBean) {
                        arg = CallbackResponsePoolClient.castADBBean((ADBBean) arg, parentLocationOfSourceClass);
                    }
                    // We also need to handle Arrays of ADBBeans. See above
                    if (arg instanceof ADBBean[]) {
                        Class innputClass = ((ADBBean[]) arg).getClass().getComponentType();
                        // Better Create a new Object, because arg[0], can get you
                        // an Exception for an empty Array
                        ADBBean inputArrObj = CallbackResponsePoolClient.getInstanceForADBBean(innputClass);
                        Class outputArrClass = CallbackResponsePoolClient.getClassForParentLocation(inputArrObj, parentLocationOfSourceClass);
                        Object outputArray = Array.newInstance(outputArrClass, ((ADBBean[]) arg).length);
                        for (int i = 0; i < Array.getLength(arg); i++) {
                            Array.set(outputArray, i, CallbackResponsePoolClient.castADBBean((ADBBean) Array.get(arg, i), parentLocationOfSourceClass));
                        }
                        arg = outputArray;
                    }
    
                    method.invoke(outputADBBean, arg);
                }
            }
    
            return outputADBBean;
        }
    
        private static Class getClassForParentLocation(ADBBean inputADBBean, String parentLocationOfSourceClass) throws ClassNotFoundException {
            return Class.forName(parentLocationOfSourceClass + "$" + inputADBBean.getClass().getSimpleName());
        }
    
        private static ADBBean getInstanceForADBBean(Class clazz) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
            Constructor constructor = clazz.getConstructor();
            return (ADBBean) constructor.newInstance();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking into the possibility of integrating an Azure hosted .NET solution with Dynamics
Looking into possibility of making an USB distributed application that will autostart on insertion
We are looking into the possibility of allowing users to opt into a program
I am looking into the possibility of doing some mobile app development, firstly for
Hey, I've been looking at the possibility of adding a scripting language into my
A little background first. I am looking into the possibility of implementing Ruby's ActiveRecord
I'm looking for a possibility to load the Java code dynamically into a class
I am looking into the possibility of using tools in order to help me
I am looking into the possibility of Distributing a data structure across multiple machines.
I am looking into the possibility of taking on LINQ to NHibernate in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.