Search This Blog

Lets go..




Manage your Inventory | Grow your restaurant business | Manage your Employee | Control your accounts
Showing posts with label SOAP Client. Show all posts
Showing posts with label SOAP Client. Show all posts

Thursday

How to Create Web service and Consume web service in Web page


By: Mohammad Tuaha
How to Create Web service and Consume web service in Web page.

Or Create web service and consume web service

Requirement 
Visual Studio 2010 - up-to
 
Step 1: First create a website.
Step 2: Add new item web service file extension is .asmx

Step 3: In App_code Folder has à NewWebService_tut_1.cs file is the main web service operation file
Here is web service Method
  [WebMethod]
    public double Add(double x, double y)
    {
        return (x + y);
    }

    [WebMethod]
    public double Subtract(double x, double y)
    {
        return x - y;
    }

    [WebMethod]
    public double Multiply(double x, double y)
    {
        return x * y;
    }
It’s simple web service function. Now it’s ready to use Just build and RUN F5.
In my web service has two parameter one is X second is Y
Output is

How use it’s on web page
Step 4:
Open a new web project and add web reference.
Copy the web service url 
Add web Reference ànd paste Link into URL textbox


Step 5:
Now add two textbox and a button in Default.aspx page.

  protected void btnValueCalculation_Click(object sender, EventArgs e)
    {
        if (txtValue1.Text != string.Empty     && txtValue2.Text != string.Empty)
        {
            try
            {
                int x = Convert.ToInt32(txtValue1.Text);
                int y = Convert.ToInt32(txtValue2.Text);                               

              
                NewService.NewWebService_tut_1 service = new NewService.NewWebService_tut_1();
                lblAdd.Text = "Sum: " + service.Add(x, y).ToString();   
                lblSub.Text = "Difference: " + service.Subtract(x, y).ToString();
                lblmul.Text = "Multiplication: " + service.Multiply(x, y).ToString();
                lbldiv.Text = "Divide: " + service.Divide(x, y).ToString();
            }
            catch (Exception)
            {
                lblAdd.Text = "Please Fill Value ";
                  // Tuaha mohammad
            }
        }
    }

Now run your web project. User can use this web service any web platform any language like PHP ,jsp Asp 

Download Project

Next one is how to create web service with Database 



Difference Between Web Service and API

By: Mohammad  Tuaha


A Web service is merely (নিছক) an API wrapped in HTTP. An API doesn’t always need to be web based.
 An API consists of a complete set of rules and specifications for a software program to follow in order to facilitate interaction. A Web service might not contain a complete set of specifications and sometimes might not be able to perform all the tasks that may be possible from a complete API.


API and Web service serve as a means of communication. The only difference is that a Web service facilitates interaction between two machines over a network.
An API acts as an interface between two different applications so that they can communicate with each other.
All Web services are APIs but all APIs are not Web services.

Web service
API
A Web service always needs a network for its operation.

An API doesn't need a network for its operation.

Web services might not perform all the operations.


API would perform all the operations.

A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication.
API may use any style for communication.
A Web service is designed to have an interface that is depicted (ফোটানো) in a machine- process able format usually specified in Web Service Description Language (WSDL). Typically, “HTTP” is the most commonly used protocol for communication.
An API is a method by which the third-party vendors can write programs that interface easily with other programs.
In case of Web applications, the API used is web based. Desktop applications such as spreadsheets and word documents use VBA and COM-based APIs which don’t involve Web service. A server application such as Joomla may use a PHP-based API present within the server which doesn’t require Web service.
A web service typically offers a WSDL from which you can create client stubs automatically.
Web API can also be used to create OData services.
·         Web Services are based on the SOAP Protocol.

  
      Web services are based on standard defined by W3C.
·         Web API can be used to create any type of web service, most commonly RESTful services.
·         Web API can present the data in nearly any format not just JSON, or XML. (Csv, protobuf, streams etc.)
·         Web API is hosted in an OWIN framework.
·         Web API is easy to extend.





Enjoy Free code


Generate soap client from wsdl in Netbeans


By: Md Mahfuj Jia

Introduction: In previous tutorial we have seen, how to create soap web service using SpringWS and Apache CXF. After creating web service we need to consume and make a client for these web services. Your business layer is completely separate from client and main purpose of the client is creating request and get response.  For java, Netbeans is a fantastic tool for creating client from wsdl and in this tutorial we will see how to create client from wsdl and how to consume it.

Projects snapshots:

Image: 1 –This is our wsdl from previous tutorial and we will generate client from this wsdl.

Image: 2-3  -Steps of generating wsdl client.

Image: 4 –Output after generating client.

Image: 5 –Now we see the generated file in Netbeans.

Image: 6-8 –When client will generate, we see the generated source code contains xmlgorgioncalender date format and we need to convert this date format to java.util.date. For conversion, we need external binding file, which makes our client code serializable and convert the desire date format.

Image: 9 –To avoid this error, just clean and build the project in Netbeans.

Image: 10 –This is our main class. Here we will see how to consume service using wsdl client.






























 
Project Source Code:

Happy coding…