Before we learned how to create your own custom web service.Now we will learn how we can insert the data through the web service.

The attachment below is a Template project with some important classes that are already made in the template for you.
You can download and open the project in Visual Basic

DataExchangeWebService.sln

  • When you open the template project DataExchangeWebService you will see the following classes (Fig) which are already defined in the project.


The following 6 classes are important for the security issues and the tokens. You don't have to create these classes as we already made them in the template class

  • To add a new service reference to your project.
    1) Go to Solution Explorer
    2) Under your project right click on 
    Service Reference–>Add service reference–> paste your WSDL of your on the address

 

  • Letsseethe coding side ofyourcustomWebService
  • Some parameters that we need to set in our code to connect to java properly:
    - We use PortTypeClient after our service name to overcome the securities of java
    - Put yourcustomwebservicenamebeforehttp
  • Now we need to create a form and make a button on the form. 
    The buttonwillstarttransfering the data

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataExchangeWebService;
namespace DataExchangeWebService
{
    public partial class TestWebService : System.Web.UI.Page
    {
        TextBox text1;
        
        // PortTypeClient is used for security in java
        WebServiceTest.WebServiceTestPortTypeClient myService = null;
        WebServiceTest.StudentCard[] arrayApplication = null;
 
        protected void Page_Load(object sender, EventArgs e)
        {
             // before http we will write our service name
            myService = new WebServiceTest.WebServiceTestPortTypeClient("WebServiceTestHttpSoap11Endpoint");
            MyEndpointBehavior behavior = new MyEndpointBehavior();
            myService.Endpoint.Behaviors.Add(behavior);
        }
  //The button start transfering the data through web service
   protected void Button1_Click(object sender, EventArgs e)
        {
  // We created an instance MyItem and we call the class createMMBOItem
            WebServiceTest.MyItem item = new WebServiceTest.MyItem();
            item.code = "Item3";
            item.auxCode = "004";
            item.description = "abcd";
            myService.createMMBOItem(1, 1, "ENUS", item);
   }







  • Now under the button, we will create an instance for MyItem and we will call the class available on our web service i.e.createMMBOItem
  • Now run your project on a browser and you will see your ButtonStartTransfer on  your screen when you will press the button it will lead you to the MMBOController class and start 
    debugging to fetch the data.


Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım