WSTK Development toolkit for Java Implementation of Web Services By Keping Jia.

31
WSTK elopment toolkit for Java Implementation of Web Ser By Keping Jia

Transcript of WSTK Development toolkit for Java Implementation of Web Services By Keping Jia.

WSTK

Development toolkit for Java Implementation of Web Services

By

Keping Jia

1.Intruduction

SoapHTTP

Why?

1. Facilitate software integration----Platform and language independent.

WSDL,SOAP,XML ----Dynamic finding & binding

UDDI

2. Comply with existing Internet infrastructure.----SOAP over HTTP

Implementation practice1.Abstract architecture

client Web service deployment environment

SOAP/HTTPbinding

2.Implementation architecture

client http parser soap parserservice

implementation

http

3.Java implementation architecture

client web server Servlet Java class

J2EE

http soap private protocol

2. WSTK --- Web service tool kit

2.1 Composition

Client side

Service side

Example:

public class jkpAdd{

public int add(int a,int b){

return a+b;}

}

1. Compile jkpAdd.java

2. Creating jkpAdd WSDL Descriptions. There are two files that need to be created: (1) A service interface definition and (2) A service implementation definition.

Interface WSDL:

Service WSDL:

Generating command:java -cp %WSTK_CP% org.apache.axis.wsdl.Java2WSDL -N http://jkpAdd -n http://jkpAdd-interface -o c:\wstk-3.1\services\applications\jkpAdd\webapp\jkpAdd_Interface.wsdl -O c:\wstk-3.1\services\applications\jkpAdd\webapp\jkpAdd_Impl.wsdl-L "http://localhost:80/jkpAdd/jkpAdd_Interface.wsdl" -m "add" -l http://localhost:80/jkpAdd/services/jkpAddjkpAdd

3.Deploying services (1) Creating the axis deployment descriptor

(2) Deploying the service WAR with the WSTK configuration tool

3.Registering the service with Axis

DEPLOY http://localhost:^<port^>/jkpAdd/services/AdminService deploy.wsdd

Service publishing

More in detail ……

Example:

Example:

---TModel

Standard Categorization Recommended by UDDI (version 1.03)

1.UDDI Types Taxonomy

2.North American Industry Classification System (NAICS) 1997 Release

3.United Nations Standard Products and Services Code System (UNSPSC) Version 3.1

4.Universal Standard Products and Services Classification (UNSPSC) Version 7.3

5.ISO 3166 Geographic Taxonomy

6. General Keywords Taxonomy

Standard Categorization Recommended by UDDI (version 2.01)

1.UDDI Types TaxonomytModel UUID: uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4

2.North American Industry Classification System (NAICS) 1997 ReleasetModel UUID: uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2

3.United Nations Standard Products and Services Code System (UNSPSC) Version 3.1tModel UUID: uuid:DB77450D-9FA8-45D4-A7BC-04411D14E384

4.Universal Standard Products and Services Classification (UNSPSC) Version 7.0tModel UUID: uuid:CD153257-086A-4237-B336-6BDCBDCC6634

5.ISO 3166 Geographic TaxonomytModel UUID: uuid:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88

6. General Keywords TaxonomytModel UUID: uuid:A035A07C-F362-44dd-8F95-E2B134BF43B4

Example:North American Industry Classification System (NAICS) 1997 Release

tModel Definition tModels: Name: ntis-gov:naics:1997 Description: Business Taxonomy: NAICS (1997 Release) tModel UUID: uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2

Valid ValuesSee http://www.census.gov/epcd/www/naics.html or any of the UDDI operator sites to browse the list of valid NAICS 1997 release codes.

<businessEntity businessKey=... ... <categoryBag> <!-- Classify this businessEntity using the NAICS taxonomy --> <keyedReference keyName="Non-scheduled chartered freight air transportation" keyValue="481212" tModelKey="uuid:C0B9FE13-179F-413d-8A5B-5004DB8E5BB2"/> </categoryBag>...</businessEntity>

ISO 3166 Geographic Taxonomy

tModel Definition tModels: Name: uddi-org:iso-ch:3166-1999 tModel UUID: uuid:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88

Valid Valuessee http://www.uddi.org/taxonomies/iso3166-1999-utf8.txt

Example of Use<businessEntity businessKey=... ... <categoryBag> <!-- Categorize this businessEntity as serving California using the ISO 3166 taxonomy --> <keyedReference keyName="California, USA" keyValue="US-CA" tModelKey="uuid:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88"/> </categoryBag>...</businessEntity>

//Program example:import java.util.Vector;import com.ibm.uddi4j.wsdl.client.UDDIWSDLProxy;import com.ibm.uddi4j.wsdl.provider.ServiceProvider;import com.ibm.uddi4j.wsdl.axis.AxisServiceDefinition;import com.ibm.uddi4j.wsdl.definition.ServiceInterface;import org.uddi4j.util.CategoryBag;import org.uddi4j.util.KeyedReference;import com.ibm.wstk.uddi.TModelKeyTable;import com.ibm.wstk.WSTKConstants;

public class NQPublish{

public static void main(String[] args) throws Exception {

try {

//------------------------------------------------------ // let's collect the input arguments //------------------------------------------------------ String serviceImplementationWSDL = args[0]; String serviceInterfaceWSDL = args[1]; //------------------------------------------------------ // this will use whatever UDDI registry you selected // in the WSTK Configuration Tool //------------------------------------------------------ UDDIWSDLProxy uwp = new UDDIWSDLProxy(WSTKConstants.UDDI_INQUIRY_URL, WSTKConstants.UDDI_PUBLISH_URL, WSTKConstants.UDDI_USERID, WSTKConstants.UDDI_CRED, WSTKConstants.TRANSPORT_CLASS);

//------------------------------------------------------ // assuming that you haven't yet registered yourself as // a Service Provider, do the following steps. If you // have already registered as a service provider, you // should use your existing registration //------------------------------------------------------ KeyedReference keyedReference = new KeyedReference(TModelKeyTable.UNSPSC, "84.12.18.01.00");

keyedReference.setTModelKey(TModelKeyTable.UNSPSC_TMODEL_KEY);

Vector keyedReferenceVector = new Vector(); keyedReferenceVector.add(keyedReference);

// Create category bag CategoryBag spCatList = new CategoryBag(); spCatList.setKeyedReferenceVector(keyedReferenceVector);

ServiceProvider sp = new ServiceProvider("WSTK 3.1 jkpAdd", "WSTK 3.1 jkpAdd", spCatList); sp = uwp.publish(sp);

//------------------------------------------------------ // now we publish the service interface //------------------------------------------------------ ServiceInterface si = new ServiceInterface(serviceInterfaceWSDL); si = uwp.publish(si);

//------------------------------------------------------ // now we deploy and publish the service itself //------------------------------------------------------ keyedReference = new KeyedReference(TModelKeyTable.UNSPSC, "84.12.18.01.00");

keyedReference.setTModelKey(TModelKeyTable.UNSPSC_TMODEL_KEY);

keyedReferenceVector = new Vector(); keyedReferenceVector.add(keyedReference);

// Create category bag CategoryBag sdCatList = new CategoryBag(); spCatList.setKeyedReferenceVector(keyedReferenceVector);

// AxisServiceDefinition sd = new AxisServiceDefinition( serviceImplementationWSDL, sdCatList, serviceDeployment, serviceMgr);

uwp.publish(sp, sd); //- publish the service } catch (Exception e) { System.out.println("There was an error (" + e + ")"); } }

}

UDDI APIs tend to fall into four broad categories.

1. There are messages used to search for things such as businesses or services. These messages start with find_xxx where xxx is the name type of object you are searching for, e.g. find_business and find_service. Like any search mechanism, find messages let you specify search criteria such as names,categories and identifiers. When searching by names, you can specify a % sign as a wildcard character.

2.The second group of messages is the detail messages which follow the naming convention get_xxxDetail where xxx is the type of object for which you want detailed information. For example, get_businessDetail and get_tModelDetail return the details of a business and a tModel respectively.A get_xxxDetail message contains the unique identifier of the object for which you want detailed information. For example, get_businessDetail contains a businessKey while get_tModelDetail containsa tModelKey.

3.The third group is the save messages, e.g save_business and save_binding. These APIs can be used tosave new objects or to replace existing objects. When saving new objects, the response message containsthe newly saved object key.

4.Finally, the delete messages such as delete_business and delete_publisherAssertions, delete specifiedobjects. Similar to get_xxxDetail messages, most delete messages also require a key that uniquely identifies the object to be deleted.

Finding services in UDDI

Finding a Business by Name

Finding Businesses by Categories

Finding Service Interfaces

Finding Businesses by Service Interface

Finding Services by Name

Example:import java.util.Vector;import com.ibm.uddi4j.wsdl.client.UDDIWSDLProxy;import com.ibm.uddi4j.wsdl.definition.ServiceDefinition;import com.ibm.uddi4j.wsdl.provider.ServiceProvider;import com.ibm.wstk.wsdl.*;import com.ibm.wstk.*;public class NasdaqQuotesClient { public static String findUDDI(String service) throws Exception { try { UDDIWSDLProxy uwp = new UDDIWSDLProxy(WSTKConstants.UDDI_INQUIRY_URL, WSTKConstants.UDDI_PUBLISH_WSTK Constants.UDDI_USERID, WSTKConstants.UDDI_CRED, WSTKConstants.TRANSPORT_CLASS); Vector providerNameVector = new Vector(); providerNameVector.add(new Name("WSTK 3.1 jkpAdd")); ServiceProvider[] sps = uwp.findAllServiceProviders(null, providerNameVector, null,null,null,null,true); if (sps.length > 0) { ServiceDefinition sd = sps[0].getServiceDefinition(service); //service: jkpAdd return sd.getServiceImplementation().getWSDLFilename(); } else { return null; } } catch (Exception e) { System.exit(0);} }}

2.2 WSTK structure