Post on 23-Jan-2016
description
transcript
Presentation 15
SOAP on the Microsoft Platform (.NET)
Ingeniørhøjskolen i ÅrhusSlide 2 af 29
Outline
• You have already been introduced to SOAP, WSDL & UDDI on the JAVA platform using AXIS
• Now we will take a look at the MS . NET platforms SOAP capabilities
• Luckily – SOAP & WSDL are well standardized – so we do not need to look at these again
• Instead we will:– Show the counterpart of the AXIS project in .NET - IIS– Show the alternatives to JAVA development – using the
tools from .NET framework & Microsoft Visual Studio .NET
Ingeniørhøjskolen i ÅrhusSlide 3 af 29
Apache Tomcat vs. Microsoft Internet Information Server
• Apache Tomcat with AXIS & J2SE Java SDK– Works on:
• Windows, UNIX, LINUX• Open source Can be compiled to any platform (with some work)
– Server listening for events: • HTTP on port 80 (test http 8080 at startup)• Executes Servlets/JSP and JavaBeans
– AXIS is an embedded project within the Tomcat environment but works with most J2EE compliant AS
• Microsoft Internet Information Server with the .NET Framework SDK (ASP.NET)– Works on:
• Only Windows platforms (Windows NT, 2000, XP)– Server listening for events:
• HTTP on port 80 (optional)• Executes Web resources – ASP.NET, Web services, Web forms (resulting in client side HTML ), .NET code
– Tightly integrated with the Visual Studio .NET – for easy deployment & debugging
SOAP ClientJava, C++, C#,
Delphi, VB Application
SOAP ClientJava, C++, C#,
Delphi, VB Application
SOAP over HTTPSOAP over HTTP
Web ServerMS Internet Information Server
& the .NET Framework SDK(ASP.NET)
(vs. Apache Tomcat, with AXIS & J2SE SDK)
Web ServerMS Internet Information Server
& the .NET Framework SDK(ASP.NET)
(vs. Apache Tomcat, with AXIS & J2SE SDK)
Web FormsWeb Forms
WebService
WebService
C++ unman.C++
unman.
Managedcode
Managedcode
Common code base – but only MS!Common code base – but only MS!
Ingeniørhøjskolen i ÅrhusSlide 4 af 29
Web service enabling Windows
• You need to:– Install .NET Framework SDK
• Download from Microsoft (130 MB)• Comes standard with Visual Studio 2003 .NET
– Install Internet Information Server• Enabled via the Control Panel• Remember to shut down after using!!!
– Visual Studio .NET• Already installed (7 or 7.1)
• More detailed instructions will follow for the LAB exercise
Ingeniørhøjskolen i ÅrhusSlide 5 af 29
Not a Windows ASP.NET course
• You will NOT be required to be an expert on .NET• You will be required to be knowledgeable about it
• ASP.NET is a framework for Web enabling Windows code
• Traditional HTML & DHTML – and Web services• Complete architecture
Ingeniørhøjskolen i ÅrhusSlide 6 af 29
What is the .NET Framework?
Developer Tools Client applications
(Windows forms)
User Experiences
ASP.NET Web Applications
XML Web Services
Databases
.NET Framework A complete
Framwork: like J2EE
Ingeniørhøjskolen i ÅrhusSlide 7 af 29
The .NET Framework Components
Win32Win32
MessageMessageQueuingQueuing
COM+COM+(Transactions, Partitions, (Transactions, Partitions,
Object Pooling)Object Pooling)IISIIS WMIWMI
Common Language RuntimeCommon Language Runtime
.NET Framework Class Library.NET Framework Class Library
ADO.NET and XMLADO.NET and XML
XML Web ServicesXML Web Services User InterfaceUser Interface
VisualBasic C++ C#
ASP.NETASP.NET
Perl JScript …
Application services. E.g. IIS, Message Queuing etc.
CLR:execution environment. Equals JVM of Java. Microsoft Intermediate Language (MSIL) equals Java ByteCode
A collection of class libraries
ActiveX Data Objects
3 types of user interfaces: Web forms, Windows forms (Win32), Command Console
For inter-process communications
Any language conforming to the Common Language Specification (CLS) may be used.
Operating system primitives – the WIN32 API using Windows XP, 2000, CE
Ingeniørhøjskolen i ÅrhusSlide 8 af 29
Benefits of Using the .NET Framework
• Based on Web standards and practices• Functionality of .NET classes is
universally available• Code is organized into hierarchical
namespaces and classes• Language independent
Windows Windows APIAPI
ASPASP
.NET .NET FrameworkFramework
1980’s 1990’s 2000’s
Visual BasicVisual Basic
MFC/ATLMFC/ATL
Ingeniørhøjskolen i ÅrhusSlide 9 af 29
Visual Studio .NET: The Tool for .NET Development
Visual Studio .NET
Windows Forms Tools
Web Forms Tools
Error Handling
Data Access
Multiple Languages
Web Services
Tools
Develop Debug DeployDesign
Ingeniørhøjskolen i ÅrhusSlide 10 af 29
Multiple Language Support• The .NET Framework is designed to support many
languages– More than 20 languages currently supported– Microsoft provides Visual Basic .NET, C#,
Visual J# .NET, and JScript .NET (backwards compatible with JScript) – others: Delphi (object pascal)
• Benefits of multiple-language support– Code modules are reusable– API access is the same for all languages– The right language is used for the right task– Performance is roughly equal between all languages
(which was not the case in ASP)
Ingeniørhøjskolen i ÅrhusSlide 11 af 29
The Common Language Runtime
• One runtime for all . NET-Based Languages• Manages threads and memory
– Garbage collection
• Enforces code security• Eliminates DLL versioning problems
– Multiple versions of a DLL can run simultaneously– Applications can specify a version of a DLL to use
• Reminds one of the Java Virtual Machine
Ingeniørhøjskolen i ÅrhusSlide 12 af 29
Runtime Compilation and Execution
Nativecode
C# code Visual Basic .NET code
Which language?
A Basic .NETcompiler
C#compiler
MSILJITcompiler
Web form (default.aspx) or Web service (default.asmx)
Runtime
HTM
L / SO
AP
Ingeniørhøjskolen i ÅrhusSlide 13 af 29
Ressources for learning more
• Feel free to learn more about ASP.NET:– Getting started with the .NET framework– http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcongettingstarte
dwithnetframework.asp
– Link can be found at the course site– Books on the subject
• Beginning .NET Web Services using C# by Joseph Bustos and Karli Watsom (WROK forlag)
• More will be listed on the course site
Ingeniørhøjskolen i ÅrhusSlide 14 af 29
Making the HelloWorld application
• Using Notepad !• Using Microsoft Visual Studio .NET• First:
– Install .NET Framework– Install IIS
• Then:– Produce code
• Manually for Notepad• Wizard for Visual Studio
– Deploy in the IIS folder • \inetpub\wwwroot\• As an .asmx file
– Test the Web service• Using the build in functionality
– Write the Client – and all is well
Ingeniørhøjskolen i ÅrhusSlide 15 af 29
C# Notepad HelloWorldName(missing): identifies localname of serviceName(missing): identifies localname of service
Namespace: the default namespace for the serviceNamespace: the default namespace for the service
Description: a purely descriptive text informationDescription: a purely descriptive text information
WebService processing directive for the ASP.NET environment, e.g. class & language info
WebService processing directive for the ASP.NET environment, e.g. class & language info
WebService Attribute, for configuration “behind the scenes” programmingWebService Attribute, for configuration “behind the scenes” programming
WebMethod Attribute: indicates that the following method is to be exposed as a Web Service method (only public methods are allowed of course). Allowed properties: -BufferResponse, CacheDuration, Description, EnableSession, MessageName, TransactionOption
WebMethod Attribute: indicates that the following method is to be exposed as a Web Service method (only public methods are allowed of course). Allowed properties: -BufferResponse, CacheDuration, Description, EnableSession, MessageName, TransactionOption
Ingeniørhøjskolen i ÅrhusSlide 16 af 29
Using Visual Studio (managed C++)Wizards Available: for Managed C++ (see below example VB and C#Wizards Available: for Managed C++ (see below example VB and C#
Code-behind: generates .asmx file and code behind (e.g. .cpp in C++ or .cs in C#)Code-behind: generates .asmx file and code behind (e.g. .cpp in C++ or .cs in C#)
Ingeniørhøjskolen i ÅrhusSlide 17 af 29
Deploy & Test – access via browserIIS test : supports viewing WSDL & code testing via browserIIS test : supports viewing WSDL & code testing via browser
WSDL: using ?WSDLWSDL: using ?WSDL
SOAP request & test: small test program generatedSOAP request & test: small test program generated
Ingeniørhøjskolen i ÅrhusSlide 18 af 29
Developing the Client application
• Support for using Web services in an Visual Studio application
• Stubs are automatically compiled by Visual Studio using the “Add Web Reference” function OR
• You may simply use command line tools
Note on command line usage: If you do not wish to use Visual Studio IDE you may use the tool via the command line:
wsdl "http://localhost/hello.asmx" /out:hello.cs
This will produce the hello.cs file which must be compiled as a DLL (using the C# .NET compiler)
csc hello.cs /t:library /out:hello.dll /r:System.Web.Service.dll /r:System.Xml.dll
Note on command line usage: If you do not wish to use Visual Studio IDE you may use the tool via the command line:
wsdl "http://localhost/hello.asmx" /out:hello.cs
This will produce the hello.cs file which must be compiled as a DLL (using the C# .NET compiler)
csc hello.cs /t:library /out:hello.dll /r:System.Web.Service.dll /r:System.Xml.dll
See example at: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=35 See example at: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=35
Ingeniørhøjskolen i ÅrhusSlide 19 af 29
New Application & Add Web Reference
Add Web Reference: Visual Studio support for generating a proxy using WSDL document
Add Web Reference: Visual Studio support for generating a proxy using WSDL document
Ingeniørhøjskolen i ÅrhusSlide 20 af 29
Discover & bind the Web serviceAdd Web Reference: Just enter the Web service endpoint address
Add Web Reference: Just enter the Web service endpoint address
Ingeniørhøjskolen i ÅrhusSlide 21 af 29
Visual Studio produces a Proxy DLL
Performed by Visual Studio tool:a DLL is generated (Web Service Proxy Generator), and a header fileand a WSDL support document is madeavailable
Ingeniørhøjskolen i ÅrhusSlide 22 af 29
Proxy class DLL
• DLL is generated by Visual Studio • The generated Proxy class derives from
System.Web.Service.Protocols.SoapHttpClientProtocol • It contains the following properties
– ClientCertificates allows clients to pass Authenticode X.509 v.3 certificates
– CookieContainer for handling state– Credentials for authentication purposes– PreAuthenticate saves the roundtrip by sending credentials first– Proxy use this property if you need to pass a proxy– Timeout default 100.000 milisseconds – may be set for infinite– Url from the location attribut of the service used
Ingeniørhøjskolen i ÅrhusSlide 23 af 29
using System.Diagnostics;using System.Xml.Serialization;using System;using System.Web.Services.Protocols;using System.ComponentModel;using System.Web.Services;
/// <remarks/>[System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")][System.Web.Services.WebServiceBindingAttribute(Name="HelloWorldSoap", Namespace="http://www.wagner.dk/webservices")]public class HelloWorld : System.Web.Services.Protocols.SoapHttpClientProtocol { public HelloWorld() { this.Url = "http://192.168.1.100/hello.asmx"; } [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.wagner.dk/webservices/Hello", RequestNamespace="http://www.wagner.dk/webservices", ResponseNamespace="http://www.wagner.dk/webservices", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public string Hello(string myName) { object[] results = this.Invoke("Hello", new object[] { myName}); return ((string)(results[0])); }
public System.IAsyncResult BeginHello(string myName, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("Hello", new object[] { myName}, callback, asyncState); } public string EndHello(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); return ((string)(results[0])); }}
using System.Diagnostics;using System.Xml.Serialization;using System;using System.Web.Services.Protocols;using System.ComponentModel;using System.Web.Services;
/// <remarks/>[System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")][System.Web.Services.WebServiceBindingAttribute(Name="HelloWorldSoap", Namespace="http://www.wagner.dk/webservices")]public class HelloWorld : System.Web.Services.Protocols.SoapHttpClientProtocol { public HelloWorld() { this.Url = "http://192.168.1.100/hello.asmx"; } [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.wagner.dk/webservices/Hello", RequestNamespace="http://www.wagner.dk/webservices", ResponseNamespace="http://www.wagner.dk/webservices", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public string Hello(string myName) { object[] results = this.Invoke("Hello", new object[] { myName}); return ((string)(results[0])); }
public System.IAsyncResult BeginHello(string myName, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("Hello", new object[] { myName}, callback, asyncState); } public string EndHello(System.IAsyncResult asyncResult) { object[] results = this.EndInvoke(asyncResult); return ((string)(results[0])); }}
The Proxy code generated by theWSDL Proxy generator
Ingeniørhøjskolen i ÅrhusSlide 24 af 29
Write the C++ code
Ingeniørhøjskolen i ÅrhusSlide 25 af 29
Try it out
Not that much fun with command line … lets make a proper Windows solutionNot that much fun with command line … lets make a proper Windows solution
Ingeniørhøjskolen i ÅrhusSlide 26 af 29
Piece of Cake – Now C#
Add Web Reference: Again we use the Web service endpoint address with the “Add Web Reference” feature
Add Web Reference: Again we use the Web service endpoint address with the “Add Web Reference” feature
We add a button, a text field and a label. Clicking the button gives access to the event handler “OnClick” of the button
We add a button, a text field and a label. Clicking the button gives access to the event handler “OnClick” of the button
Simple C# Windows Form Application:No point in producing another command line app
Simple C# Windows Form Application:No point in producing another command line app
Ingeniørhøjskolen i ÅrhusSlide 27 af 29
C# - coding the connection
Using the Proxy DLL: We recognize the connection between the WSDL, the DLL and the C# client code
Using the Proxy DLL: We recognize the connection between the WSDL, the DLL and the C# client code
Ingeniørhøjskolen i ÅrhusSlide 28 af 29
Heterogeneous system C# to Java
Proxy DLL stubgenerated by VS
Proxy skeleton classgenerated by AXIS
// Hello World.Java
public class HelloWorld {
public HelloWorld() { } public String getHelloWorldMessage(String name) { return "Hello World to "+name; }}
private void button1_Click(object sender, System.EventArgs e){ localhost.HelloWorldService hello = new localhost.HelloWorldService(); textBox1.Text = hello.getHelloWorldMessage("Stefan");}
C# to Java Lets change it to our Axis Web serviceC# to Java Lets change it to our Axis Web service
Add Web Reference: We need to generate a new Proxy DLL
Add Web Reference: We need to generate a new Proxy DLL
Other way around: and of course it also works the other way around Other way around: and of course it also works the other way around
Proxy: if we are not using .JWS deployment, we need to generate the skeleton classes in AXIS as well
Proxy: if we are not using .JWS deployment, we need to generate the skeleton classes in AXIS as well
Ingeniørhøjskolen i ÅrhusSlide 29 af 29
Try it with C++
• WARNING: In VS7 there seems to be a bug!– Problem with port 8080– Need to manually paste the
WSDL file and compile the proxy stub DLL
– This works fine in C#– No problem in VS7.1
Ingeniørhøjskolen i ÅrhusSlide 30 af 29
One standardised interface
One interface per object operation
ORB-dependent interfaceOne interface per object adapter
DynamicInvocation
ClientStubs
ORBInterface
Implementation Skeletons
Client Object Implementation
ORB Core
ObjectAdapter
Hvad ser vi her?