Quick Tutorial For Web Services - CGIAR

2y ago
34 Views
3 Downloads
1.81 MB
20 Pages
Last View : 3d ago
Last Download : 3m ago
Upload by : Abby Duckworth
Transcription

Quick Tutorialabout WebServices 2004 . International Potato Center (CIP)

IQuick Tutorial for Web ServicesTable of Contents2Part I Introduction1 Welcome. 23Part II Web Services in Java1 Pre-requesites.in Windows3Installing JVM .Installing Apache.Installing Tomcat.Installing Apache.Axis45552 Deploy an existing.Web Services63 Create and deploy.a new Web Services64 Related Links. 88Part III Web Services in PHP1 Pre-requesites.in Windows8Installing Apache.and PHPInstalling NuSOAP.892 Create and deploy.a new Web Services9Example for sum.numbers9Example for LDAP. 103 Related Links. 1313Part IV Web Services in .NET1 Pre-requesites.in Windows13Installing IIS .Installing Framework.NETInstalling Visual.Studio .NET1415152 Create and deploy.a new Web Services153 Related Links. 18Part V Web Services with Lavadora18Part VI Java vs PHP vs .NET19Index0 2004 . International Potato Center (CIP)

Introduction1Introduction1.1Welcome2This quick tutorial pretends to teach:· How to install the pre-requisites for Web Services· How to create and deploy a simple Web Services using WSDLThis tutorial is an output about Web Services of Taverna/Web Services workshop given on November2004.Tutorial created by: Edwin Rojas and Enver TarazonaExpositor: Martin SengerOn top from left to right: Reinhard Simon, Enver Tarazona, Cristian Solis, Saúl Rodríguez,Luis Avila and Martin Senger.On middle from left to right: Edwin Rojas, Miguel Blancas and Diana ZevallosOn bottom from left to right: Vanessa Domínguez, Ysabel Orosco, Magna Schmitt, Sara Villanuevaand Jackie Puchuri. 2004 . International Potato Center (CIP)

3Quick Tutorial for Web ServicesWe welcome any comments and/or suggestions. Please mail to cip-RIU@cgiar.orgCopyright 2004 International Potato Center (CIP)www.cipotato.org2Web Services in Java2.1Pre-requesites in WindowsTheses pre-requesites was installed in a Windows 2000 with Service pack 4.After installing the pre-requisites, the structure should see as fallow: 2004 . International Potato Center (CIP)

Web Services in Java2.1.1Installing JVMFor this tutorial we used the Java Virtual Machine SDK Standard Edition version 1.4.2(j2sdk-1 4 2 05-windows-i586-p.exe)Download from: http://java.sun.com/j2se/1.4.2/download.html 2004 . International Potato Center (CIP)4

52.1.2Quick Tutorial for Web ServicesInstalling ApacheFor this tutorial we used the Apache XAMPP for Windows version 1.4.9(xampp-win32-1.4.9-installer.exe)Download from: or mpp-win32-1.4.9-installer.exeNote:After download and when the installer require a path we used: d:\apachefriends2.1.3Installing TomcatFor this tutorial we used the Tomcat Add-Ons for XAMPP for Windows version load from: #644or mpp-tomcat-addon-1.4.9-installer.exeAfter download and when the installer require a path use: d:\apachefriends\xamppTo test the installation of Tomcat fallow the next steps:· Run Apache from : D:\apachefriends\xampp\xampp start.exe· Run Tomcat from : D:\apachefriends\xampp\tomcat start.bat· Go to : http://localhost:8080/ , If the installation went ok, you should see the default Tomcat page.2.1.4Installing Apache AxisFor this tutorial we used the Apache Axis Add-Ons for XAMPP for Windows version 1.1(xampp axis-1.1-addon-0.1.zip)Download from: http://addons.xampp.org/cgi-bin/search.pl?pid 17or mpp axis-1.1-addon-0.1.zipFor installing Apache Axis Addon in XAMPP for Windows:· Unpack the Apache Axis Addon in your valid XAMPP directory (D:\apachefriends\xampp) anduse(check) the default folder name of the .ZIP file.· When ask replace the existing file catalina.bat, select "No".· After unpack copy the file "D:\apachefriends\xampp\axis\lib\activation.jar" to"D:\apachefriends\xampp\tomcat\common\lib"· Stop and restart Tomcat.· Verify that Axis is installed correctly by typing the following line in your browser:"http://localhost:8080/axis"· If the installation went ok, you should see the default Apache-AXIS page.· Validate the Axis installation configuration by clicking the "Validate" link on the defaultApache-Axis page. You should not see any error in "Needed Components". 2004 . International Potato Center (CIP)

Web Services in Java2.26Deploy an existing Web ServicesDeploy the stock quote demo web service that come with Apache Axis:· Open, edit and save the file: d:\apachefriends\xampp\axis\adminclient.bat, set the path of JavaVirtual Machine and Apache Axis home.set JAVA HOME D:\j2sdk1.4.2 04set AXIS HOME D:\apachefriends\xampp\axis· cd d:\apachefriends\xampp\axis\· adminclient.bat samples\stock\deploy.wsddYou should see the following output:Processing file samples/stock/deploy.wsdd Admin Done processing /Admin · Check if the stock quote demo web service was deployed correctly by accessing the AxisServletor click on the "View" link from the default Apache-AXIS tYou should see the two new services "urn:cominfo" and "urn:xmltoday-delayed-quotes"· Test the deployed stock quote web service by getting a sample stock quote:"get stock quote demo.bat", repeat the open and edit the file as done in "adminclient.bat"As a result of the demo script you should see the following line: XXX: 55.25· Finally you can undeploy the stock quote demo web service with the adminclient script:adminclient.bat samples\stock\undeploy.wsdd2.3Create and deploy a new Web ServicesWe will develop a simple Web Services that sum two numbers.· In "d:\apachefriends\xampp\axis\samples\" create the directory named "arithmetic"· Copy the three files (sumImpl.java, sum.java, deploy.wsdd) c"· cd "d:\apachefriends\xampp\axis\samples\arithmetic"· Compile "sumImpl.java": javac sumImpl.java· Compile "sum.java": javac sum.java· In F\classes\samples\" create thedirectory named "arithmetic"· Copy the files "sumImpl.class" and "sum.class" B-INF\classes\samples\arithmetic" 2004 . International Potato Center (CIP)

7Quick Tutorial for Web Services· cd "d:\apachefriends\xampp\axis\"· open, edit and save the file: d:\apachefriends\xampp\axis\adminclient.bat, set the path of JavaVirtual Machine and Apache Axis home.set JAVA HOME D:\j2sdk1.4.2 04set AXIS HOME D:\apachefriends\xampp\axis· Run: "adminclient.bat samples\arithmetic\deploy.wsdd" in the command lineYou should see the following output:Processing file samples/arithmetic/deploy.wsdd Admin Done processing /Admin · Check if the sum web service was deployed correctly by accessing the AxisServlet or click on the"View" link from the default Apache-AXIS tFileCodesumImpl.java package samples.arithmetic;public class sumImpl {public static void main(String [] args) {try {float ret sumnumbers(5,10);System.out.println(ret);} catch (Exception e) {System.err.println(e.toString());}}public static float sumnumbers(float first, float second){return (first second);}}sum.javapackage samples.arithmetic;public interface sum {Float sumnumbers(Float first, Float second);} 2004 . International Potato Center (CIP)

Web Services in Javadeploy.wsdd deployment xmlns "http://xml.apache.org/axis/wsdd/"xmlns:java "http://xml.apache.org/axis/wsdd/providers/java" service name "sum" provider "java:RPC" parameter name "className"value "samples.arithmetic.sumImpl"/ parameter name "allowedMethods" value "*"/ /service /deployment 2.4Related LinksTavernaOther TutorialOther TutorialSUN Web ServiceAddons for XAMPPAddons for XAMPPApache Axis Addon for XAMPP3Web Services in PHP3.1Pre-requesites in ww.brics.dk/ /www.apachefriends.org/de/xampp-windows.htmlThese pre-requesites were installed in a Windows 2000 with Service Pack 4.3.1.1Installing Apache and PHPFor this tutorial we used the XAMPP for Windows version 1.4.9 (xampp-win32-1.4.9-installer.exe)containing Apache HTTPD 2.0.52 and PHP 5.0.2 4.3.9Download from: or mpp-win32-1.4.9-installer.exe 2004 . International Potato Center (CIP)8

93.1.2Quick Tutorial for Web ServicesInstalling NuSOAPFor this tutorial we used the NuSOAP version 1.81 (nusoap.php)Download from: r soap.zipFor installing NuSOAP in XAMPP for Windows you only need to copy this file inside a directory of youweb document root (for example 3.2Create and deploy a new Web Services3.2.1Example for sum numbersWe will develop a simple Web Services that sum two numbers.· In "d:\apachefriends\xampp\htdocs\" create the directory named "arithmetic"· Create a directory "includes" into "d:\apachefriends\xampp\htdocs\" and copy the NuSOAP file(nusoap.php) inside the new directory.· Create a php file (sumwsdl.php) into "d:\apachefriends\xampp\htdocs\arithmetic"· Add the following code to the file.ActionCodeOpen the php ?phpcoderequire once('./includes/nusoap.php');Pull in theNuSOAP code server new soap server();Create theserverinstanceInitialize WSDL server- configureWSDL('sumwsdl', 'urn:sumwsdl');support server- register('sum',// method nameRegister thearray('first' 'xsd:int',method to'second' 'xsd:int'), // input parametersexposearray('return' 'xsd:int'), // output param'urn:sumwsdl',// namespace'urn:sumwsdl#sum',// soapaction'rpc',// style'encoded',// use'Sums two numbers'// documentation);Define themethod as aPHP functionfunction sum ( first, second) { result first second;return result;}Use therequest toinvoke theservice HTTP RAW POST DATA isset( HTTP RAW POST DATA) ? HTTP RAW POST DATA : ''; server- service( HTTP RAW POST DATA); 2004 . International Potato Center (CIP)

Web Services in PHP10Close the php ? code· When you run the web page the WSDL file will be autogenerate, and it is not necessary tocreate a WSDD file.· To see the WSDL, load the web page sending the parameter "?wsdl" (for this l).3.2.2Example for LDAPWe will develop a Web Services that validate user name and password using LDAP.First enable LDAP:LDAP support in PHP is not enabled by default. You will need to use the --with-ldap[ DIR]configuration option when compiling PHP to enable LDAP support. DIR is the LDAP base installdirectory. To enable SASL support, be sure --with-ldap-sasl[ DIR] is used, and that sasl.h exists on thesystem.Note to Win32 Users: In order to enable this module on a Windows environment, you mustcopy several files from the DLL folder of the PHP/Win32 binary package to the SYSTEM folderof your windows machine. (Ex: C:\WINNT\SYSTEM32, or C:\WINDOWS\SYSTEM). For PHP 4.2.0 copy libsasl.dll, for PHP 4.3.0 copy libeay32.dll and ssleay32.dll to your SYSTEMfolder.If you a re using XAMPP you may need to edit you php.ini file probably located atC:\Windows\php.iniThere is a section for optional modules and you probably need to enable ldap support byuncommenting the following line (remove the semi-colon to uncomment);extension php ldap.dlland second:· In "d:\apachefriends\xampp\htdocs\" create the directory named "authentication"· Create a directory "includes" into "d:\apachefriends\xampp\htdocs\" and copy the NuSOAP file(nusoap.php) inside the new directory.· Create a php file (checkNTuserwsdl.php) into "d:\apachefriends\xampp\htdocs\authentication"· Add the following code to the file.ActionOpen the php ?phpcode 2004 . International Potato Center (CIP)Code

11Quick Tutorial for Web ServicesDocumentatio m Name : Authentication with NTModule Name : Check NT userVersion : 1.1Purpose : Validate NT user name and passowrd using LDAPDependencies: PHP 5.0 and LDAPBased on:Reference: PHP Reference documentation for LDAPData Started : 2005-07-10Date Last modification : 2005-07-11Copyright (c) 2005 by International Potato Center(CIP), Lima, PerúLicense: GPLFunding from: CIP (International Potato Center), GCP (ChallengeProgram Generation)Team: Research Informatics Unit (CIP)Contact: cip-riu@cgiar.orgAuthor: Edwin Rojas (analyst/developer; CIP)Author: Luis Avila (developer; CIP)Author: Reinhard Simon (Head of RIU, /require once('./includes/nusoap.php');Pull in theNuSOAP code server new soap server();Create theserverinstanceInitialize WSDL server- dl');support server- register('checkNTuser', // method nameRegister thearray('username' 'xsd:string','password' method to'xsd:string','DomainName' expose'xsd:string','ldap server' 'xsd:string'), //input parametersarray('return' 'xsd:string'), // output param'urn:checkNTuserwsdl', // namespace'urn:checkNTuserwsdl#checkNTuser', // soapaction'rpc', // style'encoded', // use'Validate NT user name and password using LDAP '// documentation); 2004 . International Potato Center (CIP)

Web Services in PHPDefine themethod as aPHP functionfunctioncheckNTuser( username, password, DomainName, ldapserver){// returns true when user/pass enable bind toLDAP (Windows 2k). auth user username.'@'. DomainName; ldap server 'ldap://'. ldap server;if( connect @ldap connect( ldap server)){if( bind @ldap bind( connect, auth user, password)){@ldap close( connect);return('true');}//if bound to ldap}//if connected to ldap@ldap close( connect);return('false');}//end function checkNTuser HTTP RAW POST DATA isset( HTTP RAW POST DATA) ?Use the HTTP RAW POST DATA : '';request to server- service( HTTP RAW POST DATA);invoke theserviceClose the php ? code· When you run the web page the WSDL file will be autogenerate, and it is not necessary tocreate a WSDD file.· To see the WSDL, load the web page sending the parameter "?wsdl" (for this wsdl.php?wsdl).Download code from: eckNTuserwsdl.txtEjemplo de los parametros: user jperes password xxyyzz domain cgiarad.org server 172.00.00.00:00 sessionpath ww.google.comEjemplo de llamada desde un cliente PHP: 2004 . International Potato Center (CIP)12

13Quick Tutorial for Web Servicesfunction validationUser( user, password , domain, server, sessionpath){include once "nusoap.php"; parameters array('username' user, 'password' password,'DomainName' domain, 'ldap server' server); wsdl "http://". sdl"; soapclient new soapclient( wsdl, 'wsdl'); result soapclient- call("checkNTuser", parameters);if ( err soapclient- getError()) {return 'error';} else {return result;}}3.3Related LinksOther TutorialOther TutorialDietrich Ayala NuSOAPDietrich Ayala NuSOAP4Web Services in .NET4.1Pre-requesites in nx4.com/nusoap/downloads/7469 Chap08.pdfTheses pre-requesites was installed in a Windows 2000 with Service pack 4.After installing the pre-requisites, the structure should see as fallow: 2004 . International Potato Center (CIP)

Web Services in .NET4.1.114Installing IISFor this tutorial we used the Internet Information Services(IIS) that come with the installers of Windows2000 CDs.The IIS not require to shop any licence.· To install goto "Panel Control" -- "Add/Remove Programs" -- Add/Remove WindowsComponents· Select with a check in "Internet Information Services(IIS)"· Finally clicking in button "Next"After installation finished, to active the service of IIS fallow the next steps:· Goto Menu Start -- Run -- Type "inetmgr" and enter · In the window below: 2004 . International Potato Center (CIP)

15Quick Tutorial for Web Services· Select "Default Web Site (Stopped)"· Finally click in button4.1.2Installing Framework .NETThis component will be installed when installing the Visual Studio .NET (version 2002 or 2003)4.1.3Installing Visual Studio .NET· For this tutorial we used the Visual Studio 20034.2Create and deploy a new Web ServicesWe will develop a simple Web Services that sum two numbers.· Open Visual Studio .NET 2003· Goto: Menu File -- New -- Click "Project"· In the window below: 2004 . International Potato Center (CIP)

Web Services in .NET······In "Project Types:" select "Visual Basic Project"In "Templates:" select "ASP .NET Web Service"In the "location" box rename to "http://localhost/TestWebService"Click in button OKWhen finish creating the project, click in "click here to switch to code view"In the window below:· Add the code in red as shown in the table below: 2004 . International Potato Center (CIP)16

17Quick Tutorial for Web ServicesFileCodeAdd the red System.Web.Services.WebService(Namespacecode in file: ice1.asmx Description: "My first Web Services") " WebMethod(Description: "Hello, World as Web Service") Public Function HelloWorld() As StringReturn "Hello World"End Function WebMethod(Description: "Sum two numbers") Public Function sumnumbers(ByVal first As Double,ByVal second As Double) As DoubleReturn first secondEnd Function· After change the code you should see the code as fallow:· Finally give click in button, this will deploy the Web Service to IIS, create the WSDL, runand open the Browser to test the Web Service as shown below: 2004 . International Potato Center (CIP)

Web Services in .NET18· To test the methods, click in "HelloWorld" or "sumnumbers"· To see the WSDL, click in "Service Description"4.3Related LinksOther p/10926 10040811Other CEFA-D0FD-44BE-8749-8D17B5757564.dcikMicrosoft Web l Studio ET5Web Services with LavadoraThe Lavadora is a plug-in for the Eclipse for web servicesMain Features:· Automatic Web Service client code generation· Class-to-Web Service conversion· Deployment and undeployment of thus created Web Services to a local installation of Tomcatserver· WSDL document structure browsing· Caching of WSDL documents of frequently used Web Services (so called web references)· Browsing, searching and publishing in UDDI registries· Keeping track of all generated resources· Presentation of all plug-in related project data in a dedicated viewRelated Links:· Plug-in for Eclipse: http://www.eclipse-plugins.info/eclipse/plugin details.jsp?id 833 2004 . International Potato Center (CIP)

19Quick Tutorial for Web Services· Home Page Lavadora: http://lavadora.sourceforge.net/6Java vs PHP vs .NETThese comparisons is using the pre-requisites mentioned in the tutorial.InstallationCost of toolsSupport management console forsecurity (users and groups)More richness data type supportedGenerate automatic UI for test WebServicesJavaPHPdifficult veryeasyfreefreeyesno(usingTomcat)more s(withVisualStudio)nolessNeed to learn about WSDL or WSDDMore used for research andinvestigation activitiesview details or view detailsSupport for the latest standards likesecurity and reliabilitydebugging and test featuresview detailsyesmorenolessverygoodgoodmore or verylessgoodbadverygoodUse a richness framework (virtualmachine)view detailsAvailable libraries and free sourcesyesnotoomuchregular regularyes 2004 . International Potato Center (CIP)

This quick tutorial pretends to teach: How to install the pre-requisites for Web Services How to create and deploy a simple Web Services using WSDL This tutorial is an output about Web Services of Taverna/Web Services workshop given on November 2004. Tutorial created by: Edwin Rojas and Enver Tarazona Expositor: Martin Senger

Related Documents:

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

10 tips och tricks för att lyckas med ert sap-projekt 20 SAPSANYTT 2/2015 De flesta projektledare känner säkert till Cobb’s paradox. Martin Cobb verkade som CIO för sekretariatet för Treasury Board of Canada 1995 då han ställde frågan

service i Norge och Finland drivs inom ramen för ett enskilt företag (NRK. 1 och Yleisradio), fin ns det i Sverige tre: Ett för tv (Sveriges Television , SVT ), ett för radio (Sveriges Radio , SR ) och ett för utbildnings program (Sveriges Utbildningsradio, UR, vilket till följd av sin begränsade storlek inte återfinns bland de 25 största

Hotell För hotell anges de tre klasserna A/B, C och D. Det betyder att den "normala" standarden C är acceptabel men att motiven för en högre standard är starka. Ljudklass C motsvarar de tidigare normkraven för hotell, ljudklass A/B motsvarar kraven för moderna hotell med hög standard och ljudklass D kan användas vid

LÄS NOGGRANT FÖLJANDE VILLKOR FÖR APPLE DEVELOPER PROGRAM LICENCE . Apple Developer Program License Agreement Syfte Du vill använda Apple-mjukvara (enligt definitionen nedan) för att utveckla en eller flera Applikationer (enligt definitionen nedan) för Apple-märkta produkter. . Applikationer som utvecklas för iOS-produkter, Apple .

och krav. Maskinerna skriver ut upp till fyra tum breda etiketter med direkt termoteknik och termotransferteknik och är lämpliga för en lång rad användningsområden på vertikala marknader. TD-seriens professionella etikettskrivare för . skrivbordet. Brothers nya avancerade 4-tums etikettskrivare för skrivbordet är effektiva och enkla att

Den kanadensiska språkvetaren Jim Cummins har visat i sin forskning från år 1979 att det kan ta 1 till 3 år för att lära sig ett vardagsspråk och mellan 5 till 7 år för att behärska ett akademiskt språk.4 Han införde två begrepp för att beskriva elevernas språkliga kompetens: BI

additif alimentaire ainsi que d’une nouvelle utilisation pour un additif alimentaire déjà permis. Les dispositions réglementaires pour les additifs alimentaires figurent à la partie B du titre 16 du RAD. L’article B.16.001 énumère les exigences relatives à l’étiquetage des additifs alimentaires. En particulier, l’article B.16.002 énumère la liste des critères qui doivent .