Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do selfhosting web service in java application

I have a Java Application. I use Netbeans 7.4 IDE. I want to host some web service methods within this application so that other clients can get data provided by this application using web service.
I don't want to host this web servis on any web server, i want to host this only within the application itself like WCF selfhosting in .NET.
I have been developing C# applications and i have knowladge about WCF but i am just a starter of Java world. Is it possible to host web service endpoints within the application itself like happens in .NET?

like image 436
Fer Avatar asked Jan 22 '26 01:01

Fer


1 Answers

The answer accourding to my needs is already here

I see that I just need to add new java class and add xml annoitions like @WebService and @WebMethod to make the class a web service. Then i just need to add following lines to publish this service:

public static void main(String[] args) {
        String address = "http://127.0.0.1:8023/_WebServiceDemo";
        Endpoint.publish(address, new MyWebService());
        System.out.println("Listening: " + address);

    }
like image 118
Fer Avatar answered Jan 24 '26 23:01

Fer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!