Web Service Project You are to develop – A currency converter XML web service

Web Service Project

You are to develop:

  1. A currency converter XML web service
  2. A web service client requesting the currency converter XML web service

The Currency Converter XML Web Service

  1. Create an ASP.net project named “WebServiceFall2019” (empty and non-HTTPS)
  2. Add a New Item: Web Service (ASMX) named CurrencyConvert.asmx
  3. Add the CurrencyConvert web service:<WebMethod()>

    Public Function CurrencyConvert(ByVal strCurrencyType As String, ByVal sngCurrencyIn As Single) As String

    Dim sngCurrencyOut As Single

    Select Case strCurrencyType

    Case “ca”

    sngCurrencyOut = CSng(sngCurrencyIn) * 1.1

    Case “jp”

    sngCurrencyOut = CSng(sngCurrencyIn) * 110

    End Select

    Return sngCurrencyOut

    End Function

  4. Run the web service in a browser from the Visual Studio
    1. You will see: http://localhost:xxxxx/CurrencyConvert.asmx
    2. View the Service Description (WSDL)
    3. Find the web service name: CurrencyConvert
    4. Find the two input parameters:

      <s:element name=”strCurrencyType” type=”s:string” maxOccurs=”1” minOccurs=”0“/>

      <s:element name=”sngCurrencyIn” type=”s:float” maxOccurs=”1” minOccurs=”1“/>

    5. Run the CurrencyConvert web service
      • Enter a value in the sngCurrencyIn textbox (“ca” or “jp”)
      • Enter a value in the strCurrencyType textbox
      • Invoke it and view the returned value in an XML
  5. Run the web service directly in a browser
    1. Install IIS with Windows 10
      • Go to “Turn Windows features on or off”
      • Check “Internet Information Services”
      • Check “World Wide Web Service”
    2. Create an Application in IIS
      • Go to “Administrative Tools”
      • Run “Internet Information Services (IIS) Manager”
      • Right click “Default Web Site”
      • Run “Add Application”
      • In the Alias box: “WebServiceFall2019”
      • In the Physical box: locate the path for WebServiceFall2019 (e.g., C:\inetpub\wwwroot\WebServiceFall2019)
      • Click OK
  6. Run the Currency Converter XML Web Service in a browser
      • In the URL box: enter “localhost/ WebServiceFall2019/CurrencyConvert.asmx”
      • Run the CurrencyConvert web service
        • Enter a value in the sngCurrencyIn textbox (“ca” or “jp”)
        • Enter a value in the strCurrencyType textbox
        • Invoke it and view the returned value in an XML

The Web Service Client

  1. Create an ASP.net project named “WebServiceFall2019Client” (empty and non-HTTPS)
  2. Create a Web Form named “Default.aspx”
  3. In the <div> and </div>, add the following web controls:<asp:TextBox ID=”tbCurrencyIn” runat=”server”></asp:TextBox><br />

    <asp:DropDownList ID=”ddlCurrencyType” runat=”server”>

    <asp:ListItem Selected=”True” Value=”ca”>Can</asp:ListItem>

    <asp:ListItem Value=”jp”>JP</asp:ListItem>

    </asp:DropDownList><br />

    <asp:Button ID=”btnConvert_Click” runat=”server” Text=”Button” /><br />

    <asp:Label ID=”lblCurrencyOut” runat=”server” Text=”Label”></asp:Label>

  4. Add a Web Reference
    1. In the Solution Explorer window, right click the project name “WebServiceFall2019Client”
    2. Run “Add” > “Service Reference” > “Advanced” > “Add Web Reference” (on the bottom)
    3. In the URL box: “http://localhost/WebServiceFall2019B/CurrencyConvert.asmx”
    4. In Web Reference Name box: “CurrencyConverterWebService”
    5. Click “Add Reference”
    6. Create a btnConvert_Click event for the btnConvert_Click
    7. Imports WebServiceFall2019Client. CurrencyConverterWebService
    8. Create a proxy object:

      Dim objWS As CurrencyConverterWebService.CurrencyConvert = New CurrencyConvert()

    9. Call the Convert web service: