SlideShare a Scribd company logo
1 of 14
Session 6
          Module 2



Calling a Web Service from
 an ASP.NET Web Page
Tasks for this Module
• How we’d ideally call a Web service from an
  ASP.NET Web page
• Creating a Proxy class with wsdl.exe
   – Using the Proxy class
   – Examining the Proxy class
   – Examining wsdl.exe

Time allotment for this module and questions: 75 minutes
Calling a Web Service from an
       ASP.NET Web Page
• Ideally the developer calling a Web service from
  an ASP.NET Web page should be able to work
  with the Web service using the same syntax as if
  she was working with a component local to the
  Web server.
• Since calling a Web service involves marshalling
  the ingoing parameters properly and being able to
  marshal the return parameters properly, obviously
  performing such actions in an ASP.NET Web
  page would make the syntax differ wildly from
  using a local component, where such explicit
  marshalling was not needed.
Enter the Proxy Class
• In order to achieve the end goal of treating a Web
  service call just like a call to a local component,
  the .NET framework contains a command-line
  program called wsdl.exe (Web Service
  Description Language), which creates a proxy
  class for a specific Web service.
• This proxy class serves as an intermediate
  between the ASP.NET Web page and the Web
  service. (The diagram on the next slide should
  help clarify this…)
The Role of the Proxy Class
                      STEP 3: The Web class unmarshals the
                      STEP 4: The proxy service marshals thethe
                       STEP 2: The proxy class unmarshals
                       STEP 1: The ASP.NET Web page
                       incoming parameters,passes anmethod, and
                        SomePage.aspx and runsan HTTP request
                                                   the instance of
                      return parameters instantiates back the result to
                        parameter list and makes
                      tothe Proxy class:Web page. Web Server are
                       marshals the output parameters. These
                        the Web service sitting on Transaction#2
                         the ASP.NET
                      complete! in an HTTP response.
                       sent back
                        Dim objClass = New ProxyClassName

WEB SERVER #1          And calls one of the Web service methods:
                       objClass.MethodName(paramList)
 SomePage.aspx
an ASP.NET Web page
                             WEB
                           SERVER #2

 PROXY CLASS                Web service
Creating a Proxy Class
• Creating a Proxy class involves three steps:
   – Create the source code for the class, which depends
     upon the WSDL of the Web service.
   – Compile the class into a DLL
   – Copy the DLL to the bin directory
• Once these three steps are complete we can use
  our Proxy class to access Web service methods as
  if they were methods of a local component!

  Visual Studio.NET can perform all of these tasks with the
     click of a button. We will examine how to do it via the
   command-line for those who don’t have VS.NET installed.
Creating a Proxy Class
                            (Continued…)

• When creating a proxy class, you must specify the
  WSDL for the Web service. This XML-formatted file
  contains information on the incoming and outgoing
  parameters. See
  http://localhost/UCSDTeaching/Session6/SimpleWebService.asmx?WSDL




• Create the proxy class by simply calling wsdl.exe
  with the full URL of the WSDL as the parameter:
Wsdl http://localhost/UCSDTeaching/Session6/SimpleWebService.asmx?WSDL
Creating a Proxy Class
                   (Continued…)

• Once we have the source code we need to compile
  this code into a DLL.
• Finally, once we have the Proxy class compiled
  into a DLL, we need to move it to the bin
  directory, since that is the location where our
  DLLs need to reside to be picked up automatically
  by ASP.NET.

Run cl.demo1.txt demo
Using the Proxy Class
• Once we have the Proxy class compiled and
  the DLL in the bin directory, we can use
  it through an ASP.NET Web page.
Show CallSimpleWS.aspx Demo
• Note how, when examining the syntax, it is
  impossible to tell if the instantiation of the
  ucsd.Math class is referring to a local or
  remote component. Mission accomplished!
Examining the Proxy Class
• Let’s take a moment and examine Math.cs, the
  source code for the Proxy class created by
  wsdl.exe
Examine Math.cs
• Note that the Proxy class is in C# - wsdl.exe
  provides a command-line switch to specify what
  language to use.
• Note that a class is created with the same name as
  the Web service class (Math, in this example).
  Also, for each public Web method there is a public
  method in the Proxy class with the correct input
  and output parameters.
Examining the Proxy Class
                (Continued…)

• Note that in this Proxy class the Web
  service is being called using the SOAP
  request/response payloads.
• All of the complex behavior in hidden in
  macros or through methods defined in base
  classes from which our custom Math class
  inherits from.
Examining wsdl.exe
• Wsdl.exe contains only one required parameter,
  a URL or path to the WSDL for the Web service.
  The following optional parameters can be
  specified:
  – /language:language – specifies what language the
    Proxy class should be created in (vb/cs/js).
  – /protocol:protocol – specifies the payload protocol
    to be used (SOAP, HttpGet, HttpPost)
  – /namespace:namespace – the namespace of the
    generated Proxy class.
  – /out:filename – the filename of the Proxy class.
Module 2 in Conclusion
• Ideally, we’d like to be able to call Web services
  from an ASP.NET Web page in an identical fashion
  to which we call local components.
• Creating a Proxy class allows us to call a Web
  service’s methods as if the Web service resided
  locally. The Proxy class handles the actual HTTP
  request as well as the marshalling of the input and
  output parameters.
• The command-line program wsdl.exe can create
  the source code of the Proxy class for us based upon
  a Web service’s WSDL. Once this class is compiled
  and placed in the bin directory, it can be used
  through an ASP.NET Web page.
Questions???

 Now would be a great time
to ask questions! Don’t you
  think? So ask away! 

More Related Content

What's hot

Quartz connector mule
Quartz connector   muleQuartz connector   mule
Quartz connector muleSindhu VL
 
[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina ToolsetWSO2
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Sourceakashdprajapati
 
Managing ejabberd Platforms with Docker - ejabberd Workshop #1
Managing ejabberd Platforms with Docker - ejabberd Workshop #1Managing ejabberd Platforms with Docker - ejabberd Workshop #1
Managing ejabberd Platforms with Docker - ejabberd Workshop #1Mickaël Rémond
 
Mule esb How to convert from CSV to Json in 5 minutes
Mule esb How to convert from CSV to Json in 5 minutesMule esb How to convert from CSV to Json in 5 minutes
Mule esb How to convert from CSV to Json in 5 minutesGennaro Spagnoli
 
Ejabberd with xmpp
Ejabberd with xmppEjabberd with xmpp
Ejabberd with xmppPrem Narain
 
Parallel processing for splitter in mule esb
Parallel processing for splitter in mule esbParallel processing for splitter in mule esb
Parallel processing for splitter in mule esbSunil Kumar
 
Mule core concepts
Mule core conceptsMule core concepts
Mule core conceptsSindhu VL
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interfacekrishananth
 
Composite Source With Mule ESB
Composite Source With Mule ESBComposite Source With Mule ESB
Composite Source With Mule ESBJitendra Bafna
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo javeed_mhd
 
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...Brittany Ingram
 
Rust kafka-5-2019-unskip
Rust kafka-5-2019-unskipRust kafka-5-2019-unskip
Rust kafka-5-2019-unskipGerard Klijs
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)nazeer pasha
 
Shipping your logs to elk from mule app/cloudhub part 3
Shipping  your logs to elk from mule app/cloudhub  part 3Shipping  your logs to elk from mule app/cloudhub  part 3
Shipping your logs to elk from mule app/cloudhub part 3Alex Fernandez
 
SOAP - Simple Object Access Protocol
SOAP - Simple Object Access ProtocolSOAP - Simple Object Access Protocol
SOAP - Simple Object Access ProtocolAnushka Patil
 

What's hot (19)

Quartz connector mule
Quartz connector   muleQuartz connector   mule
Quartz connector mule
 
[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset
 
Tomcat server
 Tomcat server Tomcat server
Tomcat server
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
 
Managing ejabberd Platforms with Docker - ejabberd Workshop #1
Managing ejabberd Platforms with Docker - ejabberd Workshop #1Managing ejabberd Platforms with Docker - ejabberd Workshop #1
Managing ejabberd Platforms with Docker - ejabberd Workshop #1
 
Mule esb How to convert from CSV to Json in 5 minutes
Mule esb How to convert from CSV to Json in 5 minutesMule esb How to convert from CSV to Json in 5 minutes
Mule esb How to convert from CSV to Json in 5 minutes
 
Ejabberd with xmpp
Ejabberd with xmppEjabberd with xmpp
Ejabberd with xmpp
 
Parallel processing for splitter in mule esb
Parallel processing for splitter in mule esbParallel processing for splitter in mule esb
Parallel processing for splitter in mule esb
 
Mule core concepts
Mule core conceptsMule core concepts
Mule core concepts
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interface
 
Composite Source With Mule ESB
Composite Source With Mule ESBComposite Source With Mule ESB
Composite Source With Mule ESB
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
 
Rust kafka-5-2019-unskip
Rust kafka-5-2019-unskipRust kafka-5-2019-unskip
Rust kafka-5-2019-unskip
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)
 
Shipping your logs to elk from mule app/cloudhub part 3
Shipping  your logs to elk from mule app/cloudhub  part 3Shipping  your logs to elk from mule app/cloudhub  part 3
Shipping your logs to elk from mule app/cloudhub part 3
 
Dynamic file attribute
Dynamic file attributeDynamic file attribute
Dynamic file attribute
 
Automatic documentation with mule
Automatic documentation with mule Automatic documentation with mule
Automatic documentation with mule
 
SOAP - Simple Object Access Protocol
SOAP - Simple Object Access ProtocolSOAP - Simple Object Access Protocol
SOAP - Simple Object Access Protocol
 

Similar to Test

58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-services58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-serviceshomeworkping3
 
Web services in java
Web services in javaWeb services in java
Web services in javamaabujji
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WSKatrien Verbert
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...Fwdays
 
Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1AkramWaseem
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security developmentSynapseindiappsdevelopment
 
Scripts Python Dbapi
Scripts Python DbapiScripts Python Dbapi
Scripts Python DbapiAkramWaseem
 
Welcome to Web Services
Welcome to Web ServicesWelcome to Web Services
Welcome to Web ServicesShivinder Kaur
 
Developing SOAP Web Services using Java
Developing SOAP Web Services using JavaDeveloping SOAP Web Services using Java
Developing SOAP Web Services using Javakrishnaviswambharan
 
Xml web services
Xml web servicesXml web services
Xml web servicesRaghu nath
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...WebStackAcademy
 

Similar to Test (20)

58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-services58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-services
 
SCDJWS 5. JAX-WS
SCDJWS 5. JAX-WSSCDJWS 5. JAX-WS
SCDJWS 5. JAX-WS
 
Web services in java
Web services in javaWeb services in java
Web services in java
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
 
Mule soft ppt 2
Mule soft ppt  2Mule soft ppt  2
Mule soft ppt 2
 
Webconnection
WebconnectionWebconnection
Webconnection
 
Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1
 
Asp.net
Asp.netAsp.net
Asp.net
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security development
 
Scripts Python Dbapi
Scripts Python DbapiScripts Python Dbapi
Scripts Python Dbapi
 
Introaspnet
IntroaspnetIntroaspnet
Introaspnet
 
Aspintro
AspintroAspintro
Aspintro
 
Welcome to Web Services
Welcome to Web ServicesWelcome to Web Services
Welcome to Web Services
 
Developing SOAP Web Services using Java
Developing SOAP Web Services using JavaDeveloping SOAP Web Services using Java
Developing SOAP Web Services using Java
 
Pydbapi
PydbapiPydbapi
Pydbapi
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
Xml web services
Xml web servicesXml web services
Xml web services
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 

Test

  • 1. Session 6 Module 2 Calling a Web Service from an ASP.NET Web Page
  • 2. Tasks for this Module • How we’d ideally call a Web service from an ASP.NET Web page • Creating a Proxy class with wsdl.exe – Using the Proxy class – Examining the Proxy class – Examining wsdl.exe Time allotment for this module and questions: 75 minutes
  • 3. Calling a Web Service from an ASP.NET Web Page • Ideally the developer calling a Web service from an ASP.NET Web page should be able to work with the Web service using the same syntax as if she was working with a component local to the Web server. • Since calling a Web service involves marshalling the ingoing parameters properly and being able to marshal the return parameters properly, obviously performing such actions in an ASP.NET Web page would make the syntax differ wildly from using a local component, where such explicit marshalling was not needed.
  • 4. Enter the Proxy Class • In order to achieve the end goal of treating a Web service call just like a call to a local component, the .NET framework contains a command-line program called wsdl.exe (Web Service Description Language), which creates a proxy class for a specific Web service. • This proxy class serves as an intermediate between the ASP.NET Web page and the Web service. (The diagram on the next slide should help clarify this…)
  • 5. The Role of the Proxy Class STEP 3: The Web class unmarshals the STEP 4: The proxy service marshals thethe STEP 2: The proxy class unmarshals STEP 1: The ASP.NET Web page incoming parameters,passes anmethod, and SomePage.aspx and runsan HTTP request the instance of return parameters instantiates back the result to parameter list and makes tothe Proxy class:Web page. Web Server are marshals the output parameters. These the Web service sitting on Transaction#2 the ASP.NET complete! in an HTTP response. sent back Dim objClass = New ProxyClassName WEB SERVER #1 And calls one of the Web service methods: objClass.MethodName(paramList) SomePage.aspx an ASP.NET Web page WEB SERVER #2 PROXY CLASS Web service
  • 6. Creating a Proxy Class • Creating a Proxy class involves three steps: – Create the source code for the class, which depends upon the WSDL of the Web service. – Compile the class into a DLL – Copy the DLL to the bin directory • Once these three steps are complete we can use our Proxy class to access Web service methods as if they were methods of a local component! Visual Studio.NET can perform all of these tasks with the click of a button. We will examine how to do it via the command-line for those who don’t have VS.NET installed.
  • 7. Creating a Proxy Class (Continued…) • When creating a proxy class, you must specify the WSDL for the Web service. This XML-formatted file contains information on the incoming and outgoing parameters. See http://localhost/UCSDTeaching/Session6/SimpleWebService.asmx?WSDL • Create the proxy class by simply calling wsdl.exe with the full URL of the WSDL as the parameter: Wsdl http://localhost/UCSDTeaching/Session6/SimpleWebService.asmx?WSDL
  • 8. Creating a Proxy Class (Continued…) • Once we have the source code we need to compile this code into a DLL. • Finally, once we have the Proxy class compiled into a DLL, we need to move it to the bin directory, since that is the location where our DLLs need to reside to be picked up automatically by ASP.NET. Run cl.demo1.txt demo
  • 9. Using the Proxy Class • Once we have the Proxy class compiled and the DLL in the bin directory, we can use it through an ASP.NET Web page. Show CallSimpleWS.aspx Demo • Note how, when examining the syntax, it is impossible to tell if the instantiation of the ucsd.Math class is referring to a local or remote component. Mission accomplished!
  • 10. Examining the Proxy Class • Let’s take a moment and examine Math.cs, the source code for the Proxy class created by wsdl.exe Examine Math.cs • Note that the Proxy class is in C# - wsdl.exe provides a command-line switch to specify what language to use. • Note that a class is created with the same name as the Web service class (Math, in this example). Also, for each public Web method there is a public method in the Proxy class with the correct input and output parameters.
  • 11. Examining the Proxy Class (Continued…) • Note that in this Proxy class the Web service is being called using the SOAP request/response payloads. • All of the complex behavior in hidden in macros or through methods defined in base classes from which our custom Math class inherits from.
  • 12. Examining wsdl.exe • Wsdl.exe contains only one required parameter, a URL or path to the WSDL for the Web service. The following optional parameters can be specified: – /language:language – specifies what language the Proxy class should be created in (vb/cs/js). – /protocol:protocol – specifies the payload protocol to be used (SOAP, HttpGet, HttpPost) – /namespace:namespace – the namespace of the generated Proxy class. – /out:filename – the filename of the Proxy class.
  • 13. Module 2 in Conclusion • Ideally, we’d like to be able to call Web services from an ASP.NET Web page in an identical fashion to which we call local components. • Creating a Proxy class allows us to call a Web service’s methods as if the Web service resided locally. The Proxy class handles the actual HTTP request as well as the marshalling of the input and output parameters. • The command-line program wsdl.exe can create the source code of the Proxy class for us based upon a Web service’s WSDL. Once this class is compiled and placed in the bin directory, it can be used through an ASP.NET Web page.
  • 14. Questions??? Now would be a great time to ask questions! Don’t you think? So ask away! 