TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P38
Professional Special Edition- P38:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | When we run this new code we get the following result Another design decision we have to make is whether to use SOAP headers to send additional data with our Web Service. In the previous chapter we examined how we can support SOAP headers on the server. Now we ll look at how we can use SOAP headers with our proxy. Using SOAP Headers The following is a simple Web Service written in VB .NET that implements a SOAP header @ WebService Class UsingSoapHeaders Imports Imports Public Class MySoapHeader Inherits SoapHeader Public Value As String End Class Public Class UsingSoapHeaders Public sHeader As MySoapHeader WebMethod SoapHeader sHeader Public Function GetValueOfSoapHeader As String Return End Function End Class Here GetValueOfSoapHeader returns the value of the SOAP header that the caller presents. Described in WSDL The information for SimpleSoapHeader is described in the WSDL for the service as the application using the Web Service will require knowledge of the SoapHeader in order to call the service s element name MySoapHeader nillable true type s0 MySoapHeader s complexType name MySoapHeader s sequence s element minOccurs 1 maxOccurs 1 name Value nillable true type s string s sequence s complexType This WSDL uses an XML Schema to define a SOAP Header MySoapHeader. Our proxy generator either VS .NET or will then create a class MySoapHeader with a single member variable Value. SOAP Header Proxy The following is the VB .NET code generated by Visual Studio .NET for the WSDL of the above Web Service Namespace Simple WebServiceBindingAttribute Name UsingSoapHeadersSoap Namespace http Public Class UsingSoapHeaders Inherits SoapHttpClientProtocol Public MySoapHeaderValue As MySoapHeader Public Sub New http localhost . End Sub SoapHeaderAttribute MySoapHeaderValue SoapDocumentMethodAttribute http GetValueOfSoapHeader Use .
đang nạp các trang xem trước