Companywebcast API Wiki
Navigation
Cwc API Home
PlayerSDK
Meta Service
Getting Started
Creating a client
Methods
Data Types
Understanding Webcast security
Management Service
Getting Started
Creating a client
Methods
Data Types
Quick Search
Advanced Search »
Back
History
MetaService 1.0 : Creating a JSP Client
Creating a Java client that consumes the MetaService is easy. There are many ways to achieve workable results, your choice for one may depend on your existing environment or IDE. We've tested Axis, Axis2, JAX-RPC and JAX-WS/Metro, in Netbeans and Eclipse with Tomcat 6 and Glassfish 2 and 3. Below are 2 different approaches to consuming the MetaService. {TOC} ====Creating a client with the NetBeans IDE==== NetBeans 6.5 has excellent support for consuming webservices, by default proxies are generated in a JAX-WS/Metro environment and this makes creating a functional client extremely straight forward. *Create a new Java Web Application *Right click your new project and select New => Web Service Client *In the dialogue that appears, enter the URL to the MetaService WSDL file, make sure it targets JAX-WS and click finish *In your project a new folder will be added called Web Service References. Open this folder and you should see the MetaService. *You can now drop in code that talks to the MetaService like this: Open Web Service References, open MetaService and keep opening the MetaService tree untill you find the WebcastGet and WebcastSearch methods. Click down on a method and drag it into your JSP file ... functional client code will be dropped in place and all you need to do is fill in your input parameters and run your application. Here's a sample that finds all webcasts available to "testusername", and then retrieves the metadata for the first result. <code JAVA> <%@page import="com.companywebcast.schemas.pulse.metaservice.v1.*" %> <%@page import="javax.xml.datatype.XMLGregorianCalendar" %> <%@page import="java.util.List" %> <%@page import="javax.xml.ws.Holder" %> <% try { String username = "testusername"; String password = "testpassword"; // create the client MetaService client = new MetaService_Service().getBasicHttpBindingMetaService(); // set up the search parameters String ownerName = ""; String topicTitle = ""; String speakerLastName = ""; String webcastTitle = ""; XMLGregorianCalendar periodFrom = null; XMLGregorianCalendar periodTo = null; List<List<String>> status = null; Integer pageNumber = Integer.valueOf(0); Integer pageSize = Integer.valueOf(100); //these holders will contain the response from the MetaService after we call it Holder<Integer> SearchResultHolder = new Holder<Integer>(); Holder<WebcastSummaries> SummariesHolder = new Holder<WebcastSummaries>(); //call the MetaService client.webcastSearch(username, password, ownerName, topicTitle, speakerLastName, webcastTitle, periodFrom, periodTo, status, pageNumber, pageSize, SearchResultHolder, SummariesHolder); Integer SearchResult = SearchResultHolder.value; WebcastSummaries Summaries = SummariesHolder.value; // set up the get parameters String code= Summaries.getWebcastSummary().get(0).getCode(); String language = Summaries.getWebcastSummary().get(0).getLanguages().getString().get(0); //these holders will contain the response from the MetaService after we call it Holder<Integer> GetResultHolder = new Holder<Integer>(); Holder<Webcast> WebcastHolder = new Holder<Webcast>(); //call the MetaService client.webcastGet(username, password, code, language, GetResultHolder, WebcastHolder); Integer GetResult = GetResultHolder.value; Webcast Webcast = WebcastHolder.value; } catch (Exception ex) { //TODO } %> </code> An important note is that JAX-WS/Metro is a standard component of Glassfish v2, but Glassfish v3 and other application servers like Tomcat need JAX-WS/Metro to either be upgraded to the full version, or seperately installed for your application server. For Glassfish v3 you can use its updatetool to install the "Metro Web Services Stack". For Tomcat 5 and 6 [http://x-monk.blogspot.com/2007/11/metro-on-tomcat-5x-and-6x.html|this page] explains the procedure. ====Creating a client with the Eclipse IDE for Java EE Developers==== Eclipse by default seems to use Axis for generating a web service client, so let's see how we can get it to work with the MetaService. *Create a new Dynamic Web Project *From the top menu, select Run => Launch the Web Services Explorer *In the top right of the Web Services Explorer, click the WSDL page button *Enter the MetaService url and click Go *In the Navigator pane, click on the MetaService URL, scroll to the bottom of the Actions page and click Launch Web Service Wizard *Select Web Service Client and click Go *In the Web Service Client dialogue that appears, drag the slider so it's a "Develop client", make sure it targets Axis, your project and the server you will run this application on. Click next, then Finish. Eclipse generated proxy code for us, and we can now use it like this: <code JAVA> <%@page import="com.companywebcast.schemas.pulse.metaservice.v1.*" %> <%@page import="com.companywebcast.schemas.pulse.metaservice.v1.holders.*" %> <%@page import="java.util.Calendar" %> <%@page import="javax.xml.rpc.holders.IntegerWrapperHolder"%> <% try { String username = "testusername"; String password = "testpassword"; MetaServiceProxy client = new MetaServiceProxy(); String ownerName = ""; String topicTitle = ""; String speakerLastName = ""; String webcastTitle = ""; Calendar periodFrom = null; Calendar periodTo = null; String[] status = null; Integer pageNumber = Integer.valueOf(0); Integer pageSize = Integer.valueOf(100); IntegerWrapperHolder SearchResultHolder = new IntegerWrapperHolder(); WebcastSummariesHolder SummariesHolder = new WebcastSummariesHolder(); client.webcastSearch(username, password, ownerName, topicTitle, speakerLastName, webcastTitle, periodFrom, periodTo, status, pageNumber, pageSize, SearchResultHolder, SummariesHolder); Integer SearchResult = SearchResultHolder.value; WebcastSummary[] Summaries = SummariesHolder.value; String code= Summaries[0].getCode(); String language = Summaries[0].getLanguages()[0]; IntegerWrapperHolder GetResultHolder = new IntegerWrapperHolder(); WebcastHolder WebcastHolder = new WebcastHolder(); client.webcastGet(username, password, code, language, GetResultHolder, WebcastHolder); Integer GetResult = GetResultHolder.value; Webcast Webcast = WebcastHolder.value; } catch (Exception ex) { //TODO } %> </code>