Looking at WsDL and the schema for helloCustomerservice
After you made the reference to the HelloCustomer service, it was possible for you to review the WSDL in your new reference. With the Solution Explorer showing all files, you'll see the HelloCustomerl.wsdl within your solution. You can open this file to look at the WSDL, where you will find the following XSD imports:
<wsdl:types>
<xsd:schema targetNamespace="http://www.Wrox.com/ns/Imports">
<xsd:import schemaLocation="http://localhost:8 00 0/HelloCustomer?xsd=xsd0" namespace="http://www.Wrox.com/ns/" />
<xsd:import schemaLocation="http://localhost:8 00 0/HelloCustomer?xsd=xsd1"
namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> <xsd:import schemaLocation="http://localhost:8 00 0/HelloCustomer?xsd=xsd2" namespace="http://schemas.datacontract.org/2 0 04/0 7/ ProVB_WCFWithDataContract" /> </xsd:schema> </wsdl:types>
Code snippet from ProVB_HelloWorldConsumer\Service References\HelloCustomerService\HelloCustomer1.wsdl
http://localhost:8000/HelloCustomer?xsd=xsd2 provides the details about your Customer object. The code from the file HelloCustomer2.xsd, which is part of your reference definition, is shown here:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:tns="http://schemas.datacontract.org/2 004/0 7/ProVB_WCFWithDataContract" elementFormDefault="qualified" targetNamespace=
"http://schemas.datacontract.org/2004/07/ProVB_WCFWithDataContract" xmlns:xs="http://www.w3.org/2 0 01/XMLSchema"> <xs:complexType name="Customer"> <xs:sequence>
<xs:element min0ccurs="0" name="FirstName" nillable="true"
type="xs:string" /> <xs:element min0ccurs="0" name="LastName" nillable="true"
</xs:sequence> </xs:complexType>
<xs:element name="Customer" nillable="true" type="tns:Customer" /> </xs:schema>
Code snippet from ProVB_HelloWorldConsumer\Service References\HelloCustomerService\HeUoCustomer2.xsd
This is an XSD description of the Customer object. Making a reference to the WSDL that includes the XSD description of the Customer object causes the auto-generated proxy class (located in the file Reference.vb) to create the following class as part of the proxy (this code follows the Namespace declaration in the downloadable sample):
<System.Diagnostics.DebuggerStepThroughAttribute(), _ System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization" _ , "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="Customer", _
"http://schemas.datacontract.org/2004/07/ProVB_WCFWithDataContract"), _ System.SerializableAttribute()> _ Partial Public Class Customer Inherits Object
Implements System.Runtime.Serialization.IExtensibleDataObject,
System.ComponentModel.INotifyPropertyChanged <System.NonSerializedAttribute()> _ Private extensionDataField As _
System.Runtime.Serialization.ExtensionDataObject
<System.Runtime.Serialization.OptionalFieldAttribute()> _ Private FirstNameField As String
<System.Runtime.Serialization.OptionalFieldAttribute()> _ Private LastNameField As String
<Global.System.ComponentModel.BrowsableAttribute(false)> _ Public Property ExtensionData() As _ System.Runtime.Serialization.ExtensionDataObject _ Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData Get
Return Me.extensionDataField End Get Set
Me.extensionDataField = value End Set End Property
<System.Runtime.Serialization.DataMemberAttribute()> _ Public Property FirstName() As String Get
Return Me.FirstNameField End Get Set
If (Object.ReferenceEquals(Me.FirstNameField, value) <> _
true) Then
Me.FirstNameField = value Me.RaisePropertyChanged("FirstName") End If End Set End Property
<System.Runtime.Serialization.DataMemberAttribute()> _ Public Property LastName() As String Get
Return Me.LastNameField End Get Set
If (Object.ReferenceEquals(Me.LastNameField, value) <> _
true) Then
Me.LastNameField = value Me.RaisePropertyChanged("LastName") End If End Set End Property
Code snippet from ProVB_HelloWorldConsumer\Service References\HelloCustomerService\Reference.vb
As you can see, Visual Studio and WCF provide the tools you need to define and share complex data types across a distributed system. Combined with the other powerful features supported by WCF, you have the tools to build robust, enterprise-quality distributed solutions.
Post a comment