How I may help
LinkedIn Profile Email me!
Call me using Skype client on your machine

Reload this page Web Services

This introduces basic concepts of web services.

 

Topics this page:

  • Web Services?
  • Categories
  • VS.NET Default Web Service
  • Web Service Caller
  • .NET Web Svc Proxy
  • Proxy Generation
  • .NET Proxy Generation
  • .NET Web Svc Proxy
  • IIS WS Publishing
  • Resources
  • Your comments???
  •  

    Site Map List all pages on this site 
    About this site About this site 
    Go to first topic Go to Bottom of this page


    Set this at top of window. What are Web Services?

      Web services are self-contained and self-describing application functionalities that can be processed through open internet standards.

      By offering data that can be consumed without human interaction, web services ...

      • act like a block box that may require input and deliver a result.
      • work on top of any communication technology stack (TCP).
      • can be published, discovered, and invoked base on open technology standards
      • work in asynchrounous as well as traditional synchronous scenarios
      • facilitate integration within an enterprise as well as across enterprises.

     


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set this at top of window. Categories of Web Services


    Go to Top of this page.
    Next topic this page

    Set screen Microsoft Web Communication Foundations

      With .NET 3.0, Microsoft introduced WCF (Web Communication Foundations) so that web services can be transported not just in HTTP, but other encodings, transports, and security mechanisms. These three concepts define a binding.

      1. Basic (HTTP over TCP/IP)
      2. TCP
      3. Peer networking
      4. IPC
      5. Web Service (WS)
      6. Federated WS
      7. Duplex WS
      8. MSMQ
      9. MSMQ integration

      Behind each endpoint address is its binding and contracts:

      1. Service contracts describe what operations clients can perform
      2. Operation contracts define methods inside Interface of Service
      3. Data contracts define what data types are passed.
      4. Message contracts define whether a service can interact directly with messages

      Microsoft provides a wcfTestClient.exe command-line tool to specify input parameters.


    Go to Top of this page.
    Next topic this page

    Set screen Microsoft .NET Web Service Proxy Architecture

      Microsoft Web Services A client.aspx web page contains calculations made by the web service and accesses the listener.asmx request handler file created as a C# or VB.NET language "ASP.NET Web Service Application" project in Visual Studio.

      The .asmx file references methods whose structure is defined in a web service proxy.dll library file running in a Virtual Directory within a IIS (Internet Information Service) service (named localhost by default) built into Windows Server. As a binary file, the .dll file is stored in physical folder C:\inetpub\wwwroot\bin so they are picked up automatically by ASP.NET.

      A Proxy is a stand-in for the real subject at compile time. A proxy has *the same interface* as the original object. A Remote Proxy provides a reference to an object residing in a separate address space, e.g. EJB, RMI, CORBA, etc. RMI stubs acts as a proxy for the skeleton objects. (By contrast, a facade *changes* the interface - generally to make it more coarse grained.)

      SOAP Request Message Structure

      The proxy .dll resolves methods defined in an XML file containing WSDL (Web Service Description Language) that describe how to access web services. The code for it is automatically created by the wsdl.exe program that is part of Microsoft's .NET framework 3.5 SDK (in folder C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin) (or \v6.0A for .NET 2.0).


    Go to Top of this page.
    Next topic this page

    Set screen WSDL (Web Services Description Language)

      WSDL (Web Services Description Language) are XML files containing descriptions of the methods available.

      They are contract between a server and its clients.

      Amazon's S3 WSDL http://s3.amazonaws.com/doc/2006-03-01/AmazonS3.wsdl references .xsd file.

      Specify this WSDL URL address to a project created in Visual Studio Solution Explorer: right click References, select Add Service Reference, "AmazonS3?" should show in the Services box. Enter a namespace (such as "Amazon.S3").


    Go to Top of this page.
    Next topic this page

    Set screen client.aspx

      This sample C# web service client code to invoke the Microsoft's UDDI service returns HTML which begins with this:

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope
          xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
          <businessList generic="1.0" operator="ms.com" truncated="false" 
      	     xmlns="urn:uddi-org:api">
            <businessInfos>
              <businessInfo businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
                <name>Microsoft DRMS Dev</name>
                <serviceInfos>
                  <serviceInfo serviceKey="6166f8b2-436d-4001-9f68-f37ff8b47ea3"
                      businessKey="c13cc7b2-642d-41d0-b2dd-7bb531a18997">
                    <name>Certification</name>
      ...
                  </serviceInfo>
                </serviceInfos>
              </businessInfo>
            </businessInfos>
          </businessList>
        </soap:Body>
      </soap:Envelope>
      

      Only text between <name> tags appear in the web browser.

      Commands in the Page_Load function are performed upon invocation.

      In Visual Studio, click on "Add Web Reference" to specify the URL and Name of the WebService.

      Setting the WebServiceBinding attribute's ConformsTo property to WsiProfiles.BasicProfile1_1 instructs Visual Studio to generate WSDL and ASMX files and other "behind-the-scenes" work, in accordance with the Basic Profile 1.1 (BP 1.1) best practices developed by the Web Services Interoperability Organization (WS-I), a group dedicated to promoting interoperability among Web services developed on different platforms with different programming languages.

      By default, each new Web service class created in Visual Studio inherits from class System.Web.Services.WebService.

      Yahoo weather XML feed.


    Go to Top of this page.
    Next topic this page

    Set screen WSDL Program

      C:\>wsdl /language:C# /out:MyProxyClass.cs  http://localhost/ASP.NET/MyWebService.asmx
      

        /protocol:SOAP specifies the payload protocol to be used (SOAP, HttpGet, HttpPost).

        /namespace:mynamespace specifies the namespace of the generated Proxy class.

      ASP.NET automatically creates WSDL and SOAP documents from .asmx code such as this VB.NET sample:

      <%@ WebService Language="VBScript" Class="TempConvert" %>
      Imports System
      Imports System.Web.Services
      Public Class TempConvert :Inherits WebService
      
      	<WebMethod()> Public Function FahrenheitToCelsius
      		(ByVal Fahrenheit As String) As String
      		dim fahr
      		fahr=trim(replace(Fahrenheit,",","."))
      		if fahr="" or IsNumeric(fahr)=false then return "Error"
      		return ((((fahr) - 32) / 9) * 5)
      	end function
      
      	<WebMethod()> Public Function CelsiusToFahrenheit
      		(ByVal Celsius As String) As String
      		dim cel
      		cel=trim(replace(Celsius,",","."))
      		if cel="" or IsNumeric(cel)=false then return "Error"
      		return ((((cel) * 9) / 5) + 32)
      	end function
      
      end class 'TempConvert
      

      SOAP Headers

      [SoapHeader("timeStamp", Direction=SoapHeaderDirection.InOut)]
      

      C# code such as this sample and this sample:

      <%@ WebService language="C#" class="TempConvert" %>
      using System;
      using System.Web.Services;
      using System.Xml.Serialization;
      
      [WebService(Namespace="http://localhost/MyWebServices/")]
      public class FirstService : WebService
      {
            [WebMethod(Description="Add integers")]
            public int Add(int a, int b)
            {
                return a + b;
            }
      
            [WebMethod(Description="Say Hello")]
            public String SayHello()
            {
                return "Hello World";
            }
      }
      

      In order for a client to access a Web method, it must be marked with [WebMethod] or [WebMethod()] compiler declarative attribute No method with this WebMethod attribute can be declared static because an instance of that Web service must exist for access by clients.


    Go to Top of this page.
    Next topic this page

    Set screen Web Service Consuming Amazon Web Service

      This and this C# client code issues SOAP to the Amazon S3 web service. This creates a object defined in the library specified by a using statement.

      using System;
      using System.IO; // for Console.WriteLine()
      using Amazon.com.amazon.soap;
      
      namespace SvcConsumer{
      class SvcEater{
          public static void Main(String[] args){ // for console program.
              
      		KeywordRequest kr = new KeywordRequest();
      		kr.devtag=getAmazonToken();
      		kr.keyword=this.txtSearch.Text;
      		kr.mode="books";
      		kr.sort="+titlerank";
      		kr.tag="webservices-20";
      		kr.type="lite";
      		
      		kr.page="1";
      		
      			ProductInfo pi = srch.KeywordSearchRequest(kr);
      			Details[] allDetails = pi.Details;
      
      			// showAmazonResult();
      		
      		// Did the request fail?
      		
      		if (pi.TotalResults > 10){ // get the second page of results
      			kr.page="2";
      		}
      			ProductInfo pi = srch.KeywordSearchRequest(kr);
      			Details[] allDetails = pi.Details;
      
      	} // Main
      } // class SvcEater
      
      getAmazonToken(){
      	return "1234567890";
      }
      
      showAmazonResult(){
      // Replace this code with application event coding:
      	//    Console.WriteLine("Calling Hello World Service: " +
      	//                        mySvc.SayHello());
      	//    Console.WriteLine("Calling Add(2, 3) Service: " +
      	//                        mySvc.Add(2, 3).ToString());
      }
      
      } // SvcConsumer
      

      Before invoking, change the number in function getAmazonToken() with what Amazona provided.

      For this application to parse XML content using XMLHTTP and DOM COM object xmlObj.loadXML(), the client machine is dependent on Microsoft XML Parser 3.0 being already installed.

      This sample SOAP client can also include SOAP Headers with Extensions shows a solution that passes authentication information out-of-band (that is, outside the Web methods' parameter lists) and that "front-ends" each method call with an authentication module that operates independently of the Web methods themselves.


    Go to Top of this page.
    Next topic this page

    Set screen UDDI WSDL Discovery

      Microsoft provides a utility to discover

      disco http://localhost:33973/Service1.asmx?DISCO

      If the .asmx file does not contain a namespace specification, Microsoft automatically defaults to the http://tempuri.org/ namespace.

      Microsoft's UDDI Services (Universal Description, Discovery and Integration) Business Registry (UBR).


    Go to Top of this page.


    Go to Top of this page.
    Next topic this page

    Set screen Calling Google Web Service


    Go to Top of this page.
    Next topic this page

    Set screen Visual Studio.NET Default Web Service

      Within Visual Studio 2008, create a new C# or VB.NET language project (solution) "ASP.NET Web Service Application" with default name WebService1 in default location C:\Users\W\Documents\Visual Studio 2008\Projects.

      using System;
      using System.Collections;
      using System.ComponentModel;
      using System.Data;
      using System.Linq;
      using System.Web;
      using System.Web.Services;
      using System.Web.Services.Protocols;
      using System.Xml.Linq;
      
      namespace WebService1
      {
          /// 
          /// Summary description for Service1
          /// 
          [WebService(Namespace = "http://tempuri.org/")]
          [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
          [ToolboxItem(false)]
          // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
          // [System.Web.Script.Services.ScriptService]
          public class Service1 : System.Web.Services.WebService
          {
              [WebMethod]
              public string HelloWorld()
              {
                  return "Hello World";
              }
          }
      }
      

      This sample web service has a "HelloWorld" operation using the default namespace at http://tempuri.org/.

      Press F5 to run it in a Development Server such as at http://localhost:33973/Service1.asmx.

      The HelloWorld operation is invoked upon page load by a client running IE and specifying the Service1.aspx file.

      <%@ import Namespace = "NameSp" %>
      <script language = "c#" runat = "server">
      public void Page_Load(object o, EventArgs e){
      	int x = 10;
      	int y = 5;
      	int sum;
      
      	AddNumbers AN = new AddNumbers();
      	sum = AN.Add(x,y);
      	string str = sum.ToString();
      	response.writeline(str);
      }
      </script>
      


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Proxy Generation from Assembly

      Either way, the proxy assembly is compiled into a .dll file using cs.exe.

      C:\>CSC  /t:library  /out:bin/MyWebServiceImpl.dll  MyWebServiceImpl.cs 
      

      Add /optimize to produce a smaller, faster, and more efficient dll.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen IIS Web Service Publishing

      To publish a Web Service, configure IIS running on a local machine.

      1. Open Internet Information Services (IIS) Manager from Start > Settings > Control Panel > Administrative Tools
      2. Expand Sites and right-click on [Default Web Site]
      3. Select Add (New) > Virtual Directory
      4. The Virtual Directory Creation Wizard opens. Click Next.
      5. The "Virtual Directory Alias" screen opens. Type the virtual directory name [MyWebServices] Click Next.
      6. The "Web Site Content Directory" screen opens. Enter the directory path name for the virtual directory. Click Next.
      7. The "Access Permission" screen opens. Change the settings as per your requirements. Click Next. Click Finish to complete the configuration.

      Ths sample creates a .NET Webservice in C# that screen scrapes the Microsoft Search Site for any search term. The results are parsed into a SOAP return call containing all the URLs and associated link titles for display.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Good ole SOAP

      Application
      Concept
      Web
      Standard
      Programs
      Data XML Universal data format Objects
      Schema XSD Universal type system Classes
      Directory UDDI Directory of Services
      Listing DISCO Service discovery
      Services WSDL Service descriptions Methods
      Services Invocation SOAP Calls
      Services Invocation REST Calls

    • Visual Studio SOAP toolkit for Microsoft Windows® 2000 (not Win 9x) can be download from
      • Versions:
        • Version 1 released July 2000 interoperates with Visual Studio.NET Beta 1 uses older Service Description Language (SDL) and scalar atomic data types using UTF-8 encoding based on Windows code page 1252.
        • Version 2 Beta 1 released January 2, 2001 based on SOAP Specification version 1.1, adds support for new Web Services Description Language (WSDL) 1.0 contracts to define the SOAP messages and service call formats; Universal Description, Discovery and Integration (UDDI), and the Version 2.0 will pass strings to BSTR parameters encoded as UTF-16.
        • The final release of SOAP Toolkit version 2.0 will be fully supported by Microsoft product support.
      • This requires Visual Studio SP 4.
      • The Listener provided is ASP, not ISAPI.
      • MSXML Parser 3.0 is included in the SOAP toolkit.
    • All this work done by developers will be hadled automatically by Microsoft's Visual Studio.NET which was distributed as Beta 1 on January 2001.

      Although VisualBasic.NET (also known as Visual Basic 7.0) features new Web Forms which are HTML pages with Visual Basic events (such as native support for accessibility). Microsoft recommends using it for business objects and use ASP.NET, an enhanced version of ASP, which uses Web Forms for interfacing with Web Services hosted by ASP.NET, which targets disconnected data. The Mobile Internet Toolkit is part of ASP.NET.

        The NET Framework SDK TDG (Tool Developer Guide) is included in the ASP.NET CD to manipulate new & old registry classes.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen Client ROPE Proxy

      A ROPE proxy serves a similiar function as WinSock, through which client software issue and receive communications to web services on a web server.

      If a SOAP client is on a different computer than the SOAP server, you will need to copy ROPE.dll from the Visual Studio SOAP Toolkit and register it on the client computer (tunning command regsvr32 rope.dll).

      The ROPE Proxy uses methods in COM objects written to SOAP standard which defines the "handshaking" between client and server.

      A client first sends a Services Description method ROPE.SDMethodInfo and other methods to discover what web services a particular server provides on this page

      The ROPE.SoapPackager object creates a SOAP envelope and calls

      It then calls ROPE.WireTransfer to execute HTTP GET and POST requests by calling methods AddStdSOAPHeaders and PostDataToURI using parameters DataSent and DataReceived.

      Web Serices Discovery

      methods in the ROPE.SDServiceDescriptors collection: <> ROPE.SDEndPointInfo describes the URI location of web services.

      ROPE.SDMethodInfo provides information about methods exposed by a Web Service.

      ROPE.SDParameterInfo then provides requirements for calling those methods.

      SDL = Service Description Language

      Here is a sample request.

      <SERVICE>
         <ADDRESSES>
         <ADDRESS URL='http://x.com/soap/Products.asp'>
         <IMPLEMENTS name='Products/'>
      </SERVICE>

      The SDL wizard can generate this.

      ASP

      XML references COM methods.

      <%@ language=VB Script %>
      <%Option Explicit

      ADO

      <element name='GetProductsResponse'>
       <type>
        <element name='ProductStruct'/>
        <element name='ProductID' type='dt:string'/>
        <element name='ProductName' type='dt:string'/>
       </type>
      <element>

      For XML Schema

     


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen WS (Web Services) Stack

      Microsoft's WSE (Web Services Enhancements) v2.0 download has been available since 6/2004. Installing for "VS Developer" provides additional configuration help.

      A lot of behavior is defined in the config.xml.

      Custom code obtains a reference to RequestSoapContext and/or ResponseSoapContext

      BooK: Understaing Web Services Specifications in the WSE pub. by Microsoft Press by Genine galey


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Portions ©Copyright 1996-2014 Wilson Mar. All rights reserved. | Privacy Policy |


    How I may help

    Send a message with your email client program


    Your rating of this page:
    Low High




    Your first name:

    Your family name:

    Your location (city, country):

    Your Email address: 



      Top of Page Go to top of page

    Thank you!