Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,746 members, 7,809,844 topics. Date: Friday, 26 April 2024 at 03:55 PM

Web Service Using Java Or C# - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Web Service Using Java Or C# (7172 Views)

Creating An Open-source Java Web Service / Programming Career In Either JAVA Or .NET / Java Or C++ (2) (3) (4)

(1) (2) (Reply) (Go Down)

Web Service Using Java Or C# by webmonkey(m): 9:55am On Feb 02, 2011

Can anyone help take me through on how to develop a webservice using either Java, VB or C#.  The web service will connect to a remote Oracle database.

The motivation for this is that I am developing a banking application and the application will be domicile in Nigeria but application will need to connect to other regional branches database for posting, account checks, balance enquiry and limit checks.

However, I have no clue on Web service. I have search the internet for tutorials but no good source found. I know that there are good programmers here like Sbucareer and etc. Please, try and guide me.

Thanks in advance.

Re: Web Service Using Java Or C# by megaplaza(m): 3:44pm On Feb 02, 2011
are u a java programmer, i have developed web ssservice b4 but with netbeans IDE. I think this may help
download.oracle.com/javaee/5/tutorial/doc/bnayl.html
Re: Web Service Using Java Or C# by webmonkey(m): 3:53pm On Feb 02, 2011


Thanks. I am a java developer and would appreciate any help on java web services. I just want a general tutorial on how to connect to oracle database (Flexcube) and return a table object and select a turple and get the cust_id and manipulate the object.

I would really appreciate your help. I have Netbeans and JEE tutorial but are not sufficient for my understanding. It only return Hellow World.

I need to know how to deploy the services and how to connect to them. Would I need a server like Tomcat to WSDL.

If so, I want to do it on Microsoft VB or C# where I will just generate .dll and deploy it with regsvr32 and call the OCX from my application. 

I still need help of Microsoft VB or C#

Re: Web Service Using Java Or C# by logica(m): 1:15pm On Feb 03, 2011
Download CXF, read about it, use it. You might benefit from using it with Hibernate and Spring.
Re: Web Service Using Java Or C# by gozzilla(m): 3:04pm On Feb 03, 2011
^^^ Seconded. Spring and Hibernate.

Spring makes it easy to do just that.
Re: Web Service Using Java Or C# by Mobinga: 12:08am On Feb 04, 2011
cool
Re: Web Service Using Java Or C# by Beaf: 12:19am On Feb 04, 2011
Just add a web reference to your C# project in Visual Studio and 70% of the job is done, it will be easy enough to just fill in the gaps from there.
Re: Web Service Using Java Or C# by Kobojunkie: 5:55am On Feb 04, 2011
First @Poster. Always try to program in the language you are most familiar and most comfortable with. I know a lot of people pretend they can know it all but the truth is you are best only in the one you are best at. If you are a Java Developer, then program in Java.

Second you probably want to spend two weeks reading up on web services and probably learning how similar they are to what you are probably already used to.
Re: Web Service Using Java Or C# by AspWebUK: 9:01pm On Feb 04, 2011
We can partner with you to create and consume this web service using C# and the .Net framework. If this is of interest to you, then you can contact us at this address: support@aspwebuk.com
Re: Web Service Using Java Or C# by candylips(m): 10:52pm On Feb 04, 2011
Since you are integrating a Banking app. I think it will be safer for you to integrate  via messaging .

webservices doesn't seem to be the right tool for what u have described above
Re: Web Service Using Java Or C# by Kobojunkie: 1:14am On Feb 05, 2011
And a webservice does not offer messaging feature as one of it's cores?  undecided
Re: Web Service Using Java Or C# by candylips(m): 1:48am On Feb 05, 2011
ok let me rephrase. messaging over a message broker/messaging bus via JMS or AMPQ.

his banking app can publish a posting, balance enquiry etc message for to a Topic which branches can subscribe to and retrieve messages . .
Re: Web Service Using Java Or C# by logica(m): 8:47am On Feb 05, 2011
Well, a combination of SOAP and JMS can be used. JMS can just be used to serialize or sequence messages coming in, but ultimately the messages are delivered to the queue via SOAP calls. And about security, SOAP has several strategies for securing the web-service methods.
Re: Web Service Using Java Or C# by candylips(m): 11:54am On Feb 05, 2011
I wouldn't use SOAP over JMS. Thats like wrapping another protocol over another protocol which is unnecessary.

Simple object bytes serialization over JMS is more than enough.
Re: Web Service Using Java Or C# by Gomez(m): 7:18pm On Feb 05, 2011
Hi
I think the advice on using the language that you are very familar
while developing your services is a good one to consider.
There are tools to use for either java or .net to create a service solutions.

I have worked with webservices for some thing now and on a current project where I am developing the service on .net framework and the client devices run java based solutions, buiding the solution is one thing, performance and security are other factors to consider.

Here is a link to a quick video on how to create webservice on .net framework.

http://www.asp.net/general/videos/how-do-i-create-and-call-a-simple-web-service-in-aspnet

I hope that helps.
Re: Web Service Using Java Or C# by gozzilla(m): 7:30pm On Feb 05, 2011
Seems everyone is rooting for Java. So poster is that language of choice?
Re: Web Service Using Java Or C# by logica(m): 8:29pm On Feb 05, 2011
Candylips,

I would rather not regard JMS as a protocol, while SOAP is ACTUALLY a protocol. unwrapping the acronyms will tell the full story:

Simple Object Access Protocol
Java Message Service

When you say this: "Simple object bytes serialization over JMS is more than enough", it is obvious to me that a protocol is actually used to perform that serialization. Therefore it is JMS over some arbitrary protocol (which could be any IP based protocol, including SOAP).
Re: Web Service Using Java Or C# by candylips(m): 1:36am On Feb 06, 2011
No JMS uses Java's inbuilt serialisation it doesn't care about serialisation it just routes messages.
Re: Web Service Using Java Or C# by logica(m): 2:01am On Feb 06, 2011
. . . and how do you think Java will "automatically" serialize an object over the wire? It is apparent that a protocol is at play and this is usually IIOP. So in effect, what you have described is JMS (that is RMI) over IIOP as opposed to JMS over SOAP.
Re: Web Service Using Java Or C# by candylips(m): 9:03pm On Feb 06, 2011
java will typically "automatically" serialise an object that is either getting persisted or that will be sent over the wire.

That is why it is mandatory to implement serialisable if you use Hibernate or ObjectMessage for example

JMS uses TCP/IP socket connections not IIOP

Sending objects over the wire is even not very efficient because of the cost incurred doing serialisation and stuff

Coming back to your previous point. While SOAP via JMS is a viable solution. All am saying is that SOAP is not really necessary in this scenario.

JMS Messages composed of  simple objects or better still bytes of data is more than enough.
Re: Web Service Using Java Or C# by logica(m): 11:13pm On Feb 06, 2011
. . . making the critical assumption that every single consumer of the exposed queue should understand proprietary JMS communication protocol. Not generic enough in my opinion. It even gets worse because not all JMS based MOMs are interoperable. So it is not a given that messages can be successfully exchanged except they are the exact same. Though quite a bit have been adopting AMQP (which is a bit new to me I must admit). Interesting reading here:

http://en.wikipedia.org/wiki/Message-oriented_middleware

http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol
Re: Web Service Using Java Or C# by candylips(m): 11:11am On Feb 07, 2011
". . . making the critical assumption that every single consumer of the exposed queue should understand proprietary JMS communication protocol."

This is exactly the fundamental disadvantage of sending Objects in JMS when working in a multilanguage scenerio and why SOAP might probably be an option.

AMPQ on the other hand can interoperate with different languagues since it is a wire level protocol and relies on bytes of data

yea more people especially in the financial space are adopting AMPQ. its fast and efficent. Have a look at Apache Qpid and RabbitMQ ( reference implementation in java)
Re: Web Service Using Java Or C# by webmonkey(m): 10:03am On Feb 08, 2011

Thanks all for your guide and advice.  Over the weekend I was going through Java tutorial from Oracle web site

I can comfortably say that I am getting hang of Java. At least I understand Java Web Services.  Although, many people here prefer JMS or SOAP messing using XML binding.  But my motivation is not about asynchronous queuing systems for my RMI/RPC (Remote Method Invocation/Remote Procedural Call).

I am interested in getting a remote object method that otherwise will be difficult to get that implement a local interface. The interface holds a reference to the underlying database i.e Oracle.

In my application I am using third party software called IBM MQ Series Queue for my queue messages to the Core systems (Flexcube). The queue listens to my database Trigger on INSERT ON A TABLE.  The queue is tie to that table interface.



Re: Web Service Using Java Or C# by webmonkey(m): 10:06am On Feb 08, 2011

I could have used [url=http://www.google.com.ng/search?hl=en&source=hp&biw=1020&bih=562&q=define%3A+database+link&aq=o&aqi=&aql=&oq=”]database link[/url] to do the job.  But it is too slow for scalability.
Re: Web Service Using Java Or C# by webmonkey(m): 10:52am On Feb 08, 2011

Introducing JAX-WS 2.0 With the Java SE 6 Platform, Part 1

JAX-WS 2.0 pronounced (Jaz Waz) is extremely good framework used for developing a Web services. JAX-WS is the industry standard for developing RMI/RCP. It is better than Microsoft .COM, OCX, DLL and etc.
This is my findings. You can correct me on this.  To develop and use JAX-WS we will need the following installed in our systems.

1. Web Server (J2ee 1.6, JBoss 6.0)
2. Java (J2SE 1.6)
3. Netbeans IDE 6.8 (Optional)
4.  Oracle (For this tutorial)
Re: Web Service Using Java Or C# by webmonkey(m): 11:39am On Feb 08, 2011

Define the Service Endpoints to be published by your web services
package com.sun.org.webservices;

import javax.jws.WebService;
import org.com.sun.webservice.dao;

@WebService
public class WebExService {

   @WebMethod
   public double getBalance(String customer_id) {
       return Double.ValueOf(getBalance()).doubleValue();
    }

   @WebMethod
   public double getLimitCheck(String customer_id) {
       return Double.ValueOf(getLimitCheck()).doubleValue();
   }
   @WebMethod
   public double getBalEquiry(String customer_id) {
       return Double.ValueOf(getBalEnquiry()).doubleValue();
   }

}//End WebExService
To export these methods, you must add two things: an import statement for the javax.jws.WebService package and a @WebService annotation at the beginning that tells the Java interpreter that you intend to publish the methods of this class as a web service and @WebMethod

Re: Web Service Using Java Or C# by webmonkey(m): 11:59am On Feb 08, 2011

You can use the static publish() method of the javax.xml.ws.Endpoint class to publish the class as a web service in the specified context root:

package com.sun.org.webservices;

import javax.xml.ws.Endpoint;

public class WeExServiceEndpoint{
public static void main(String[] args) {

Endpoint.publish(
"http://localhost:8080/WebService/WebExService",
new WebExService());

}

Now, compile the source code normally using javac. However, you must perform one more step: Call the Wsgen tool, as follows.
c:\>wsgen –cp . com.sun.org.webservices.WebExService

The Wsgen tool will generate a number of source files in a subdirectory called wsgen, which it then compiles. Although you should never have to edit these files, you can browse these source code files to get an idea of how JAX-WS 2.0 creates the appropriate stub files for use while publishing the web service. Note that the original source files must be located in a package when you call the Wsgen tool. Otherwise, you may get an error that dictates that classes annotated with @WebService, such as WebExService, must declare a separate javax.jws.Webservice.targetNamespace element because the source files are not part of a package.

Re: Web Service Using Java Or C# by webmonkey(m): 12:15pm On Feb 08, 2011


That's it. When you run the application, the Java SE 6 platform has a small web application server that will publish the web service at the address http://localhost:8080/WebService/WebExService while the JVM is running.* You can verify that the web service is running by displaying the Web Services Definition Language (WSDL) file of the WebExService web service.While the JVM is still running, open a browser and go to the following location:

http://localhost:8080/WebService/WebExSerice?WSDL

If you see a large amount of XML that describes the functionality behind the web service, then the deployment has been successful.
Re: Web Service Using Java Or C# by webmonkey(m): 12:32pm On Feb 08, 2011

Creating a Client that will consume the Endpoints

To create client that will consume the web service we created, we need to bear couple of things in mind. If our client is going to stay remotely from our endpoints i.e. different JVM or Machine with different physical network address.  Such that  our web service is in Ghana and our client trying to access the endpoints is in Nigeria.

We will need the web service endpoint to have a public IP (Internet Protocol) hence, rather to http://localhost:8080/WebService/WebExService we will have http://136.148.2.14:8080/WebService/WebExService
This way our client stubs generated by c:\>wsgen –cp . com.sun.org.webservices.WebExService will communicate with the http://136.148.2.14:8080/WebService/WebExService?wsdl

Re: Web Service Using Java Or C# by webmonkey(m): 1:06pm On Feb 08, 2011

package com.sun.org.webservices.client;

import javax.xml.ws.*;
import javax.jws.*;
import com.sun.org.webservices.WebExService;

public class WeExServiceClient{
   public static void main(String[] args) {
try{
@WebServiceRef(wsdlLocation="http://136.148.2.14:8080/WebService/WebExService?wsdl”)
static WebExService service;
double result;
WebExServer port = service.getWebExServerPort();
result = port.getBalEnquiry("0083347781737701"wink; //0083347781737701 is account number
System.out.println(result);
 }catch(java.lang.Exception e ){
e.printStackTrace();
}//End exception      
}
Re: Web Service Using Java Or C# by webmonkey(m): 2:00pm On Feb 08, 2011

You may correct any part of this tutorial. Note, this code were not compiled and as such requires your debuging to get it to work.

Re: Web Service Using Java Or C# by webmonkey(m): 2:12pm On Feb 08, 2011

Creating POJO that will communicate Oracle
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package org.com.sun.webservice.dao;

import java.sql.*;
/**
*
* @author Dalan Quaice
*/
public class DatabaseCon  {

    private Connection con;
    private ResultSet rs;
    private PreparedStatement psmt;
    private String url;


    public Connection getConnection(){
        try{
            DriverManager.registerDriver
                (new oracle.jdbc.driver.OracleDriver());
            url = "jdbc.oracle.thin@localhost:1521:FLEXCUBE";
            con = DriverManager.
                    getConnection(url, "webservice", "webservice"wink;
        }catch (SQLException e){

        }
        return con;
    }//End getConnection

    public String getLimitCheck (String id) throws SQLException{

        String theTitle = null;
        String query = "SELECT * from GZH971 where SYSTEM_ID=?";

            psmt = getConnection().prepareStatement(query);
            psmt.setString(1, id);
            psmt.executeUpdate();

            rs = psmt.executeQuery();

            while (rs.next()){
               theTitle = rs.getString("SCV321"wink;
            }
            return theTitle;
    }//End getLimitCheck

    public String getBalEnquiry (String id) throws SQLException{

        String name = null;
        String query = "SELECT * from GZH971 where SYSTEM_ID=?";

            psmt = getConnection().prepareStatement(query);
            psmt.setString(1,id);
            psmt.executeUpdate();

            rs = psmt.executeQuery();

            while (rs.next()){
               name = rs.getString("SCPF2"wink;
            }
            return name;
    }//End getBalEnquiry

    public String getBalance (String id) throws SQLException{

        String name = null;
        String query = "SELECT * from GZH971 where SYSTEM_ID=?";

            psmt = getConnection().prepareStatement(query);
            psmt.setString(1, id);
            psmt.executeUpdate();

            rs = psmt.executeQuery();

            while (rs.next()){
               name = rs.getString("PFDS34"wink;
            }
            return name;
    }//End getBalance

    public String getTransactionPosting (String id) throws SQLException{

        String name = null;
        String query = "SELECT * from GZH971 where SYSTEM_ID=?";

            psmt = getConnection().prepareStatement(query);
            psmt.setString(1, id);
            psmt.executeUpdate();

            rs = psmt.executeQuery();

            while (rs.next()){
               name = rs.getString("H3H"wink;
            }
            return name;
    }//End getTransactionPosting
}

(1) (2) (Reply)

Aspiring Video Game Programmers Lounge. / How To Develop Android Apps From Scratch Without Coding. / You need to see this! "Awoof" Offer You Can't Get Anywhere Else

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 48
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.