Implementing a Web Service Client using Java



Similar documents
Overview of Web Services API

Java Access to Oracle CRM On Demand. By: Joerg Wallmueller Melbourne, Australia

Mobile Labs Plugin for IBM Urban Code Deploy

Active Directory Authentication Integration

Integrating VoltDB with Hadoop

EMC Clinical Archiving

Secure Messaging Server Console... 2

XMLVend Protocol Message Validation Suite

Installing the ASP.NET VETtrak APIs onto IIS 5 or 6

Capture Pro Software FTP Server System Output

Lucid Key Server v2 Installation Documentation.

Web Testing, Java Testing, Server Monitoring. AppPerfect Installation Guide

MANAGING OUTLOOK PERSONAL DATA FILES

Builder User Guide. Version 5.4. Visual Rules Suite - Builder. Bosch Software Innovations

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

LAE 5.1. Windows Server Installation Guide. Version 1.0

Advanced Digital Imaging

SFTP Server User Login Instructions. Open Internet explorer and enter the following url:

How To Install Storegrid Server On Linux On A Microsoft Ubuntu 7.5 (Amd64) Or Ubuntu (Amd86) (Amd77) (Orchestra) (For Ubuntu) (Permanent) (Powerpoint

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

Force.com Migration Tool Guide

Builder User Guide. Version Visual Rules Suite - Builder. Bosch Software Innovations

Using Internet or Windows Explorer to Upload Your Site

SETTING UP YOUR JAVA DEVELOPER ENVIRONMENT

PDQ-Wizard Prototype 1.0 Installation Guide

HYPERION SYSTEM 9 N-TIER INSTALLATION GUIDE MASTER DATA MANAGEMENT RELEASE 9.2

Active Directory Requirements and Setup

ArpViewer Manual Version Datum

State of Michigan Data Exchange Gateway. Web-Interface Users Guide

Eylean server deployment guide

EBOX Digital Content Management System (CMS) User Guide For Site Owners & Administrators

StreamServe Persuasion SP4

Access Instructions for United Stationers ECDB (ecommerce Database) 2.0

Java Web Services Developer Pack. Copyright 2003 David A. Wilson. All rights reserved.

Polar Help Desk Installation Guide

A Sample OFBiz application implementing remote access via RMI and SOAP Table of contents

Third-Party Software Support. Converting from SAS Table Server to a SQL Server Database

Hello World RESTful web service tutorial

DocuSign for SharePoint

SDK Code Examples Version 2.4.2

Capture Pro Software FTP Server Output Format

PHP Language Binding Guide For The Connection Cloud Web Services

Developer's Guide: Driving Tivoli Workload Automation

Decision Support AITS University Administration. EDDIE 4.1 User Guide

Mass-DAC Secure Document Repository User Guide

Compiere ERP & CRM Installation Instructions Linux System - EnterpriseDB

Using a Remote SQL Server Best Practices

Alert Notification of Critical Results (ANCR) Public Domain Deployment Instructions

Montefiore Portal Quick Reference Guide

Indian Standards on DVDs. Installation Manual Version 1.0. Prepared by Everonn Education Ltd

EMC Documentum Composer

Content Management System

Install guide for Websphere 7.0

Creating A Walking Skeleton

The goal with this tutorial is to show how to implement and use the Selenium testing framework.

How to install phpbb forum on NTU student club web server

Online Client Portal Client User Guide

NSi Mobile Installation Guide. Version 6.2

Project Management (PM) Cell

European Access Point for Truck Parking Data

Using Actian PSQL as a Data Store with VMware vfabric SQLFire. Actian PSQL White Paper May 2013

DocAve 6 SDK and Management Shell

Kuali Security Request Installation Guide

Trend Micro Worry- Free Business Security st time setup Tips & Tricks

Implementing SQI via SOAP Web-Services

Secure FTP. Client user guide. Author: Steria A/S Version: 2.2 Date: 20 January 2010 Document SecureFtpClientUserguideV2_2.doc

Creating a Java application using Perfect Developer and the Java Develo...

Automated CPanel Backup Script. for home directory backup, remote FTP backup and Amazon S3 backup

Oracle Utilities Customer Care and Billing Integration to Oracle Utilities Meter Data Management

ShadowControl ShadowStream

We begin with a number of definitions, and follow through to the conclusion of the installation.

The presentation explains how to create and access the web services using the user interface. WebServices.ppt. Page 1 of 14

Extending Remote Desktop for Large Installations. Distributed Package Installs

Talk Internet User Guides Controlgate Administrative User Guide

Enterprise Data Integration (EDI)

Practice Fusion API Client Installation Guide for Windows

Java Web Services SDK

Customizing the SSOSessionTimeout.jsp page for Kofax Front Office Server 3.5.2

Backing Up CNG SAFE Version 6.0

Deploying Microsoft Operations Manager with the BIG-IP system and icontrol

NMR HTTP/FTP Data Download Package

WebSphere Business Monitor V7.0: Clustering Single cluster deployment environment pattern

Information Technology Services

NovaBACKUP Remote Workforce Version 12.5 Cloud Restore

E-invoice manual Instruction for a client implementation of the B2B web service

Bitrix Site Manager ASP.NET. Installation Guide

The Web Pro Miami, Inc. 615 Santander Ave, Unit C Coral Gables, FL T: info@thewebpro.com

RPC over XML. Web services with Java. How to install it? Reference implementation. Setting the environment variables. Preparing the system

Moveit DMZ User Manual

Installing, Uninstalling, and Upgrading Service Monitor

Microsoft FTP Configuration Guide for Helm 4

TIBCO ActiveMatrix BusinessWorks Plug-in for TIBCO Managed File Transfer Software Installation

Installation Guide for Websphere ND

Montefiore Portal Quick Reference Guide

9. Database Management Utility

for Networks Installation Guide for the application on the server July 2014 (GUIDE 2) Lucid Rapid Version 6.05-N and later

Transcription:

Implementing a Web Service Client using Java Requirements This guide is based on implementing a Java Client using JAX-WS that comes with Java Web Services Developer Pack version 2.0 (JWSDP). This can be downloaded from the following location http://java.sun.com/webservices/downloads/previous/index.jsp This guide explains how to modify the sample solution in JWSDP to write a web service client that connects to PageOne SOAP Server. The sample solution can be found on the following location YOUR_JWSDP_INSTALLATION_ROOT\jwsdp-2.0\jaxws\samples\fromwsdl Follow the instructions below to write your own client Editing the build scripts 1. Before you start editing the sample we recommend creating a back up of the fromwsdl folder. 2. Copy the PageOne liquidsoap.wsdl to fromwsdl/etc folder. Also create a subfolder xsd and copy the schema that is referred in the liquidsoap.wsdl. 3. Modify your build.xml as follows At the beginning of the build file, edit the path to the sjsas.props file and libraries if necessary. You can remove the sections that are not required to generate clients. Please refer to the ant script at the end of the document to see the sections you will need. Also change the project s default parameter to server from the default help mode. This is the very first line of the build file. 4. Within the /etc folder you will find the other files that are used in build.xml. Edit the following files as follows File build.properties server.wsdl=etc/liquidsoap.wsdl client.wsdl=https://m2m.oventus.com/liquidws/messageservice?wsdl v1.1

client=fromwsdl.client.liquidsoap File custom-server.xml wsdllocation="liquidsoap.wsdl" targetnamespace='http://schemas.oventus.com/' File custom-client.xml wsdllocation=https://m2m.oventus.com/liquidws/messageservice?wsdl targetnamespace='http://schemas.oventus.com/' 5. Delete the contents of src\fromwsdl\server since you do not need to generate the server 6. Also delete the client class in src\fromwsdl\client. You will be writing a fresh client class to invoke the service. Before running the ant script, make sure that you have the required elements in your classpath. Generating Client Stubs 7. Run your ant script. This will generate all the classes you will need to write the Web Service client. These classes will be generated within the build folder of the project root directory. Implementing the Client The client class uses the following classes that were generated in the previous steps. 1. MessageServicePortType The port type class provides and interface to access the methods offered in the web service. 2. MessageService This class is used to get access to the port. 3. ObjectFactory ObjectFactory is used to generated Object Types that are used in constructing or accessing the soap messages.

4. Following is an outline of the client class. Place this class in src\fromwsdl\client package fromwsdl.client; import com.pageone.liquidsoap.jaxb.*; public class LiquidSoap public String invokemylogin() try MessageServicePortType port = new MessageService().getMessagePort(); ObjectFactory objfac = new ObjectFactory(); l l LoginRequest loginrequest = objfac.createloginrequest(); oginrequest.setuserid("username"); oginrequest.setpwd("password"); LoginResponse loginresponse = objfac.createloginresponse(); PageoneHeader pageoneheader = objfac.createpageoneheader(); javax.xml.ws.holder loginholder = new javax.xml.ws.holder(loginresponse); javax.xml.ws.holde r headerholder = new javax.xml.ws.holder(pageoneheader); p ort.login(loginrequest,headerholder, loginholder ); PageoneHeader p1header = (PageoneHeader)headerHolder.value; LoginResponse logresponse = (LoginResponse) loginholder.value; StatusType statustype = logresponse.getstatus(); System.out.pri ntln("session ID is >>> "+p1header.getsessionid()); System.out.println("Status is >>> "+statustype.getvalue()+" "+statustype.getdescription()); return p1header.getsessionid(); catch (Exception ex) ex.pri ntstacktrace(); return null; public void invokemysendmessage(string sessionid) try MessageS erviceporttype port = new MessageService().getMessagePort();

ObjectFactory objfac = new ObjectFactory(); SendMessageType sendmessagetype = objfac.createsendmessagetype(); PageoneHeader pageoneheader = objfac.createpageoneheader(); pageoneheader.setsessi onid(sessionid); sendmessagetype.setsourceaddress(nul l); sendmessagetype.setmessage("hel lo test client sample"); sendmessagetype.setfl ashsms(true); sendmessagetype. getdestinationaddress().add("valid ADDRESS"); SendMessageResponseType sendresponse = port.sendmessage(pageoneheader,sendmessagetype); System.out.pri ntln("send Response transactionid "+sendresponse.gettransactionid().getvalue()); catch ex.pri (Exception ex) ntstacktrace(); public static void main (String[] args) try LiquidSoap ls = new LiquidSoap(); String sessionid = ls.invokemylogin(); l s.invokemysendmessage(sessionid); catch (Exception ex) NOTE Please make sure you set a valid username and password in login request and also a valid destination address in sendmessagetype. The above class creates a SOAP login request and sends to the PageOne SOAP server. Then the sessionid is extracted from the login response and a SOAP sendmessage request is sent. If you do not set these you will not be able to see the results.

Running the client 1. You can automate generating client classes as part of your ant script edit your build.xml by adding <antcall target="client" /> in targets section at the bottom of your file. 2. Run your ant script to generate client classes. 3. Finally you can run your client class by >> java fromwsdl.client.liquidsoap (this class file located at build\classes\fromwsdl\client) The basic Ant script required for generating the client <project basedir="." default="server" name="fromwsdl"> <property environment="env"/> <property file="../../../jwsdp-shared/bin/sjsas.props"/> <condition property="lib.home" value="../../../jaxws/lib"> <available file="../../../jwsdp-shared/bin/sjsas.props"/> </condition> <condition property="lib.home" value="$env.jaxws_home/lib"> <not> <available file="../../../jwsdp-shared/bin/sjsas.props"/> </not> </condition> <property file="etc/build.properties" /> <property name="build.home" value="$basedir/build"/> <property name="build.classes.home" value="$build.home/classes"/> <path id="jaxws.classpath"> <pathelement location="$java.home/../lib/tools.jar"/> <pathelement location="$lib.sample.home/jaxwssampleutils.jar"/> <fileset dir="$lib.home"> <include name="*.jar"/> <exclude name="j2ee.jar"/> </fileset> </path> <taskdef name="wsimport" classname="com.sun.tools.ws.ant.wsimport"> <classpath refid="jaxws.classpath"/> </taskdef> <target name="setup">

<mkdir dir="$build.home"/> <mkdir dir="$build.classes.home"/> <target name="clean"> <delete dir="$build.home" includeemptydirs="true" /> <target name="generate-client" depends="setup"> <wsimport debug="$debug" verbose="$verbose" keep="$keep" extension="$extension" destdir="$build.classes.home" wsdl="$client.wsdl"> <binding dir="$basedir/etc" includes="$client.binding"/> </wsimport> <target name="client" depends="generate-client"> <javac fork="true" srcdir="$basedir/src" destdir="$build.classes.home" includes="**/client/**,**/common/**"> <classpath refid="jaxws.classpath"/> </javac> <target name="server" depends="setup"> <antcall target="clean" /> < antcall target="client" /> </project>