Consuming Web services with Microsoft .NET

Part of BookMARC's TVS Model papers.

The new Microsoft development platform has a simple and straightforward way to consume webservices.

In the next steps we will see how this is done:

  1. Start by opening Visual Studio .NET
  2. Create a Windows Application Project
  3. Under the Solution Explorer right-click on the solution name and choose Add Web Reference
  4. Type the address where the web service is located: http://sirius.bn.pt
  5. We can choose the option View Contract to look at the web service description
  6. Add the web reference
  7. Add controls to the form, to get user input and display the results, and code to execute the services
  8. See the services description bellow for some code examples

Monitoring

Visual Studio .NET doesn't includes a TCP monitor. The Axis monitor can be used instead or you can download the Microsoft SOAP Toolkit from http://msdn.microsoft.com and use its Trace Utility.

If you're going to use the Axis monitor see Axis Monitoring.

Using the Microsoft SOAP Toolkit Trace Utility

  1. Execute the Trace Utility
  2. Add a new Formated Trace
  3. In the Trace Setup add the following values:
    1. Local port # - select a local port to be monitored (example: 9090)
    2. Destination host - sirius.bn.pt
    3. Destination port - 80
    4. Click Ok
  4. The monitor is ready, now we have to make a small change to the generated code:
    1. Open the Reference.vb file which is located in the project directory under Web References\pt.sirius.bn and change the Me.Url variable value to: http://localhost:9090/sirius/sirius2.exe
    2. Now we can see the SOAP request and the service SOAP response

Get Record by ISBN

Input parameters
  • isbn - String
Output parameters
  • marcXML - MarcXML object

Search

Input parameters
  • terms - Array of Strings.
    Each term identifies the search prefix, matches the corresponding value. See the next term list for details:
    • AS - Subject
    • AU - Author
    • DP - Publishing date
    • CDU - Universal Decimal Classification
    • ED - Publisher
    • COL - Series
    • ISBN - ISBN
    • TI - Title
    • empty term - Word search
  • values - Array of Strings.
    The values to search for. Values can be prefixed with logical operators to restrict the search result:
    • < - Lower than
    • > - Greater than
    • = - Equal to
    • <= - Lower than or equal to
    • >= - Greater than or equal to
  • precedences - Array of Integers
  • operators - Array of Strings.
    The pairs term-value are linked by the operator wich assumes the values AND, OR and AND NOT
  • pagesize - Integer. The number of records by page
  • pagenumber - Integer. The page number
Output parameters
  • marcXML - Array of MarcXML object