Monday, October 13, 2014

Creating Web service in Java EE


Server 

ejb <- add new package-> name it.--->clicl on package->new Session bean->statelss->local->finish.

In side the page Right clik->add business method->

Method name:Converter
Add-Parameter1-value,,Select data type fom drop down (double)
Return type : double

public class Convert implements ConvertLocal {

    @Override
    public double CelciusConvrtr(double value) {
        return ((value*9/5)+35);
    }

------------------------------------------------------------------------------------------------------------------

war<-Add new package->other->webservices->webservice->give a name->select create webservice from existing session bean->brows->select creates session bean->finish->Deploy
----------------------------------------------------------------------------------------------------------------
war->webservices->new webservice->Test service

----------------------------------------------------------------------------------------------------------------------

Client in Visual studio console

Get URL of generated WSDL

Cretae  console application->References->Add Service reference->Paste the URL->Click Go->OK

-------------------------------------------------------------------------------------------------------------------------
Main call the functions include in WSDL

WebserviceAppname-which dispay inside the references
ServicenameClient- .war pagename+Client

Main{
Webserviceappname.ServicenameClient dd=new Webserviceappname.Servicename();
       Console.writeline( dd.methodname(pass argument));
       Console.ReadLine();
}


Display on form(get the value from text box,Diplay Label)
private void button1_Click(object sender, EventArgs e)
        {
            ServiceReference1.tempConverterClient cc = new           ServiceReference1.tempConverterClient();
            label1.Text = cc.CtoF(Convert.ToDouble(textBox1.Text.ToString())).ToString();

        }
---------------------------------------------------------------------------------------------------------

Client in Net-beans console

Java application->add->webservices->webserviceclient->select WSDL url->Paste the URL
->finish

Go main page Click add new method by
Right click->Insert code->Call webservice method->Select the method you want

Call the method inside the main method(If there are parameters pass the relevent values)

----------------------------------------------------------------------------------------------------------
Reading a WSDL file


























No comments:

Post a Comment