Ch25

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ch25 as PDF for free.

More details

  • Words: 9,603
  • Pages: 41
Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Developing XML Web Services and Server ■ ■ ■ ■ ■ ■

Chapter 25 Chapter 26: Chapter 27: Chapter 28: Chapter 29 Chapter 30

The Technologies Windows Services .NET Remoting XML Services Data Again Security and Deployment

1 P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:17 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 /

Blind Folio 2

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:17 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

25

CHAPTER

The Technologies In this chapter, you will • Be introduced to SOAP, UDDI, XML, WSDL, XSLT, XPath, and XSD • Configure debugging in an XML web service • Implement logging in an XML web service • Implement tracing in an XML web service

This chapter introduces you to the concepts that we will be exploring in detail in this part of the book. In order to fully understand the questions you will see on Exam 70-320, “Developing XML Web Services and Server Components,” you must take the time to understand the protocols and alphabet soup that you see in this chapter’s objectives. Most of the questions are very detailed and explore complicated scenarios that will call upon your understanding of the technologies. As a result, you will see very little in this chapter that is directly on the exam; however, you will need to know this chapter inside and out to be successful on the exam. If you are fairly new to XML (Extensible Markup Language), be sure to review the information in Chapter 8. We will quickly review the concepts here, but we will also be going into the detail that is required for the 70-320 exam. A fair bit of this chapter will be spent on SOAP (Simple Object Access Protocol), and then we will briefly explore technologies such as UDDI, XSLT, XPath, and XSD. We will also take some time to review the testing methods for XML web services and server components. In Chapter 9, we looked at the generic concepts related to testing— creating a unit test plan, tracing, and so forth. In this chapter, we will specifically consider the testing of an XML web service. We will also look at the log test results. The focus of our work on testing in this chapter will be on debugging control within the web.config file and using SOAP extensions for debugging.

The Standards Many of the questions on the 70-320 exam describe complicated scenarios that require your understanding of the standards involved in server-based services. In this section, we will examine some of these standards and protocols. Here is a quick summary: • XML (Extensible Markup Language) A language that allows data and data definitions to be included in a structured document.

3 P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:17 AM

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

4 • SOAP (Simple Object Access Protocol) A lightweight protocol for exchanging information in a decentralized, distributed environment. • XML Web Services Application logic (components) that provide data and services to other applications. XML web services are accessed using web protocols such as HTTP, XML, and SOAP. • WSDL (Web Services Description Language) A language that describes a web service in terms of the messages that it accepts and creates. • UDDI (Universal Description, Discovery, and Integration) A method of publishing and discovering information about web services. UDDI provides a directory of web services. • XSL (Extensible Stylesheet Language) A style-sheet language that produces the presentation of data from the data content. It is a transformation language that is usually used to translate XML data content to HTML for displaying in a browser. • XSLT (Extensible Stylesheet Language Transformations) A component of XSL that transforms data content from one XML format to another XML format. • XPath A technology that addresses part of an XML document. It is used by XSLT. • XSD (XML Schema Reference) Files that allow you to define the structure and data types for XML documents. In this section, we will start with XML and work our way through the preceding list. Remember that most of the information in this section is provided as a reference for the material that comes after it. You will see very little on the exam that is directly related to this section.

XML (Extensible Markup Language) Hang onto your hats—we are going to cover in this section what took us all of Chapter 8 earlier. However, we understand that you might only be interested in this part, since you want to write the 70-320 exam, so we’ll give you the Reader’s Digest version of XML here.

What Is XML? XML stands for Extensible Markup Language and was designed to describe data. Since it is a markup language, it looks a little like HTML (Hypertext Markup Language), but it is not the same thing. HTML is used to display data and XML is used to describe data. XML uses tags that you define (or that a schema document defines) to define pieces of data within the XML document. The following is an example of an XML document: Chicken Soup Chicken Soup

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:18 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

5 This XML document does nothing except describe some data. Although it looks like HTML with its tags, it really does nothing. If you try to “open” this file in a browser, such as Internet Explorer, you will see the result shown in Figure 25-1. In order to display the data described in our XML document, we need a program that will do something with it. In reality, for the purposes of this part of the book, XML is a tool for transmitting data. We will find a way to send the data (SOAP). The data can be sent to any platform, any software or hardware, and be received there and processed. When data is described using XML, it can be easily transmitted through Internet protocols and received by any type of application at the server end. XML allows developers to spend less time worrying about how to move data and more time developing their applications. Businesses can use XML to exchange and share data (well, that’s been done for ages, but now the data is self-describing and is easily transmitted over the Internet). As an analogy, think of a word processing document. In the past, if you wanted to send the document to someone else, they had to have the same word processing program to read the document because the encoding must be read by that one application. With a standard way of describing data through XML, anyone can read the document.

XML Rules As a standard, XML boasts very simple and very tight syntax rules. Following these rules means that your XML document can be easily read and used. These rules are as follows: • The first line in the document is an XML declaration describing the version and encoding:

Figure 25-1 The XML document in Internet Explorer

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:18 AM

PART V

• There can only be one root element. An element is a tag that describes the data, and in a well-formed XML document, there is only one root element. The root element in our example is .

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

6 • All other elements are considered children of the root element. Therefore, is a child element. • XML elements must have closing tags: Chicken Soup

The element is closed using . • XML tags are case sensitive. This means that the tag is different from the tag . • XML elements must be properly nested. For example, the following XML is invalid because the is not closed within the tag. Chicken Soup Chicken


• Attribute values must be in quotes. An attribute describes name-value pairs within an element tag. For example, Chicken Soup

In the preceding line, serves is an attribute that doesn’t need it’s own element tag. • Comments are coded as follows:

XML Elements Elements are the most common type of markup that you will see in an XML document. Elements describe the data and formulate the hierarchy of the data in the document. Tags are used to define data elements. In between the start tag, <element_name>, and the end tag, , is the actual text or data that belongs to the element. In this example, Chicken Soup is the data: Chicken Soup

Elements can be hierarchical. This means that you can have child elements of an element. In our earlier example, was a child of , and was a child of . To be more correct, you may want to formulate the XML document like this: Chicken Soup Chicken Soup

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:18 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

7 In this case, is a child of , which is a child of . Notice that this document follows the rules of the previous section, in that there is one and only one root element—. Element names must conform to the following rules: • They must contain letters, numbers, or other characters. • They must not start with a number or punctuation character. • They must not start with the letters “xml” (in any case combination). • They cannot contain spaces.

XML Attributes An XML attribute can be used to give more information about the data. However, an attribute is not an element. Rather, it is a part of the element and gives more information about the element. In the earlier example, we used this line to describe the data regarding the name of the recipe: Chicken Soup

We could add an attribute (which is simply a named pair of values) to give more information about the name of the recipe:
SOAP (Simple Object Access Protocol) At the time of writing, the SOAP protocol is at version 1.1 and the specifications for the protocol can be found at http://www.w3.org/TR/SOAP. The official definition of SOAP is “a lightweight protocol for exchange of information in a decentralized, distributed environment.” In this section, we will examine the protocol in detail.

What Is SOAP? Many developers were keen to anticipate the release of SOAP since they were looking for a method of using RPCs (remote procedure calls) over HTTP (Hypertext Transfer Protocol). Remote procedure calls are used by many different distributed solutions to define the way requests and data are transmitted from one application to another. This means that one program can request the services of another program that is located on a remote system. The calling program (client) does not need to understand the network details. How the request gets there is unimportant to the client.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:18 AM

PART V

Category is the attribute, and it is followed with an equals sign (=) and double quotes surrounding the value. You can use either double or single quotes to surround the attribute value, but they must match. For more information on XML, refer back to Chapter 8. However, keep in mind that this book’s intention is not to teach you XML. You simply have to know how it is formed and how it is used in web services or server components.

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

8 Using RPCs entails the use of stubs, which are compiled into the client code and act as the local representative of the called code (which is on the server). The stub actually receives the client request and marshals it to the server. The server then intercepts the request, processes the call, wraps the results up (using a proxy—a representative of the server) and marshals them back to the stub. One of the problems with using RPCs is that HTTP does not support them. This means that typically firewalls will block RPC calls. Using HTTP means that port 80, which is usually open on a firewall, can be used for remote calls. So is this SOAP?—a method of using RPCs over HTTP? Not really, although that is certainly part of the specification. SOAP is “a lightweight protocol that passes structured data between applications using XML.” It doesn’t matter what transports the data. HTTP can be used, SMTP (Simple Mail Transfer Protocol) can be used—SOAP simply defines the way in which the message is constructed. How it is transported is immaterial.

The Three Faces of SOAP SOAP is an XML-based protocol that is made up of three parts: • The envelope The envelope describes what is in the SOAP message and explains how the message can be processed. • The encoding rules The encoding rules define the serialization mechanism (encoding, sending, and decoding) that can be used to exchange the data. • The RPC representation This is the convention that can be used to represent remote procedure calls and the responses from the server. Let’s look at how a SOAP message is created, and how the mechanism works. The Envelope Every SOAP message is an XML document. The document includes an XML envelope element, which is the root element (see Chapter 8 for the definition of root elements). The envelope element optionally may contain a header element, but must contain a body element. If a header is not used, the body element must be the immediate child of the envelope element. EXAM TIP A SOAP message is made up of (1) the envelope, the top element in the XML document that represents the message; (2) the header, an optional element that includes definitions of extra features; and (3) the body, a mandatory element that contains the message. The SOAP header is used to describe extra information regarding the message but will not directly affect the message. Some of the information that you might find in a SOAP header includes the following: • Transaction information • Authentication information • Language, country, currency, etc.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:18 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

9 • Next recipient of the message • State information to be carried between requests The SOAP body is the actual message that is intended for the recipient of the message. The body element will contain multiple child elements, which are called body entries. SOAP Encoding Serialization (the rules for representing types such as integers, strings, and so forth) of data inside a SOAP message is called encoding. You can use an attribute called encodingStyle within the Envelope element to identify the encoding rules. Encoding style can be defined right down to a specific element, if you want. However, we won’t spend too much time on this concept because you’ll begin to think that the “Simple” in SOAP is a misnomer. There is no default encoding style, but you can use the SOAP specification’s set of encoding rules. These will work well in most cases since they map nicely to most programming types. The SOAP encoding rules are found at http://schemas.xmlsoap.org/soap/ encoding/. To read more on SOAP encoding, refer to the SOAP specifications at http:// www.w3.org/TR/SOAP. Section 5 covers the rules for encoding types in XML, simple types, strings, enumerations, compound types, arrays, structs, and references. RPC Representation The final piece that brings the picture together is the representation that defines the convention that can be used to represent method calls and responses. For the purposes of this part of the book, we will cover SOAP in HTTP. Keep in mind, however, that SOAP can be used for remote procedure calls (RPCs). The SOAP specification (http://www.w3.org/TR/SOAP) covers both of these.

Figure 25-2 shows how a SOAP message is constructed. Notice that HTTP (the transportation protocol) wraps the entire message. Within the package is the SOAP document, and it contains an optional header with delivery information and a mandatory body with the actual method parameters.

Figure 25-2

SOAP message structure

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:19 AM

PART V

The SOAP Message

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

10 A very simple SOAP message would look like this: <SOAP:Envelope xmlns=http://schemas.xmlsoap.org/soap/envelope/> <SOAP:Body> <m:helloWorld xmlns:m="http://www.osborne.com/"/>

If we take this message apart, we have the following: • An envelope element starting with <SOAP:Envelope and ending with • The namespace URL, which is determined by xmls=http:// schemas.xmlsoap.org/soap/envelope. The elements and attributes are defined at that location. • The next element (defined by the schema) is <SOAP:Body>. • Following the declaration of the body element is the actual remote method call—m:helloWorld. The “m” represents the namespace of the method call and is defined in the namespace declaration xmlns:m="http://www.osborne.com/" Note that if you go to the namespace URL (http://schemas.xmlsoap.org/ soap/envelope) mentioned in the second point above, you will find something that looks like this: <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:tns=http://schemas.xmlsoap.org/soap/envelope/ targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"> - <xs:element name="Envelope" type="tns:Envelope" /> <xs:complexType name="Envelope"> <xs:sequence> <xs:element ref="tns:Header" minOccurs="0" /> <xs:element ref="tns:Body" minOccurs="1" /> <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> <xs:anyAttribute namespace="##other" processContents="lax" /> <xs:element name="Header" type="tns:Header" /> - <xs:complexType name="Header"> - <xs:sequence> <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> <xs:element name="Body" type="tns:Body" /> - <xs:complexType name="Body"> - <xs:sequence> <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> - <xs:anyAttribute namespace="##any" processContents="lax"> - <xs:annotation>

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:19 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

11 <xs:documentation>Prose in the spec does not specify that attributes are allowed on the Body element

In this code you can see the schema that describes some of the elements and attributes that will be included in your SOAP document. For the complete schema, go to http:// schemas.xmlsoap.org/soap/envelope. Here is a template for a SOAP message: <SOAP:Envelope xmlns:"http://schemas.xmlsoap.org/soap/envelope/"

SOAP in HTTP Developers can use SOAP within HTTP. SOAP and HTTP are a natural fit, since they both use a request/response messaging model. In this section, we will examine how you can bind SOAP to the network protocol, HTTP. Keep in mind that a lot of this is beneath the surface of what you see when you code using Visual Studio .NET and create web services. SOAP allows you to embed method calls within an XML document and have those calls transmitted over HTTP. Here are the steps: 1. The client identifies the server by its URL. 2. The TCP/IP network protocol, HTTP, is used to connect to the server. 3. The HTTP request message has a SOAP request embedded within it. 4. The SOAP request is then “bound” to HTTP.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:19 AM

PART V

soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP:Header> --> <SOAP:Body> --> <SOAP:Fault> SOAP:Server Server Error -->

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

12 Here is a simple SOAP HTTP header: POST /objectURI HTTP/1.1 HOST: www.osborne.com SOAPMethodName: namespace:IRecipe#getRecipe Content-Type: text/xml Content-Length: xxxx

The header indicates that the getRecipe method (found in namespace:IRecipe) should be called from server www.osborne.com. The corresponding SOAP document would include the following: <SOAP:Envelope xmlns:"http://schemas.xmlsoap.org/soap/envelope/> <SOAP:Body> <m:getRecipe xmlns:m="namespace:IRecipe"> Chicken Soup

Notice that within the <SOAP:Body> element, the element <m:getRecipe> matches the SOAPMethodName in the HTTP header. (Remember that <m:getRecipe> translates into .) Because of this, the code within HTTP can be used to process the call on the server side without having to parse the XML first. We have added one more element to the SOAP message—. This is the parameter information that the method getRecipe is expecting. So, what happens at the server side? The SOAP protocol doesn’t really care. The request may be to an ASP page or any other server component, such as Java Server Pages, CGI programs, Apache modules, and so on. The point here is that it doesn’t matter what is on the server side. That’s the beauty of SOAP—it’s transparent to the server. Issues like interoperability, firewalls, and the like all disappear by using SOAP. This is a very simplified explanation of SOAP, mainly because you don’t need to know all of the mechanics behind it. EXAM TIP Microsoft will ask you questions regarding the protocol to use when requesting services outside of the local application. Your answer very often should be SOAP. Read the question carefully and ensure that SOAP will answer the problem. The response from the server is embedded in an HTTP response message.

Things to Remember About SOAP SOAP messages are made up of the following parts: • Envelope

This is the mandatory root element of a SOAP document.

• Header This is an optional element that provides extra information to the server.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:19 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

13 • Body This is a mandatory element that contains the actual data of the message. • Fault This is an optional element that describes the error messages that the server can provide to the client. SOAP messages are embedded in an HTTP request. The message is sent to the server identified by its URL in the message. Figure 24-3 illustrates the process. SOAP in HTTP is used to provide an interoperable, standards-driven, and flexible transmission of message calls between a client and a server. XML web services use SOAP as the protocol for network messages. These messages can pass data and use complex structures, such as objects and structures.

XML Web Services XML Web Services is Microsoft’s latest entry into the remote execution of application code in a multi-tiered application. In a multi-tiered application, the client request is generated by one application and sent to a server for processing through a transmission protocol. There can be many different machines involved in the process or, in the simplest sense of the term, everything could happen on a single machine. Figure 25-4 illustrates the relationship between the different pieces of the multi-tier puzzle. The web service architecture begins with the XML web service consumer, as shown in Figure 25-4. The client can be a browser program (such as Internet Explorer), a Windows application, or a console application. The client makes a request of a web service broker, which acts like a directory service and looks up the location of the web service. (This step can be avoided if the location is hard-coded for the client.) The location is the URL address PART V

Figure 25-3

The SOAP message process

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:19 AM

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

14

Figure 25-4

Web services at work

of the web service provider. The location is returned to the consumer, who then makes the remote call to the web service provider. The provider services the request and returns the response to the consumer. XML web services use HTTP, XML, and SOAP. Since the protocols are easily transferred throughout the World Wide Web, XML web services are gaining in popularity and will ultimately replace many of the older standards, such as DCOM, CORBA, and so forth. XML web services can be used by virtually any application since the technologies are platform-independent. It is not always necessary to use XML web services—XML web services operate at a higher level of networking, which requires extra overhead. However, if you have little or no control over the location of the client or the server, you will find that the answer to platform limitations is to use XML web services. The web service consumer must be able to create the messages that are destined for the web service and understand the messages that are returned from the web service. Although it is possible to do the coding yourself, it is much easier to allow the .NET Framework to build the proxy class that will encapsulate the message-parsing and creation code. The idea behind a proxy is that it works on behalf of the application and acts as a go-between between the technology and the application.

WSDL (Web Services Description Language) The Web Services Description Language is used to describe a web service in terms of the messages that it creates and accepts. The WSDL document is an XML file that contains the interface schema for the web service; it identifies the methods that are used in the exchange between a web service consumer and a web service provider. Essentially, it is a file that contains a whole lot of definitions. These are the elements in the WSDL document:

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:20 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

15 • Types These XML elements describe the various data types that are used to exchange messages between the consumer and the provider. • Message

This XML element describes the actual message or method call.

• portType • binding • service

This element describes the set of operations and each related message. The binding elements describe the protocol details.

This element groups a set of related ports together.

Unless you like to type, you can get the .NET Framework to generate this file for you. Let’s look at creating a simple web service.

Creating a Web Service We will use Visual Studio .NET to create an XML web service, since it contains all of the tools to generate the surrounding documents. For the full details on creating and consuming XML web services, refer to Chapter 28. We will use the web service that is created in that chapter for our example. Follow these steps to create a simple web service provider: 1. Open a new ASP.NET Web Service project in Visual Studio .NET, and name it CImperial. Be sure to locate the project on the localhost server (or your web server of choice). 2. Rename the file to Imperial.asmx in the Solution Explorer.

PART V

3. Remove the comments from the HelloWorld() method.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:20 AM

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

16 4. Test the web service (press F5). You will see the information page displayed in Internet Explorer, as shown in Figure 25-5. Notice the SOAP request and response code. 5. Click the Invoke button, and you will see the XML document that represents the return value from the HelloWorld() method (see Figure 25-6).

Figure 25-5

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:20 AM

The web service information page

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

17

Figure 25-6

6.

The XML document with the return value

Add the code to tell the service its namespace (see Figure 25-7). This step is required to locate the service correctly.

7. Build and run the solution (F5) and click on the Service Description link that appears in the web browser. You will see the WSDL file that has been created for you. You can see in Figure 25-8 that the methods have been described in this file. This document is the contract between the provider and the consumer of the web service.

PART V

Figure 25-7

Adding the web service namespace

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:20 AM

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

18

Figure 25-8

The WSDL document

Now that you have created the web service provider, you need to build the client. The following steps describe how build the client (the web service consumer):

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:20 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

19 1. Open a new Visual Studio Windows Application project, call it Practice, and locate it on the localhost. 2. Add a new button to the form, and change its Text property to read Call on a Web Service. 3. In Solution Explorer, right-click on the project name and select Add Web Reference from the menu. The Add Web Reference dialog box will open. Type http://localhost/CImperial/Imperial.asmx in the Address field.

PART V

4. Press ENTER, and you will see the window shown in the following illustration. This window allows you to select from the web services found at the location in

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:20 AM

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

20 the Address box. In this case, there is only one web service, called HelloWorld. Click the Add Reference button to add the web reference to your project.

5. When you expand the Web References and localhost sections in the Solution Explorer, you will see the WSDL file that has been created for you.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:21 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

21

6. Add the following code to the button: localhost.Service1 s = new localhost.Service1(); MessageBox.Show (s.HelloWorld());

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:21 AM

PART V

7. Finally, press F5 to build and run the project. Click on the button to instantiate a new instance of the web service and then call on its HelloWorld() method. The result is shown in the following illustration.

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

22 This section has demonstrated the simple creation and consumption of a web service. For more details and exam-specific information, read Chapter 28.

UDDI (Universal Description, Discovery, and Integration) In our previous example of creating and consuming a web service, we kept the actual service component on the local machine (http://localhost/CImperial/Imperial.asmx). In reality, the service will likely be hosted on a remote server. The process of locating (or discovering) documents that describe XML web services using WSDL is called web service discovery. Chapter 28 goes into the details of static and dynamic discovery, but for the purposes of an introduction, here is the difference: • Static discovery This means that a discovery document (with an extension of .disco) can be found and interpreted. The discovery document contains the information necessary to describe the services that are located at the server endpoint (in our example, localhost). • Dynamic discovery In this case, the consumer application does not know any location information. Instead, all that is known is the endpoint (the web service provider). Dynamic discovery is not enabled by default and must be turned on within the configuration files (either in machine.config or web.config). Refer to Chapter 28 for more information. EXAM TIP A static discovery document can usually be identified by its .disco extension. A dynamic discovery document usually has an extension of .vsdisco. Consider the World Wide Web and all of the services located there. How is an application developer to find out about the web services that are available? In order to help in the search for XML web services, XML web service directories are used. Web services are published to the directories, and the information is then available to any queries. The UDDI (Universal Description, Discovery, and Integration) specifications define the standards for publishing and discovering information about XML web services. These standards have been built in cooperation with companies such as Microsoft, Ariba, Novell, and IBM (to name but a few). For more information on the UDDI specifications, visit http://uddi.org/.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:21 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

23 Two services are provided by UDDI: • XML Schema for Business Descriptions includes information about the service publisher (contact name, address, and so on) and specifications on the web service. • Web Registry of Web Services includes business, service, and binding information for the web service. Think of UDDI as a yellow-pages service. Businesses register their web services with UDDI, which in turn publishes them for use by consumer applications. The consumer applications can then search for the available web services and receive information about them. Let’s look at the process of discovering information about web services. The following steps describe what happens when a consumer application searches for and finds a web service directory: 1. The web service consumer application searches for a service by sending a request to a UDDI to locate the service. (UDDI is actually a web service that allows a request to drill down into the directory.) 2. UDDI returns a link to the service description. 3. The consumer then connects to the returned link and requests the service description.

5. The consumer then requests that a method be executed by sending a SOAP message that encompasses the SOAP request for the method. 6. The provider then returns a SOAP response with the results of the method invocation. In the HelloWorld consumer example created in the “Creating a Web Service” section of the chapter, you right-clicked on the project and selected Add Web Reference from the menu, and you saw the screen shown in the following illustration. Notice that, there are currently two UDDI directories listed there—the UDDI Business Registry and the Microsoft development directory. When you select the UDDI Business Registry, you will

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:21 AM

PART V

4. The web service returns the WSDL file, which is a contract between the consumer and the provider and contains the description of the actual web service (as explained earlier in the chapter).

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

24 be redirected to http://uddi.microsoft.com/visualstudio/, and from there you can type in the business name and press ENTER.

In the following illustration, we typed in Microsoft as the business name and then expanded the root UDDI Web Services to receive the namespaces you see in the list.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:21 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

25

This is simply an example of how the process works when you statically select a UDDI directory. Remember that dynamic discovery will return information about web services that might not be statically known.

XSD, XSLT, and XPath In this section, we will quickly introduce the renaming acronyms that may be subject to testing on the Microsoft exam. Remember that you will not be tested directly on these technologies. Rather, you can expect to see the acronym in a question, and you must understand the context under which it is used.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:21 AM

PART V

EXAM TIP To add discovery capabilities to your .NET application, add the System.Web.Services.Discovery namespace to the application.

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

26 XSD (XML Schema Definition Language) The World Wide Web consortium published a recommended standard in 2001 for XML Schema Definition Language (XSD). (Refer to Chapter 8 for more information on XSD.) This standard should bring a level of consistency to software development, and Microsoft has chosen to accept the standard in its XML parser, which supports XSD. An XML parser is an application that can read XML and render it to the reader. For example, a parser would be needed to display the XML data in a web browser—remember that, by default, the browser will only show the XML code, because XML by itself does not display data, it simply describes data. An XML parser can be used to display the data, and until now, those parsers have understood DTDs (Document Type Definitions). XSD schemas will eventually replace DTDs and XDRs (Microsoft XML-Data Reduced schemas). You may find that you will still have to support both of these methods of defining the XML grammar; however, the push is to move towards XSD. The .NET Framework provides a great deal of support for XSD. Let’s return to the simple XML file we looked at earlier in the chapter: Chicken Soup Chicken Soup

We can take this file and add the XSD to it, as follows: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="Recipe" type="RecipeType"/> <xsd:simpleType name="RecipeType"> <xsd:sequence> <xsd:element name="RecipeName" type="xsd:string"/> <xsd:simpleType name="Ingredient">

We could start to make a lot of mistakes by doing it this way. Let’s look at how Visual Studio .NET assists us in the process: 1. Open a new file in Visual Studio (File | New File). This file can be added to an existing project or be created on its own. You will see the New File dialog box.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

27

2. Select XML Schema from the list of templates and click Open. 3. The new file is shown in Figure 25-9. Notice that the Toolbox has a new tab— XML Schema. From the Toolbox, you can select and drag any of the following XML Schema descriptors to the Design window: element, attribute, attributeGroup, complexType, and so forth.

In order to link your XML file to the XSD file, add the following to the recipe.xml file: Chicken Soup Chicken Soup

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

PART V

4. Experiment by adding a complexType called Recipes, and insert the element’s name and ingredient. When you switch over to the code window, you will see the code shown in Figure 25-10.

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

28

Figure 25-9

Adding XML schema descriptors

Notice that in this example we have no namespace for the XML. We are simply pointing to the local filesystem for the .xsd file. Properly formed XML and XSD would include namespaces to identify locations.

XSLT (Extensible Stylesheet Language Transformations) Simply put, XSLT is a technology that transforms the content in one XML document into a new XML document. By using XSLT, you can parse an XML document and create a new document that uses the data differently. For example, the new document may contain values calculated from the old XML document. XSLT can also be used to create HTML, which can then render the XML source document in a web browser.

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

Chapter 25: The Technologies

29

Figure 25-10

The XML schema definition file

Chicken Soup Chicken Soup

The next step is to build the simple XSLT style sheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/">

P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

PART V

XSLT documents are stored in style sheets that are used to transform the XML data. Let’s look at our recipe XML file and combine it with an XSL style sheet.

Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

25

MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

30 <xsl:apply-templates/> <xsl:template match="recipe"> <xsl:apply-templates/> <xsl:template match="name">

<xsl:value-of select="."/>

<xsl:template match="ingredient">
  • <xsl:value-of select="."/>


  • Once a parser program (such as MSXML) works through the XML file, it outputs an HTML file, as shown here:

    Chicken Soup

  • Chicken
  • Soup


  • The style sheet contains the templates that tell the parser how to process the XML. These templates could tell the parser to work with the data or, as in our example, create the HTML to display the data.

    XPath (XML Path Language) XML Path Language (XPath) allows you to create expressions that can address sections of an XML document. Using XPath, you can manipulate strings, numbers, and so forth. XPath is used by XSL Transformations (XSLT), covered in the previous section. When XSLT is working through parts of an XML document, it uses XPath to select a portion of the XML document by using expressions to query for particular elements in the document. For example, in our demonstration in the previous section, <xsl:template match="/"> is an XPath expression that says “find the beginning of the XML document” (or the first line following the XML declarations).

    System.XML Namespace In order to use these technologies programmatically, you need to know the classes that represent them. The System.XML.XSL namespace is where you will find the classes that are used to perform XSLT transformations. These include

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

    Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    Chapter 25: The Technologies

    31 • XslTransform

    Used to perform transformations.

    • XsltArgumentList

    Used to pass arguments to the transformation.

    The System.Xml.XPath namespace contains the classes that allow XPath expression parsing and evaluating. Look for • XPathDocument

    Used to perform XSLT transformations.

    • XPathExpression • XPathNavigator

    Used to represent XPath expressions. Used to access XML documents with XPath expressions.

    This whole section has been a quick introduction to the technologies that you will use with XML. Keep the various acronyms in mind as you go through the rest of the chapters in this part of the book. You will be able to see where they are used and how they are used as we cover the requirements for exam 70-320.

    Logging Test Results and Debugging

    Control Debugging in web.config In order to test your web service within Visual Studio .NET, you need to make sure that the web.config file is set up properly. The web.config file is a configuration file that contains XML code specific to the settings of your application. In the Solution Explorer, double-click the web.config file to look at the configuration file (see Figure 25-11). Make sure that the debug attribute of the compilation element is set to True, as follows:

    EXAM TIP By setting the debug attribute to True, the debug information will be compiled into your solution. Be sure to change this attribute before you deploy your application.

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

    PART V

    We have included a section in this chapter on testing and debugging, since the Microsoft exam requires that you understand how to test your services. This can include testing of web services, Windows services, .NET remoting objecting, and so forth. Each will be covered in their respective chapter and, of course, Chapter 9 introduces the concepts of testing and debugging. However, in this chapter, we will deal with XML Web Services and configuring debugging and testing for your web services. We will look at logging test results since that is the focus of the Microsoft 70-320 exam. However, remember that you should become comfortable with debugging the services that you create, and you will find that information in the chapters that focus on each service. The next chapter, for instance, is on Windows Services, and you will find a section on testing in that chapter.

    Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

    32

    Figure 25-11

    The web.config file

    You should also ensure that the project configuration shows ASP.NET Debugging as enabled. Right-click on the project in Solution Explorer and select Properties from the menu. You will see the Property Pages dialog box shown in the following illustration. Select the Configuration Properties on the left side, and set the Enable ASP.NET Debugging option to True.

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:22 AM

    Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    Chapter 25: The Technologies

    33

    Logging Test Results in an XML Web Service

    using System.Diagnostics

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    PART V

    Log entries can be written into the Application Log (viewed by using the Event Viewer— see Figure 25-12). A network administrator can then track the errors that might need to be resolved by looking at the Application Log. As the developer, you must write pertinent information to the log file without recording too many events that would cause the file to explode. In order to write to the Application Log, add the following namespace declaration:

    Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

    34

    Figure 25-12

    Viewing the Application Log in the Event Viewer

    The System.Diagnostics namespace contains classes that allow you to write to the Application Log. In the section of your web service, locate the method that contains the error (or write an error-handling routine) and add the following: // Create a string that contains the error message and code string strMessage = "Error message from my web service"; string strLogName = "Application"; // test if the event log exists // if it doesn’t exist, create it if (!EventLog.SourceExists (strLogName)) { EventLog.CreateEventSource (strLogName, strLogName); } // Instantiate an EventLog object and insert the message EventLog l = new EventLog(); l.Source = strLogName; l.WriteEntry (strMessage, EventLogEntryType.Error);

    This method will now write a message out to the Application Log after checking if the log file actually exists first. If the log file does not exist, this method will create it with this line: EventLog.CreateEventSource (strLogName, strLogName);

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    Chapter 25: The Technologies

    35 The EventLog class also contains a method that will write the message out to the Application Log file: l.WriteEntry (strMessage, EventLogEntryType.Error);

    Implementing Tracing in an XML Web Service While implementing debugging during production is an excellent way of proving the validity of your application, it is a terrible way to ensure application success during production. During production, your application must stay up and running. However, in order to provide more information than what is written out to the application log, you can implement tracing. Tracing allows a production environment to benefit from reporting on errors and exceptions while not compromising the success of the application. Refer to Chapter 9 for a full description of implementing tracing within Microsoft .NET applications. To implement tracing within your XML web service, you need to write the tracing code within the application and then set the production environment to either implement it or not. That way, the code stays with the application, but it will not execute unless the environment tells it to. For example, you can code the following anywhere within your XML web service: if (HttpContext.Current.Trace.IsEnabled == True) { HttpContext.Current.Trace.Write ("MyWebService", "We are here!"); }



    Turn off the pageOutput property, since normally this tracing is found at the bottom of an HTML page. An XML web service is not typically outputting any HTML, so the information will not be seen.

    Summary In this chapter, we have provided you with an introduction to the technologies that will be explored throughout this part of the book. We have looked at XML again and reviewed the technologies associated with it. We have also explored the concepts and implementation of Simple Object Access Protocol (SOAP). EXAM TIP Remember that these technologies, SOAP, HTTP, and XML, work together to provide XML web services.

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    PART V

    This code will check the context under which the service is running (the configuration file sets the context) and determine whether it should write the tracing information out or not. To set the runtime environment, code the following in the web.config file:

    Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

    36 In Chapter 28, you will look in depth at XML Web Services, which is a large focus of the 70-320 exam. In this chapter, we explored the overall process and talked about the three components—web service provider, web service consumer, and web service broker. Be very sure that you are comfortable with all of these technologies before moving on in this part of the book. In the next chapter, we will introduce Windows Services, the first service in three services covered by the 70-320 exam—Windows Services, .NET Remoting Services, and XML Web Services. Later in this part of the book, we will revisit data access as it applies to server components. Finally, we will end Part V with security and deployment.

    Test Questions 1. What is the result of opening the following XML file in Internet Explorer? <Title> All-in-One Certification Guide

    A. The file will not open because it is not well-formed XML. B. Figure 25-13. C. Figure 25-14. D. An XML file cannot be opened by Internet Explorer.

    Figure 25-13

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    Answer B

    Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    Chapter 25: The Technologies

    37

    Figure 25-14

    Answer C

    2. Which line of code will write an event out to an Event Log file? A. EventLog.CreateEventSource (strLogName, strMessage); B. EventLog.WriteEntry (strMessage, EventLogEntryType.Error); C. eventLogInstance.WriteEntry (strMessage, EventLogEntryType.Error);

    3. Which namespace must be added to the XML web service in order to write to an event log? A. System.EventLog B. System.Events C. System.Diagnostics D. System.Diagnostics.Event 4. Which technology allows you to publish XML web services? A. XMLPub B. XSLT C. XPath D. UDDI

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    PART V

    D. EventLog.Source = eventLogInstance.WriteEntry (strMessage, EventLogEntryType.Error);

    Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

    38 5. Which of the following SOAP messages will result in a valid message transfer? Choose all that apply. A. <SOAP:Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Header> <SOAP:Body> <m:MyMethodCall xmlns:m="http://localhost" /> <SOAP:Body> <m:MyMethodCall2 xmlns:m="http://localhost" />
    B. <SOAP:Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Header> <SOAP:Body> <m:MyMethodCall xmlns:m="http://localhost" />
    C. <SOAP:Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Header>
    D. <SOAP:Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Body> <m:MyMethodCall xmlns:m="http://localhost" /> <SOAP:Body> <m:MyMethodCall2 xmlns:m="http://localhost" />
    E. A and C. F. A and D. G. A, B, and D. 6. Which of the following describes the elements that make up a SOAP message? A. Envelope, Header, Body, Fault. B. Envelope, Header, Body, Error.

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    Chapter 25: The Technologies

    39 C. Envelope, Body, Fault. D. Envelope, Header, Fault. 7. Which of the following technologies are used to describe a web service in terms of the messages that it creates and the messages that it accepts? A. XMLS B. XSLT C. CORBA D. WSDL 8. What is the default namespace for a new web service? A. http://localhost B. http://www.w3.org C. http://tempuri.org/ D. http://www.microsoft.com 9. Which segment of code will cause the web service method to be invoked? A. localhost.Service1 MyWebService = new localhost.Service1(); MyWebService.Method();

    B. proxy.Service1 MyWebService = new proxy.Service1(); MyWebService.Method();

    D. WebService MyWebService = new WebService(); MyWebService.Method(); 10. How would you add a web service component to your Visual Studio .NET application? A. Project | Add Web Component B. Project | Add Component C. Project | Add Web Service D. Project | Add Service 11. A static discovery file will usually have a file extension of which of the following? A. .vsdisco B. .vdisco C. .sdisco D. .disco

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    PART V

    C. Service1 MyWebService = new Service1(); MyWebService.Method();

    Color profile: Generic CMYK printer profile Composite Default All-In-One screen / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide

    40 12. Which of the following technologies is a lightweight protocol for exchange of information in a decentralized, distributed environment? A. XML B. WSDL C. XSD D. SOAP 13. Which of the following technologies is a file that defines the structure and data types for XML documents? A. XSD B. XMLD C. XSLT D. XSL 14. You are creating an application that will employ the services of an application that resides on a remote server. Which of the following protocols should be used to encode the message to the remote server? A. SOAP B. XML C. RPC D. DCOM 15. A WSDL document is a file that contains definitions for which of the following? A. Types, Messages, Bindings. B. Types, Messages, portTypes, bindings, services. C. Types, portTypes, bindings, services. D. Messages, portTypes, bindings, services.

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    Color profile: Generic CMYK printer profile Composite Default screen All-In-One / MCAD/MCSD Visual C# .NET Certification All-in-One Exam Guide / Rempel & Lind / 222443-6 / Chapter

    25

    Chapter 25: The Technologies

    41 Test Answers 1. B. Only the XML code will be displayed. 2. C. You need an instance of the class EventLog in order to write to the log file. 3. C. 4. D. 5. G. A SOAP message must have a element and may have a
    element. 6. A. 7. D. 8. C. 9. A. 10. C. 11. D. 12. D. 13. D. 14. A. 15. B.

    PART V

    P:\010Comp\All-in-1\443-6\ch25.vp Monday, August 26, 2002 11:52:23 AM

    Related Documents

    Ch25
    November 2019 7
    Ch25
    November 2019 7
    Ch25
    November 2019 9
    Ch25 Inverts) Part 1
    December 2019 4
    Ch25 Inverts) Part 2
    December 2019 4