Professional ASP.NET 1.1 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional ASP.NET 1.1 [Electronic resources] - نسخه متنی

Alex Homeret

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">








  • Data Types

    ASP.NET Web services support all the primitive types supported in the CLR. In addition to the simple primitive types, arrays of primitives are also supported. More interesting, however, is the support for user-defined classes and structs. Essentially, anything that can be represented by an XSD schema can be a parameter or return type of an ASP.NET Web service.


    Custom Types


    Suppose you want to build an ASP.NET Web service that returns a user-defined class named CustomerRecord. This returns some string and integer values, as well as an array of another, user-defined, class named Order:


    Public Class CustomerRecord
    Public Customer As String
    Public Address1 As String
    Public Address2 As String
    Public Phone As String
    Public Email As String
    Public CustomerOrder(2) As Order
    End Class

    Public Class Order
    Public OrderNumber As Integer
    Public Name As String
    Public Cost As String
    Public ShipDate As String
    End Class

    You could write the following WebMethod that returned an instance of CustomerRecord:


    Public Class OrderDetails
    <WebMethod()> Public Function RequestOrderDetails() As CustomerRecord
    Dim customerRecord As New CustomerRecord
    ' Set data...
    customerRecord.Customer = "JohnDoe"
    customerRecord.Address1 = "22913 Crestpark Dr"
    customerRecord.Address2 = "Houston, Tx 79043"
    customerRecord.Phone = "281-475-0938"
    customerRecord.Email = "john@customer.com"
    customerRecord.CustomerOrder(0) = New Order()
    customerRecord.CustomerOrder(0).OrderNumber = 12
    customerRecord.CustomerOrder(0).Name = "Product A"
    customerRecord.CustomerOrder(0).Cost = "$23.45"
    customerRecord.CustomerOrder(0).ShipDate = "8/6/01"

    customerRecord.CustomerOrder(1) = New Order()
    customerRecord.CustomerOrder(1).OrderNumber = 15
    customerRecord.CustomerOrder(1).Name = "Product C"
    customerRecord.CustomerOrder(1).Cost = "$13.41"
    customerRecord.CustomerOrder(1).ShipDate = "7/1/01"

    Return customerRecord
    End Function
    End Class

    As long as the user-defined class represents its data using primitive types, and those types are public, the data will be sent correctly to the caller. If, however, the class used Get/Set properties and modified private variables within the class, the data would not be sent correctly – XML is not used to describe the binary representation of the object in memory. Now that you're more familiar with the data types and the general ASP.NET Web service .asmx file, let's take a deeper look at two of the attributes used most often when building ASP.NET Web services.

  • / 243