Lots of code to make a web service

Does anybody know of any tools to make creating web services faster in Java - I am getting frustrated with the amount of code it takes. Anybody else feel the same way?

Here's an example of what I mean..
// Open a database connection and statement.
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Connection dbConn = DriverManager.getConnection("jdbc:db2:sample","myuser","mypass");
Statement statement = dbConn.createStatement();
// Build the message.
SOAPMessageContext ctx = (SOAPMessageContext) messageContext;
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage m = messageFactory.createMessage();
SOAPEnvelope env = m.getSOAPPart().getEnvelope();
SOAPBody body = env.getBody();
SOAPElement elem =
body.addBodyElement(env.createName("ns1:getEmployees"));
elem.addNamespaceDeclaration("ns1",
"http://www.abc.com/SampleApplication/Employee.wsdl");
elem.addNamespaceDeclaration("ns2",
"http://www.abc.com/SampleApplication/Employee.xsd");
SOAPElement elem1 = new SOAPElementImpl("Response", null, null);
// Execute the query.
String sql = "SELECT EMPNO, FIRSTNME, MIDINIT, LASTNAME, HIREDATE FROM EMPLOYEE";
ResultSet result = statement.executeQuery(sql);
SOAPElement employee = new SOAPElementImpl("Employees", "ns2", "http://www.abc.com/SampleApplication/Employee.xsd");
employee.addChildElement("ns2:EMPNO").addTextNode(result.getString("EMPNO"));
employee.addChildElement("ns2:FIRSTNME").addTextNode(result.getString("FIRSTNME"));
employee.addChildElement("ns2:FIRSTNME").addTextNode(result.getString("MIDINIT"));
employee.addChildElement("ns2:LASTNAME").addTextNode(result.getString("LASTNAME"));
employee.addChildElement("ns2:FIRSTNME").addTextNode(result.getString("HIREDATE"));
elem1.addChildElement(employee);
elem.addChildElement(elem1);
ctx.setMessage(m);
dbConn.close();
} catch (Throwable e) {
weblogic.utils.Debug.say("(hbs):e " + e);
e.printStackTrace(System.out);
putting the data in the node seems excessive to me.
thanks
DG

Similar Messages

  • How to edit Java source code of a generated Web Service?

    I generated a Jax RPC (1.4) Web Service using the JDev Wizard . Everything works fine. But now I need to make some changes in the business logic contained in the source code. The problem is there is no easy way to get to the source code - JDeveloper shows the web service but right clicking on it only lets me go to the WSDL or Mapping file - not the Java source.
    So - how do I get to the source.
    I could do a file -> open and open up the java file and edit it - but this seems like a round about way . Why doesn't JDev let me go back to the Source code easily?
    It does provide a Regeneate from Source option but there is no way (as far as I could tell) to actually jump back into the source code after I've generated the Web Service.
    Thanks!

    Hi,
    just to confirm that Jan is ight. If you seect the generated WSDL icon, which is shown in the Application Navigator, open the Structure Window and you'll see all teh generated interfaces and sourcefiles, as well as your WebService file.
    Alternatively you can use teh System navigator which will show all files in one view (ctrl+shift+N)
    Frank

  • What is the transaction code for see the Web Services available in SAP

    Hi
    I came to know that SAP has provided its own webservices... I need some information on that... If any one has documentation on that can u please send it to me... My ID is <b>[email protected]</b>.
    What is the trasaction code for see the web services available in SAP.... Can any one help.. Please its  urgent
    Best Regards
    Ravi Shankar B
    Message was edited by:
            RaviShankar B

    Hi,
    you can find Web Services (Enterprise Services) in the Enterprise Services Workplace (ES Workplace). The ES Workplace allows you to explore, test, and use enterprise services to make enterprise SOA tangible. Here, you will find all of the currently productized enterprise services by SAP.
    Best Regards,
    Boris Mueller
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/developerareas/esa/esapreview">ES Workplace at SDN</a>
    <a href="http://esapreview.sap.com:82/socoview(bD1kZSZjPTgwMCZkPW1pbg==)/flddisplay.asp">ES Workplace</a>

  • Hi all: Change language Code in CI based web services.

    I am developing CI based soap web services in peoplesoft. i want response in different in languages. I need that language is selected at request time. mean need to change Language Code in CI based web services.
    Can anybody help me?
    thanks

    You posted a duplicated thread here :
    Hi all: Change language Code in CI based web services.
    -- mod. action: locking this one --
    Nicolas.

  • Make simple web service

    Hi all, I'd like to make simple web service. I made a desktop (swing) application, which requires access to database. The database is not accessible from outside of the server.
    But I have web application on this server, so I can create a servlet (or jsp), which could operate as web service. Afterwards I can create a connection in my desktop application directed to this service page. The page downloads required data and grants them for my desktop application.
    But I don't know the way I could do it. Can you help me please? Thank you :-).

    Hi again, after several days, I'm back. It seems to be very good solution for me, but I have a problem. I can't catch it :-(. I've read the manual pages maybe twenty-times and I've looked for another tutorials and so on. Nothing helped. I don't know, how I can run it :-(. I create following:
    My web.xml:<web-app version="2.4"
               xmlns="http://java.sun.com/xml/ns/j2ee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
               http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
         <servlet>
              <servlet-name>EOTService</servlet-name>
              <servlet-class>services.EOTService</servlet-class>
              <init-param>
                   <param-name>enabledForExtensions</param-name>
                   <param-value>true</param-value>
                   <description>Sets, whether the servlet supports vendor extensions for XML-RPC.</description>
              </init-param>
         </servlet>
         <servlet-mapping>
              <servlet-name>EOTService</servlet-name>
              <url-pattern>/service</url-pattern>
         </servlet-mapping>
    </web-app>In package services I have two .java files. The first one, Calculator.java:package services;
    public class Calculator {
         public int add(int a, int b) {
              return a + b;
         public int sub(int a, int b) {
              return a - b;
    }and the second one, EOTService.java:package services;
    import org.apache.xmlrpc.*;
    import org.apache.xmlrpc.common.*;
    import org.apache.xmlrpc.server.*;
    import org.apache.xmlrpc.webserver.*;
    public class EOTService extends XmlRpcServlet {
         private boolean isAuthenticated(String pUserName, String pPassword) {
              return pUserName.equals("username") && pPassword.equals("password");
         protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
              PropertyHandlerMapping mapping = (PropertyHandlerMapping) super.newXmlRpcHandlerMapping();
              AbstractReflectiveHandlerMapping.AuthenticationHandler handler =
                   new AbstractReflectiveHandlerMapping.AuthenticationHandler() {
                        public boolean isAuthorized(XmlRpcRequest pRequest) {
                             XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig();
                             return isAuthenticated(config.getBasicUserName(), config.getBasicPassword());
              mapping.setAuthenticationHandler(handler);
              try {
                   mapping.addHandler("Calculator", Class.forName("services.Calculator"));
              } catch (ClassNotFoundException e) {
                   e.printStackTrace();
              return mapping;
    }In the myapp/WEB-INF/lib I have these files:xmlrpc-common-3.1.3.jar
    xmlrpc-server-3.1.3.jarAnd now, I'd like to connect to this servlet and download data. So I have another application and in main method of the application I call this:public static void main(String[] args) {
    try {
                XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
                config.setServerURL(new URL("http://127.0.0.1:8080/service"));
                XmlRpcClient client = new XmlRpcClient();
                client.setConfig(config);
                Object[] params = new Object[]{new Integer(33), new Integer(9)};
                Integer result = (Integer)client.execute("Calculator.add", params);
                System.out.println("33 + 9 = " + result);
            } catch (java.net.MalformedURLException e) {
                System.out.println(e.getMessage());
            } catch (org.apache.xmlrpc.XmlRpcException e) {
                e.printStackTrace(System.out);
    }But following exception is thrownException in thread "main" java.lang.NoClassDefFoundError: org/apache/ws/commons/serialize/DOMSerializer
            at org.apache.xmlrpc.serializer.NodeSerializer.<clinit>(NodeSerializer.java:30)
            at org.apache.xmlrpc.common.TypeFactoryImpl.<clinit>(TypeFactoryImpl.java:88)
            at org.apache.xmlrpc.common.XmlRpcController.<init>(XmlRpcController.java:31)
            at org.apache.xmlrpc.client.XmlRpcClient.<init>(XmlRpcClient.java:51)
            at main.Main.main(Main.java:51)
    Caused by: java.lang.ClassNotFoundException: org.apache.ws.commons.serialize.DOMSerializer
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            ... 5 moreI'm trying to implement it for five days and my failure is very stressful. Help me please... please :-[.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Sample code to access BAPI Web services from JAVA required

    Hi All,
    I am a java developer. I am new to SAP. I just want to know how to use the web services from ABAP
    I got the WSDL, and able to convert the WSDL into java classes using java2wsdl command.
    Now i want to know how to use these classes, in my java class.  i want to know two things
    1) How to get authentication or session  or token to use the service
    2) How to consume BAPI services by using above session or token.
    Any help, really appreciated. Plz help me if any one knows.
    Thanks alot,
    Mohan

    Triplehhh wrote:
    Hi,
    I have a web application developed with java,jsp and javascript and server used is weblogic.
    Now this application is running fine on my PC. I assume from this that there is no client side Java. Is this right?
    So what steps are required so that I can access the application from other PCs also.If there is no client side Java then you have to do nothing other than make sure your PC can be reached from the other PCs. i.e. no firewalls blocking the access and routing available between the client PC and the server PC.
    I don't see what this has to do with JNLP. Am I missing something?

  • Code generated from imported web service model does not compile

    I have created a model in Web Dynpro by importing a web service model using a valid WSDL, but the generated code won't compile because of type mismatches.
    The problem is that methods sometimes try to pass plain objects to methods whose parameter is an array of that object, and a List to methods whose parameter is a plain object.
    [Examples from SAP Netweaver tasks below]
    Thanks,
    Alastair
    snip
    The method setSessionData(EntInstType) in the type AssessRequestData is not applicable for the arguments (EntInstType[])     
    ComplexType_AssessRequestData.java
    Type mismatch: cannot convert from EntInstType to EntInstType[]     
    ComplexType_AssessRequestData.java
    The method setResult(List) in the type Response_JrbrsRefGeneric_listGoals is not applicable for the arguments (EntType)
    Request_JrbrsRefGeneric_listGoals.java

    I'm getting the same error.
    Type mismatch: cannot convert from short[][] to short[]
    ComplexType_Carton.java
    and...
    The method setNumeroscarton(short[][]) in the type Carton is
    not applicable for the arguments (short[])
    ComplexType_Carton.java     
    Steps to recreate the problem:
    1. Create and Expose webservice method with a parameter whose type has a short[][] (or bidimensional array of anything) field (property).
    2. Try to import the web service in web dynpro... <b>kaputt</b> it won't compile.
    <b>Seems like a bug to me. Someone please advice.</b>

  • Is it possible to make synchronous web service calls?

    Hi all,
    Is it possoble to get a web service call to block and wait
    for a response rather than doing it asynchronously using
    flex/action script?
    thanks

    quote:
    Originally posted by:
    Sean Hughes
    peterent - no offense, but your suggestion is a hack. All we
    need is a timeout value.
    In support of the flash player's design I'm going to have to
    disagree with you here. It is completely normal in any multi
    threaded environment to make all functionality non blocking by
    default. Blocking by design can be implemented with semaphores, and
    is not a hack. To implement simply create a flag such as
    'hold:bool' init it to false when your application starts. Set it
    to true just before the web services send() method is called. In
    the result handler you set it back to false.
    In this way you have complete control over what should be
    blocked and what should not be blocked, by simply testing the
    'hold' semaphore. In this way the GUI itself, and all non dependent
    functionality stays alive. A timeout value would arbitrarily block
    all functionality for a fixed amount of time if the request was
    never filled. Although a semaphore could be used to do this as
    well, it has far more flexibility, and users have notoriously
    shorter timeout values than developers.
    j

  • Anyone got sample C# / VB code for CRM OD web service with multi threading?

    Hi,
    I am writing a small utility app to help bulk delete data from custom objects in CRM OD via web services.
    However from what i can see you can only delete 20 records at a time it can take a long time to delete several thousands records by getting 20 results from a query, then deleting the records, then getting the next page of results and deleting them and so on.
    I thought that using multiple threads would help speed up the process but since I'm new to CRM OD web service development i thought if would see if anyone had any sample code they would like to share to help ease the transition?
    Any help would be appreciated.
    Thanks

    Not done this area myself - but I spotted some code that use these tables:
    CRMD_SRV_OSSET, CRMD_SRV_SUBJECT.
    So your selecting lines from OSSET that match the service ticket header guid
    SELECT * FROM   CRMD_SRV_OSSET
             WHERE  SUBJECT_PROFILE  = 'Subject Profile for classification'
             AND    GUID_SET  in
                            ( SELECT GUID_SET FROM CRMD_LINK
                                   WHERE  GUID_HI EQ header_GUID
                                  ) ... into a internal table
    The selecting more information from CRMD_SRV_SUBJECT that matches guids found on the OSSET table
    loop round internal table
    SELECT * FROM  CRMD_SRV_SUBJECT
           WHERE  GUID_REF    =  crmd_srv_osset-GUID
    endloop.
    On this table you have your code group and code that relate to a classification
    Hope this helps and give me some points if it does

  • Can anybody give me complete guideance & code about using j2me web service?

    Hi to all !
    I have posted problem about using j2me web service ...
    but still nobody have give me at least one response..
    can anybody give me complete example about using webservice in j2me?
    premal

    Hi to all !
    I have posted problem about using j2me web service
    but still nobody have give me at least one
    response..
    can anybody give me complete example about using
    webservice in j2me?
    premal-----------------------------------
    Hi, You may find help using netBean IDE.In netBean IDE help, there you should find step by step solusion for web service as well soap messang technology
    your best regard
    http://www.techbd.com
    [email protected]

  • Can't get the print code..tried enabling web services

    but it prompts that 'problem connecting to
    server" I had registered before and it looks like it will not allow to re-register? The HP Eprint "sees" the HPeprint printer C410a as not online. It also see a checked printer C410 [FC99D3] AS ACTIVE  but cannot print. What is wrong? Thx

    Hi, it could be that your printer is dropping its wireless connection and is therefore not connected to the internet. Here's a link to a troubleshooting document that can help you establish if this is the issue and how to fix it. If it is a network connectivity issue you'll need to fix that first before doing anything in your ePrintCenter account.
    Hope this information helps.
    If my reply helped you, feel free to click on the Kudos button (hover over the "thumbs up").
    If my reply solved your problem please click on the Accepted Solution button so other Forum users may benefit from viewing the post.
    I am an HP employee.

  • How to make a web service out of a Stored procedure/Package

    Hi
    I have developed a PL/SQL Package and i wanted to expose this package as a WebService. Can you please give me the detailed steps to create a webservice.
    Your help in this regard is highly appreciated.
    Thanks
    Laj

    Laj,
    I've not done it myself but I believe that there are wizards in JDeveloper that do most (if not all) of the work for you.
    You could try searching the JDeveloper forum.
    Patrick.

  • Invoking Web Service From PL SQL package

    Below is the sample code to invoke web service from pl/sql package using UTL_HTTP:
    Declare
    http_req UTL_HTTP.req;
    http_resp UTL_HTTP.resp;
    Begin
    http_req :=
    UTL_HTTP.begin_request
    'http://'
    || lv_hosturl
    -- || '.net/soa-infra/services/finance_rt/Payments/paymentsprocess_client_ep',
    --new url
    || '.net/soa-infra/services/finance_rt/PaymentsReq/paymentsprocess_client_ep?WSDL',
    'POST',
    'HTTP/1.1'
    UTL_HTTP.set_header (http_req, 'Content-Type', 'text/xml');
    -- since we are dealing with plain text in XML documents
    UTL_HTTP.set_header (http_req,
    'Content-Length',
    LENGTH (lv_soap_request)
    UTL_HTTP.set_header (http_req, 'SOAPAction', '');
    -- required to specify this is a SOAP communication
    UTL_HTTP.write_text (http_req, lv_soap_request);
    http_resp := UTL_HTTP.get_response (http_req);
    UTL_HTTP.read_text (http_resp, lv_soap_respond);
    UTL_HTTP.end_response (http_resp);
    resp := XMLTYPE.createxml (lv_soap_respond);
    End;

    Hi,
    there are a lot of option to make plsql web services .
    First you can stay with jdev 10.1.3
    Use the xmldb servlets
    use jdev 11g tp4 to create plsql ws and upgrade to jdev 11g production
    And I think in the next release of jdev it will be back , there are more options which disappeared like the adf bc sdo ws or jmx datacontrol etc.
    thanks Edwin

  • Support for Creating Web Service from pl/sql package in JDeveloper 11

    We have been creating all of our web services from pl/sql packages in our Oracle database using JDeveloper 10.1.3.1. I understand that this capability is not supported in Jdev 11. We have been mandated to either move up to JDeveloper 11, or consider switching to eclipse, or even VS2008 and run .NET services from IIS. I have seen work-around solutions using TopLink and Jdev 11. Are there plans to revive this feature in the near future? We're now looking at switching to .NET since we could scrap our OAS instances and use IIS to publish web services. The only reason we were sticking with Oracle was the ease in converting all our existing package to web services with Jdev.
    Is anyone else in the same situation. If so, what solutions are you considering?

    Hi,
    there are a lot of option to make plsql web services .
    First you can stay with jdev 10.1.3
    Use the xmldb servlets
    use jdev 11g tp4 to create plsql ws and upgrade to jdev 11g production
    And I think in the next release of jdev it will be back , there are more options which disappeared like the adf bc sdo ws or jmx datacontrol etc.
    thanks Edwin

  • How to make my Portal Web Service SECURED?

    Hi Experts,
    I created one portal Service and exposed it as Portal Web Service.
    Everything is working fine, as i deployed my Portal Web Service on to the SAP J2EE Engine ie SAP Server.
    I m able to access functions of Web Service from my StandAlone Java Application.
    but the problem is my Web Service is not SECURED.
    How can i make my Portal Web Service SECURED?
    Please help me out.
    Help will be appreciated and rewarded!!!!!

    user13046122 wrote:
    I have an old pl/sql "helper" package, originally written to make SOAP Web Service calls from the database - it uses UTL_HTTP to invoke the target services.
    I now need to make SOAP Web Service calls - from an 8.1.7.4 database
    But the version of UTL_HTTP inside 8.1.7.4 does not contain the functions needed in the helper package
    Can anybody suggest a means of making SOAP Web Service calls from an 8.1.7.4 database ?I think you'll be very lucky to find anyone here who still has access to a version of Oracle that is that old.... I mean... that's like what? 15 years old at least? I'm surprised you've still got hardware that can run that.
    It would probably help if you could post what code you've got and explain which function(s) it's complaining about, as I doubt people will want to guess.

Maybe you are looking for

  • List of PI KPI's

    Hi All, Can anyone help me out with the "list of Key Performance indicators(KPI)"  related to Process Integration(PI) and its thresholds. Thanks in Adavnce, Preethi.

  • Adding html to messages I send

    I use Macmail and want to be able to include the link to my website in my signature. I don't want it to say http://mydomain.com...I just want it to appear as a clickable link. Is that possible in Macmail? I've tried a few things but thus far, none of

  • No sound Quicktime Player

    Have upgraded to Mac OS 10.6.3. on both my MacPro and my Macbook. Can play a .wmv or .mpeg but have no sound. They played OK before I upgraded. Any ideas as to why?

  • Count number of Session Hosts active in RD Connection Broker farm.

    Hello, Is there a way to count how many session hosts are active (not drained) in RD Connection broker farm at a given point of time. Thank you,  Kashif

  • Appended log files are not well formed XML?

    I'm working on a retrofit of our home grown logging class to use the new java.util.logging classes. It works beautifully with one exception. If I need to instantiate the logger in the same day, appending to an existing log file, I get a second (or th