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 6657415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:45:54+00:00 2026-05-26T01:45:54+00:00

I have 5 webservices, A, B, C, D, and E. Each has autogenerated objects

  • 0

I have 5 webservices, A, B, C, D, and E. Each has autogenerated objects of the exact same structure, but with different names and in different packages.

com.ws.a.carA contains  parameters and com.ws.a.wheelA
com.ws.b.carB contains  parameters and com.ws.b.wheelB
com.ws.c.carC contains  parameters and com.ws.c.wheelC
com.ws.d.carD contains  parameters and com.ws.d.wheelD
com.ws.e.carE contains  parameters and com.ws.e.wheelE

I want to create one function that can convert each of these objects (and the inner wheel) to a object named

com.model.car,

but I dont wan’t many functions like :

com.model.car convert(com.ws.a.objA obj)
com.model.car convert(com.ws.b.objB obj)

…

The problem is, I can’t give all the objects a common interface to implement, because I don’t want to manually change the autogenerated classes (they are recreated frequently).

I need a way, probably with generics, to create a common function

com.model.car convert(T obj)

that will work for all the car types but I’m not sure how to implement it.

  • 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-05-26T01:45:55+00:00Added an answer on May 26, 2026 at 1:45 am

    You can use reflection for this. The easiest and cleanest way would probably be to use Apache Common BeanUtils, either PropertyUtils#copyProperties or BeanUtils#copyProperties.

    PropertyUtils#copyProperties copies the values from one object to another, where the field names are the same. So with copyProperties(dest, orig), it calls dest.setFoo(orig.getFoo()) for all fields which exist in both objects.

    BeanUtils#copyProperties does the same, but you can register converters so that the values get converted from String to Int, if necessary. There are a number of standard converters, but you can register your own, in your case com.ws.a.wheelA to com.model.wheel, or whatever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two webservices that have exactly the same methods and signatures but point
I'm trying to dynamically send a SOAP request to different webservices. Each webservice has
We have this software that has a webservices component. Now, the administrator of this
I have got class Car, and each class has list of extras (leather, abs,
I have a bunch of very simple functions. Each function has one input and
We have HTTP webservices that are RPC. They return XML representing the object the
I have a few webservices (.net 2.0/ C#) used by many partners. One of
I have been working with WebServices for sometime. I dealt with many services where
I have a list of webservices from a Flex project. I am trying to
I have a set of webservices that I connect to using Silverlight Client. I

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.