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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:30:00+00:00 2026-05-24T17:30:00+00:00

i am creating a web service using 3rd party wsdl that helps me in

  • 0

i am creating a web service using 3rd party wsdl that helps me in getting a kind of notification. now i have to save that notification in DB and perform several other operations related to DataBase.
in My persistence.xml there are two persistence units as following:

    <persistence-unit name="PU1" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/vsDS</jta-data-source>
    <class>com.Response</class>
    <class>com.Request</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="eclipselink.logging.level" value="INFO"/>
    </properties>
</persistence-unit>


<persistence-unit name="PU2" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/vdDS</jta-data-source>
    <class>com.LogRequest</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="eclipselink.logging.level" value="INFO"/>
    </properties>
</persistence-unit>

till yet i have made a class named Service.java that have all functions i need to perform on DB as following:

public class Service {

private static Logger logger = Logger.getLogger(Service.class);

private EntityManagerFactory PU1;
private EntityManagerFactory PU2;


public Service(){
    System.out.println("in service's constructer");
    PU1=Persistence.createEntityManagerFactory("PU1");
    PU2=Persistence.createEntityManagerFactory("PU2");
}
public void logSubRequest(String msg){
    EntityManager em= PU1.createEntityManager();
    try{
        em.getTransaction().begin();
        Request req=new Request();
        req.setMessage(msg);
        req.setStatus("Y");
        em.persist(req);

        em.getTransaction().commit();
    }catch(Exception e){
        logger.error("In logSubRequest="+e.getMessage()); 
        e.printStackTrace();
    }finally{
        if(em.isOpen()){
            em.close();
        }
    }
}
   // there are several other methods of such kind that either persist entities or executeUpdate
   }

My Question is: Am i going with standard approach to implement JPA with webservice or should i go with some other technology/method. kindly suggest and guide if i am doing any thing out of standard.

  • 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-24T17:30:01+00:00Added an answer on May 24, 2026 at 5:30 pm

    The combination of a Web services and JPA is often used, I see no reason to choose some other persistence mechanism. I’d recommend sticking with your current design until your requirements get more complex.

    Larger applications where the equivalent of your Request object is more complex and the resulting business logic more challenging will add more layers of objects in order to control the structure and enable reuse.

    I tend to think like this: The Web service interface is just one possible “way in” to the my business logic. So I might also have a RESTful service, or a JMS interface. Hence I tend to put my business logic inside an EJB, in simple cases a “No Interface” EJB. I focus on the EJB as a reusable piece of business logic that I can test in isolation. It will do all the JPA work. Then my Web service just uses that EJB to do its work. The EJB looks after the transactions so I don’t need to write the transaction control code you have.

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

Sidebar

Related Questions

I have XML that is returned by a 3rd party web service in the
I have a WCF web service using wsHttpBinding that I am consuming from a
I am creating a web service using php SOAPServer. I am creating a wsdl
I have to call the web service using java script? e.g. I'm creating one
I'm creating a web service using gSoap, in the header file I have few
I am creating a WCF web service using wsHttpBinding and a corresponding application that
I am creating an application which involves so many web-service calls. I am using
I have an irritating problem, I'm creating an asp.net web service; this service should
I am using JBoss 4.0 for creating a simple Web Service using the @WebService
I'm creating a web service that often scrapes data from remote web pages. After

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.