DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.
-
Upload
abner-dixon -
Category
Documents
-
view
230 -
download
3
Transcript of DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.
![Page 1: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/1.jpg)
DEVELOPING WEB SERVICES WITH JAVA
WSDL & SERVICE REGISTRYWSDL & SERVICE REGISTRY
![Page 2: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/2.jpg)
CONTENTS• Elements of WSDL
• Web Service Registry
• Steps to configure the registry Server and use the JAXR to publish, query and delete registry on registry services.
• Exercises
![Page 3: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/3.jpg)
SERVICE DESCRIPTION LANGUAGE – SDL
Platform A
Service 1
………….………….………….
Platform B
Service 2
………….………….………….
Description of service written in SDL
Specifies functionality of service
Lists the parameters required by the exposed method
Lists parameters returned by methods
Documents the Web service contract (messages that the Web Service will generate and accept)
CompatibilityIssues
![Page 4: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/4.jpg)
WEB SERVICE DESCRIPTION LANGUAGE – WSDL or WISDEL
Web Service
Consumer
………………………
Web Service
•XML file describing Web services acts as a contract between the Web service consumer and the Web service
•Location of Web Service
•Type of protocol to be used
•Allow specifying the way in which a service can be access
•Use to explain how a particular Web Service works. It provides businesses with a standardized way of describing how applications and processes can interact online.
•A WS proxy supports communication
![Page 5: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/5.jpg)
WSDL FOR SERVICE PROVIDERS & CONSUMERS
![Page 6: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/6.jpg)
WSDL DOCUMENT STRUCTURE• WSDL being an XML document begins with an XML
declaration that specifies the XML version as 1.0 and the character encoding as UTF-8.
• Consists of six elements– definitions– types– message– portType– binding– service
serv
ices
bin
ding
s
Por
t T
ypes
mes
sage
s
typ
es
Platform and Language Independent
Abstract Definitions
Machine or Language Specific
Concrete Definitions
modifies
operations
ports
![Page 7: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/7.jpg)
WSDL DOCUMENT STRUCTURE (cont)<wsdl:definitions targetNamespace="http://localhost:8081/axis/Calculator. <wsdl:definitions targetNamespace="http://localhost:8081/axis/Calculator.
• definitions– Is the root component of the WSDL file– The targetNamespace attribute declares a namespace
to which all names declared in an element will belong– The purpose of namespaces is to avoid naming
conflicts– Acts as a container for the elements types, message,
portType, binding and service. – Defines the name of the Web Service and also one or
more namespaces used by its child elements.
![Page 8: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/8.jpg)
WSDL DOCUMENT STRUCTURE (cont)<wsdl:types><wsdl:types>- <schema targetNamespace="urn:fibonacci" - <schema targetNamespace="urn:fibonacci" xmlns="http://www.w3.org/2001/XMLSchema">xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> <import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> - <complexType name="ArrayOf_xsd_int">- <complexType name="ArrayOf_xsd_int">- <complexContent>- <complexContent>- <restriction base="soapenc:Array">- <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:int[]" /> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:int[]" /> </restriction></restriction> </complexContent></complexContent> </complexType></complexType> </schema></schema> </wsdl:types></wsdl:types>
• types
– Defines the data type of the information exchanged between applications.
– Is mandatory only if the data type is other than the built-in data types of XML Schema. Example of XML schema’s built-in types are string, integer and so on
![Page 9: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/9.jpg)
WSDL DOCUMENT STRUCTURE (cont)
<wsdl:message name="calFibonacciRequest"><wsdl:message name="calFibonacciRequest"> <wsdl:part name="in0" type="xsd:int"/><wsdl:part name="in0" type="xsd:int"/> </wsdl:message></wsdl:message>
• message– Describes the content of messages exchanged by applications. – Specifies the service’s request and response mechanism– Not dependent upon any protocol i.e. there is no naming
convention for message names. Ex: add Request, add Response– Divided into parts (arguments in method)
• Each part is defined by the <part> element • A part may be visualized as a parameter value, or the return value in a
typical RPC• A message element may contain zero or more <part> elements
![Page 10: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/10.jpg)
WSDL DOCUMENT STRUCTURE (cont)
<wsdl:portType name="Fibonacci"><wsdl:portType name="Fibonacci"> <wsdl:operation name="calFibonacci" parameterOrder="in0"><wsdl:operation name="calFibonacci" parameterOrder="in0"> <wsdl:input message="impl:calFibonacciRequest" <wsdl:input message="impl:calFibonacciRequest" name="calFibonacciRequest"/>name="calFibonacciRequest"/> <wsdl:output message="impl:calFibonacciResponse" <wsdl:output message="impl:calFibonacciResponse" name="calFibonacciResponse"/>name="calFibonacciResponse"/> </wsdl:operation></wsdl:operation> … … </wsdl:portType></wsdl:portType>
• portType– Defines operations provided by the Web Service. It often bean references to
the message elements– The operations (methods) are collectively referred to as portType. They are
defined on every portType– Operations (input output messages) are to be defined by specifying the
<operation> element
• operations– Distinguishes between the input, output, or fault message– Operations are apart from the message definitions
![Page 11: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/11.jpg)
WSDL DOCUMENT STRUCTURE (cont)
<wsdl:binding name="fibonacciSoapBinding" type="impl:Fibonacci"><wsdl:binding name="fibonacciSoapBinding" type="impl:Fibonacci"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="calFibonacci"><wsdl:operation name="calFibonacci"> <wsdlsoap:operation soapAction=""/><wsdlsoap:operation soapAction=""/> <wsdl:input name="calFibonacciRequest"><wsdl:input name="calFibonacciRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:fibonacci" use="encoded"/>namespace="urn:fibonacci" use="encoded"/> </wsdl:input></wsdl:input> <wsdl:output name="calFibonacciResponse"><wsdl:output name="calFibonacciResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:fibonacci" use="encoded"/>namespace="urn:fibonacci" use="encoded"/> </wsdl:output></wsdl:output> </wsdl:operation></wsdl:operation> … … </wsdl:binding></wsdl:binding>
• binding– Describes how the input and output messages of each operation defined in portType
element will be transmitted over the Internet from one application to another – Represents the concrete descriptions of the operations– Specifies the representation of parameters for a Web method– Are specified for each method of service consumption– The encoding of the input and output messages for WS is defined in the binding
section
![Page 12: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/12.jpg)
WSDL DOCUMENT STRUCTURE (cont)
<wsdl:service name="FibonacciService"><wsdl:service name="FibonacciService"> <wsdl:port binding="impl:fibonacciSoapBinding" name="fibonacci"><wsdl:port binding="impl:fibonacciSoapBinding" name="fibonacci"> <wsdlsoap:address location="http://localhost:8081/axis/fibonacci"/><wsdlsoap:address location="http://localhost:8081/axis/fibonacci"/> </wsdl:port></wsdl:port> </wsdl:service></wsdl:service>
• service– Specifies methods offered by the Web service– Services are available on ports, which have specific addresses – Specify the binding, port name, and the port addresses
(endpoint) for each access method• port
– Endpoint describe network address which is consumed by WS consumer
– Support a communication between WS (application) and client – Reuse (The port is dynamically)
![Page 13: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/13.jpg)
UDDI• Is a platform-independent, XML-based registry for businesses
worldwide to list themselves on the Internet. • Provides standard mechanisms for businesses to describe and
publish their Web Services, discover published Web Services and use them.
• Contains references to specifications called as Technical Models, or tModels, which describe the working of Web Services. The tModel is built upon a programming model and schema that are platform and language independent.
• There are several steps for using the registry– The software companies populate the registry by describing various tModels
and specifications common to a business. – UDDI programmatically assigns a Unique Universal Identifier (UUID) to
each tModel and business applications query the registry to discover services of other companies and integrate this data easily with each other over the web.
– Finally, this becomes a dynamic process where search and discovery is performed automatically based on the available services.
![Page 14: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/14.jpg)
UDDI DATA STRUCTURE• Provides five core data structures that are used to represent an organization, its
services, implementation technologies, and relationships with the other businesses
bT
bS bS
bE pA
bS
bT
tModel tModel
WhitePages
YellowPages
GreenPages
businessEntity
(bE)businessServi
ce(bS)
bindingTemplate(bT) tModel
publisherAssertion(pA)
bEpA
bS bS bS
bTbT
tModel tModel
![Page 15: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/15.jpg)
UDDI PUBLISHER API• Allows to add, modify, and delete service-related data from the registry• allows organizations to save their own businessEntity, businessService,
bindingTemplate, tModel, and publisherAssertion data structures in a UDDI registry, and to remove them when necessary
Method Description
save-business Adds or updates one or more businessEntity entries
save-service Adds or updates one or more businessService entries
save-binding Adds or updates one or more bindingTemplate entries
save-tModel Adds or updates one or more tModel entries
delete-business Deletes one or more businessEntity entries
delete-service Deletes one or more businessService entries
delete-binding Deletes one or more bindingTemplate entries
delete-tModel Deletes (or hides) one or more tModel entries
get-authToken Logs you into the registry
discard-authToken Logs you out of the registry
find-related business Finds matching publisherAssertion entries
get-publisherAssertions Gets a list of publisherAssertion entries
get-assertionStatusReport Gets a summary publisherAssertion entries
![Page 16: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/16.jpg)
UDDI INQUIRY API• Is used to search and read data from a UDDI registry. • Is used to query the UDDI registry and fetch specific UDDI data structures
Methods Description
find-business Finds matching businessEntity entries
find-service Finds matching businessService entries
find-binding Finds matching bindingTemplate entries
find-tModel Finds matching tModel entries
get-businessDetail Gets businessEntity entries
get-serviceDetail Gets businessService entries
get-bindingDetail Gets bindingDetail entries
get-tModelDetail Gets tModel entries
get-registeredInfo Gets an abbreviated list of businessEntity and tModel entries
add- publisherAssertions Adds one or more publisherAssertion entries
set- publisherAssertions Updates one or more publisherAssertion etries
delete- publisherAssertions Deletes one or more publisherAssertion entries
![Page 17: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/17.jpg)
ebXML
![Page 18: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/18.jpg)
ebXML ARCHITECTURE
![Page 19: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/19.jpg)
REGISTRY & REPOSITORY• Is a superset of UDDI• The ebXML registry stores information about the service provider and
the Web Service• The ebXML repository also stores the business process documents of
the service provider• Internally, the registry is connected to the repository. • The repository stores different objects such as Core Components, Bus
Process Information Meta Models, Business Documents, Collaboration Protocols Profiles and Collaboration Protocols Agreement
• The clients communicate with the registry using the following two interfaces– Object Manager
• Provides the methods to create new objects within the registry and affect state transitions on existing objects.
• Includes different methods namely approveObjects(), deprecateObjects(), removeObjects(), submitObjects(), addSlots() and removeSlots().
– Object Query Manager• Provides the methods to find and access the objects created within the registry. • Includes different methods namely getClassficationTree(),getClassfieldObjects(),
getContent() submitAdhocQuery() and getRootClassficationnodes()
![Page 20: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/20.jpg)
BUSINESS PROCESSES• Defines a standard language to configure business systems for business
collaboration execution between collaborating parties or business partners• Is a set of individual messages exchanged among business partners. • Depicts who the trading partners are, their roles, the documents exchanged and its
structure. In other words, a Business Process defines the Business Collaboration.• The main parts of Business Collaboration:
– Business Collaboration Specification: is a set of roles interacting through a set of specialized protocol by exchanging Business Documents between business partners.
– Business Transaction: is an atomic unit of work in a trading arrangement between two business partners. A Business Transaction is conducted between two parties playing opposite roles in the transaction. The roles are always in the form of request and response.
– Business Document Flows: in Business Transaction, by default, each requesting role has one Business Document. The responding role may not have a Business Document. The Business Documents are composed from registry-usable Business Information Objects. The ebXML reuses the Business Information Objects from a Core Component Library to create the Business Documents.
– Choreography: is used to define which Business Transaction follows which Business Transaction. The realization of the choreography is done by the transition between two Business Transactions. A Binary Collaboration has several transitions and a transition has a “from” Business State and a “to” Business State.
– Patterns: are a set of defined transaction interactions. The use of predefined patterns combines the flexibility of specifying an infinitive number of specific transactions and collaborations with a consistency. This facilitates faster design, faster implementation, and enables generic processing.
![Page 21: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/21.jpg)
ebXML Collaboration Protocol Profiles and Collaboration Protocol Agreements
• The CPP is an XML document that contains information about a business and the way exchanges information with other businesses.
• The CPA is an intersection of two CPP documents.• The CPA is derived from two or more CPPs.
![Page 22: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/22.jpg)
ebXML CORE COMPONENTS & MESSAGING SERVICE • Also called Aggregated Component. • A Core Component is a reusable building block that
contains information about a business concept. For example, for a concept such as purchase order, the core components are date of purchase order, sales tax and total amount.
• The ebXML Messaging Service (ebXML MS) provides the message wx functionality within the ebXML infrastructure.
• ebXML MS is an entity used by the Business Service Interface software to send and receive XML messages from one point to another.
• ebXML MS is based on TCP/IP, FTP, HTTP and SMTP protocols. EBXML MS uses packages data in SOAP messages and transmits them using HTTP, TCP/IP, FTP or SMTP protocol.
![Page 23: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/23.jpg)
SETTING UP & CONFIGURING REGISTRY SERVER
• Tool requirement: – Tomcat 5.0 for jwsdp (java web service developer pack)– jwsdp 1.5– jdk 1.4– Netbeans IDE 5.5.1
• Step 1: – Setting up above the requirement tools– Alternative, unzip the package all in one including Tomcat 5.0,
jwsdp 1.5 and jdk 1.4• Step 2: Adding the new server for Netbeans 5.5.1• Step 3: Starting to test the server
![Page 24: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/24.jpg)
SETTING UP & CONFIGURING REGISTRY SERVER
• Step 1: Unziped the package (Drive C is recommended)
![Page 25: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/25.jpg)
SETTING UP & CONFIGURING REGISTRY SERVER
• Step 2: Adding the new server for Netbeans 5.5.1– In tab Runtime, right click on the Server, click Add Server
Choose the Tomcat 5.0
Type the Server Name
Click Next Button
![Page 26: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/26.jpg)
SETTING UP & CONFIGURING REGISTRY SERVER
• Step 2: Adding the new server for Netbeans 5.5.1 (cont)
Browse to the Tomcat 5.0 directory
Typing the username and password that can be found at the tomcat-user.xml in the conf directory
Click finish Button
![Page 27: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/27.jpg)
SETTING UP & CONFIGURING REGISTRY SERVER
• Step 2: Adding the new server for Netbeans 5.5.1 (cont)
![Page 28: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/28.jpg)
SETTING UP & CONFIGURING REGISTRY SERVER
• Step 3: Starting to test the server– Right click the name of server that is setting up, click Start
![Page 29: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/29.jpg)
STEPS TO USE REGISTRY WITH JAXR• Step 1: Creating Application to using registry with JAXR• Step 2: Create Connection Factory• Step 3: Setting the Connection attributes• Step 4: Create Connection from Connection Factory• Step 5: Create the RegistryService from Connection• Step 6: Get the LifeCycleManager or QueryManager from
RegistryService• Step 7: Configuring the Connection Authentication with username
password default (testuser – testuser)• Step 8: Determine the action (publish, query, or delete) on the registry
using JAXR API• Requirement packages
– javax.xml.registry.*;– javax.xml.registry.infomodel.*;– javax.xml.registry.infomodel.RegistryObject;
• with jar files– soap.jar, jaxr-api.jar,jaxr-impl.jar– jaxb-api.jar, jaxb-impl.jar, jaxb-libs.jar, jaxb.xjc.jar
![Page 30: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/30.jpg)
CONNECT TO REGISTRY SERVER• Create Connection FactoryConnectionFactory factory=ConnectionFactory.newInstance();• Create Connection from Connection Factory
– Using URL and registry server attributes that are accessed. Ex:connProps.setProperty("javax.xml.registry.queryManagerURL",
“http://localhost:8080/RegistryServer/”);connProps.setProperty("javax.xml.registry.lifeCycleManagerURL",
“http://localhost:8080/RegistryServer/”);connProps.setProperty("javax.xml.registry.factoryClass",
"com.sun.xml.registry.uddi.ConnectionFactoryImpl");– Create connection. Ex:
factory.setProperties(connProps);Connection conn=factory.createConnection();• Notes: In flexibility, the URLs should be put on the properties
file. Ex: the publish.properties file that is put in root application
query.url=http://localhost:8080/RegistryServer/publish.url=http://localhost:8080/RegistryServer/user.name=testuseruser.password=testuser
![Page 31: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/31.jpg)
GET REGISTRY SERVICE • Get Registry Service ObjectRegistryService rs=conn.getRegistryService();• Get Query va LifeCycle ManagerBusinessQueryManager bqm=rs.getBusinessQueryManager();BusinessLifeCycleManager blm=rs.getBusinessLifeCycleManager();• Configuring the Authentication for Connection (that
is applied with publish and delete action)PasswordAuthentication passwdAuth=new
PasswordAuthentication(username, password.toCharArray());
Set creds=new HashSet();creds.add(passwdAuth);conn.setCredentials(creds);
![Page 32: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/32.jpg)
PUBLISH REGISTRY • Create object
– Creating object using the BusinessLifeCycleManager with the createXXX methods
– Organization, createOrganization(Name) & setDescription: define Name & Description for organization
– Service, createService(String) va setDescription: define the branch or services that are provided by the organization
– PersonName & createPersonName: define Contact– The contact object includes TelephoneNumber, PostalAddress,
EmailAddress– Classification: taxonomy following the
ClassificationSchema(ordering) & Key (id)– Other information as ExternalIdentifier &
createExternalIdentifier• Save/ Store the Object into Registry
– Using the saveOrganizations(Collection) method. ExBulkResponse br=blm.saveOrganizations(orgs);if(br.getStatus()==JAXRResponse.STATUS_SUCCESS)
![Page 33: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/33.jpg)
EXAMPLE• Register the organization to
Registry Service with the following information as:– Name: ABCL New Corp (Brand
of a Celebrity)– Services: Selling a celebrity brand
(Services of a celebrity brand)– Contact: Michelle Pfeifer– Tel: 199-600-5403– Address: 14739 Highway Park
Apartments New Jersey NY USA 09140
– Email: [email protected]– Classification: ntis-gov:naics– Key:uuid:C0B9FE13-179F-413D-
8A5B-5004DB8E5BB2– ...
![Page 34: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/34.jpg)
EXAMPLE (cont)• publish.properties
query.url=http://localhost:8080/RegistryServer/
publish.url=http://localhost:8080/RegistryServer/
user.name=testuser
user.password=testuser
#if you are behind a firewall this needs to be configured
http.proxy.host=
http.proxy.port=
![Page 35: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/35.jpg)
EXAMPLE (cont)• Publish.javapublic class Publishing { String username="testuser"; String password="testuser"; String regUrli=""; String regUrlp=""; Properties connProps=new Properties(); private static final String USER_NAME="user.name"; private static final String USER_PASSWORD="user.password"; private static final String PROXY_HOST="http.proxy.host"; private static final String PROXY_PORT="http.proxy.port";public void assignUserProperties(Properties props){ String queryURL=((String)props.get("query.url")).trim(); String publishURL=((String)props.get("publish.url")).trim(); String user=((String)props.get(USER_NAME)).trim(); String pw=((String)props.get(USER_PASSWORD)).trim(); if(queryURL!=null) regUrli=queryURL; if(publishURL!=null) regUrlp=publishURL; if(user!=null) username=user; if(pw!=null) password=pw;}
public void setConnectionProperties(){ connProps.setProperty("javax.xml.registry.queryManagerURL", regUrli); connProps.setProperty("javax.xml.registry.lifeCycleManagerURL", regUrlp); connProps.setProperty("javax.xml.registry.factoryClass", "com.sun.xml.registry.uddi.ConnectionFactoryImpl"); }
![Page 36: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/36.jpg)
EXAMPLE (cont)• Publish.java
public void executeTest(Properties properties)throws JAXRException{ try{ assignUserProperties(properties); setConnectionProperties(); ConnectionFactory factory=ConnectionFactory.newInstance(); factory.setProperties(connProps); Connection conn=factory.createConnection(); RegistryService rs=conn.getRegistryService(); BusinessQueryManager bqm=rs.getBusinessQueryManager(); BusinessLifeCycleManager blm=rs.getBusinessLifeCycleManager(); PasswordAuthentication passwdAuth=new PasswordAuthentication(username, password.toCharArray());
Set creds=new HashSet(); creds.add(passwdAuth); conn.setCredentials(creds); Collection orgs=new ArrayList(); Organization org=blm.createOrganization(blm.createInternationalString("ABCL New Corp")); org.setDescription(blm.createInternationalString("Brand of a Celebrity")); Service service=blm.createService(blm.createInternationalString("Selling a celebrity brand")); service.setDescription(blm.createInternationalString("Services of a celebrity brand")); User user=blm.createUser(); PersonName personName=blm.createPersonName("Michelle Pfeifer"); org.setPrimaryContact(user); TelephoneNumber telephoneNumber=blm.createTelephoneNumber(); telephoneNumber.setNumber("199-600-5403"); telephoneNumber.setType(null); PostalAddress address=blm.createPostalAddress("14739", "Highway Park Apartments", "New Jersey", "NJ", "USA", "09140", ""); Collection postalAddress=new ArrayList(); postalAddress.add(address); Collection emailAddresses=new ArrayList(); EmailAddress emailAddress=blm.createEmailAddress("[email protected]"); emailAddresses.add(emailAddress);
![Page 37: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/37.jpg)
EXAMPLE (cont)• Publish.java Collection numbers=new ArrayList(); numbers.add(telephoneNumber); user.setPersonName(personName); user.setPostalAddresses(postalAddress); user.setEmailAddresses(emailAddresses); user.setTelephoneNumbers(numbers); ClassificationScheme cScheme=blm.createClassificationScheme(blm.createInternationalString("ntis-gov:naics"), blm.createInternationalString("")); Key cKey=(Key)blm.createKey("uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"); cScheme.setKey(cKey); Classification classification=(Classification)blm.createClassification(cScheme, "System Related Services", "15000"); org.addClassification(classification); ClassificationScheme cScheme1=blm.createClassificationScheme(blm.createInternationalString("D-U-N-S"),
blm.createInternationalString("")); Key cKey1=(Key)blm.createKey("uuid:8609C81E-EE1F-4D5A-B202-3EB13AD01823"); cScheme1.setKey(cKey1); ExternalIdentifier ei=blm.createExternalIdentifier(cScheme1, "D-U-N-S number", "08-146-6849"); org.addExternalIdentifier(ei); org.addService(service); orgs.add(org); BulkResponse br=blm.saveOrganizations(orgs); if(br.getStatus()==JAXRResponse.STATUS_SUCCESS){ System.out.println ("Published and saved the organization details");} else{ System.err.println("One or more JAXRExceptions occured during the save operation: "); Collection exceptions=br.getExceptions(); Iterator iter=exceptions.iterator(); while(iter.hasNext()){ Exception e=(Exception)iter.next(); System.err.println(e.toString());}}} catch(JAXRException e){e.printStackTrace();} }
![Page 38: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/38.jpg)
EXAMPLE (cont)• Publish.java public static void main (String[] args) { try{ System.out.println ("main start"); Publishing bqt=new Publishing(); Properties properties=new Properties(); properties.load(new FileInputStream("publish.properties")); System.out.println ("have file"); bqt.executeTest(properties); System.out.println ("Finish"); }catch (JAXRException e){ System.out.println ("Failed " + e.getMessage()); }catch(IOException e){System.out.println ("Unable toopen properties file"); } }}
![Page 39: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/39.jpg)
QUERY• Some attributes: Collection findQualifiers,
Collection namePattern, Collection classifications, Collection specifications, Collection externalIdentifiers, Collection externalLinks
• Query by Name: – Assign to findQualifiers to define the finding and
sorting way (Ex: FindQualifier.SORT_BY_NAME_ASC or FindQualifier.CASE_SENSITIVE_MATCH)
– namePattern: finding with % character – Get return values
BulkResponse br=bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null);
if(br.getStatus()==JAXRResponse.STATUS_SUCCESS)
![Page 40: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/40.jpg)
EXAMPLE • Setting the JAXR Client to get Registry Services, get
BusinessLifeCycleManager Collection findQualifiers=new ArrayList();findQualifiers.add(FindQualifier.CASE_SENSITIVE_MATCH);findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
Collection namePatterns=new ArrayList();namePatterns.add("%"+sName+"%");
BulkResponse br=bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null);if(br.getStatus()==JAXRResponse.STATUS_SUCCESS){
Collection org=br.getCollection();Iterator iter=org.iterator();while(iter.hasNext()){
Organization o=(Organization)iter.next(); //tham sô truyên RegistryObjectSystem.out.println ("Name: " + getName(o));System.out.println ("Description: " + getDescription(o)); System.out.println ("Key: " + getKey(o));}}
else{
System.out.println ("Not found");}
![Page 41: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/41.jpg)
EXAMPLE (cont)public static void main (String[] args) { String sname="ABCL New Corp"; System.out.println ("main start"); try{ queryByName qBN=new queryByName(); Properties properties=new Properties(); properties.load(new FileInputStream("publish.properties")); System.out.println ("have file"); qBN.jaxrQueryByName(properties, sname); System.out.println ("finish"); }catch (JAXRException e){ System.out.println ("Failed " + e.getMessage()); }catch(IOException e){ System.out.println ("Unable toopen properties file");}}
![Page 42: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/42.jpg)
QUERY (cont) • Query by Classification:
– Define Classification schemaClassificationScheme
cScheme=bqm.findClassificationSchemeByName(null, "ntis-gov:naics");– Define classification content that is found
Classification classification=blm.createClassification(cScheme, "System Related Services", "15000");
Collection classifications=new ArrayList();classifications.add(classification);
– Get return value BulkResponse br=bqm.findOrganizations(null, null, classifications,
null, null, null);if(br.getStatus()==JAXRResponse.STATUS_SUCCESS)
• Query by argument service: studying in jwsdp document on Sun
![Page 43: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/43.jpg)
EXAMPLE • Setting JAXR Client to get Registry Services, get
BusinessLifeCycleManager ClassificationScheme cScheme=bqm.findClassificationSchemeByName(null, "ntis-
gov:naics");
Classification classification=blm.createClassification(cScheme, "System Related Services", "15000");
Collection classifications=new ArrayList();classifications.add(classification);
BulkResponse br=bqm.findOrganizations(null, null, classifications, null, null, null);if(br.getStatus()==JAXRResponse.STATUS_SUCCESS){
Collection org=br.getCollection();Iterator iter=org.iterator();while(iter.hasNext()){
Organization o=(Organization)iter.next(); //tham sô truyên RegistryObjectSystem.out.println ("Name: " + getName(o));System.out.println ("Description: " + getDescription(o)); System.out.println ("Key: " + getKey(o));}}
else{
System.out.println ("Not found");}
![Page 44: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/44.jpg)
EXAMPLE (cont) public static void main (String[] args) { String sname="ntis-gov:naics"; System.out.println ("main start"); try{ queryByClassification qBN=new queryByClassification(); Properties properties=new Properties(); properties.load(new FileInputStream("publish.properties")); System.out.println ("have file"); qBN.jaxrQueryByClassification (properties, sname); System.out.println ("finish"); }catch (JAXRException e){ System.out.println ("Failed " + e.getMessage()); }catch(IOException e){ System.out.println ("Unable toopen properties file");}}
![Page 45: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/45.jpg)
REMOVE REGISTRY • Using deleteObject(Collection) method
of (Business)LifeCycleManager object with id registry.
• The authentication is requirement
![Page 46: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/46.jpg)
EXAMPLE • Configuring JAXR Client to get Registry Services, get
BusinessLifeCycleManager and authenticationKey orgKey=blm.createKey(key);Collection keys=new ArrayList();keys.add(orgKey);
BulkResponse br=blm.deleteOrganizations(keys);if(br.getStatus()==JAXRResponse.STATUS_SUCCESS){
Collection org=br.getCollection();Iterator iter=org.iterator();while(iter.hasNext()){
Organization o=(Organization)iter.next(); System.out.println ("Name: " + getName(o));System.out.println ("Description: " + getDescription(o)); System.out.println ("Key: " + getKey(o));}}
else{
System.out.println ("Not found");}
![Page 47: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/47.jpg)
EXAMPLE (cont) public static void main (String[] args) { String skey="121b5064-5b71-21b5-3f48-9eb3dfd16b24"; System.out.println ("main start"); try{ Deleting dr=new Deleting(); Properties properties=new Properties(); properties.load(new FileInputStream("publish.properties")); System.out.println ("have file"); dr.jaxrDelete(properties, skey); System.out.println ("Finish"); }catch (JAXRException e){ System.out.println ("Failed " + e.getMessage()); }catch(IOException e){ System.out.println ("Unable toopen properties file");} }
![Page 48: DEVELOPING WEB SERVICES WITH JAVA WSDL & SERVICE REGISTRY.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649e365503460f94b25564/html5/thumbnails/48.jpg)
EXERCISES• Do it yourself all the demo again