Working with UDDI
Publish in a UDDI Registry
In this example, you will see how to publish a WSDL into the UDDI registry bundled
with JBossAS. The simple wsdl publisher follows the UDDI.org technical
note you can find here with
some simplifications (see javadocs).
There are two different versions of this example.
The first version Uddiv2JaxrTechnotev2.zip is for JBossAS-4.0.3RC2+ and uses: -
JAXR to talk to the registry.
JWSDP1.5 to build the example web service
The UDDI v2 jUDDI service you will find in all/juddi-service.sar and you can copy into the default configuration
JBossAS-4.0.3RC2+
The second version Uddiv2JaxrTechnotev2JBoss4_0_5_GA.zip has been updated for JBoss 4.0.5.GA, this no longer uses JWSDP and instead uses the new JBossWS stack including the tools provided with JBossWS. This version still uses: -
JAXR to talk to the registry.
The UDDI v2 jUDDI service you will find in all/juddi-service.sar and you can copy into the default configuration
The instructions to run both versions of the example are the same.
Description
A simple web service is deployed twice. One with the example.war webapp, the second with the example2.war webapp that is the
same war file renamed. Thus, we obtain two endpoints for the web service.
The web service is a simple multiplyByTwo method:
public int multiplyByTwo(int in_value) throws RemoteException { return 2 * in_value; }
A simple publisher uses these WSDLs and several other parameters (UDDI URLs, login & password, business entity name) to publish the service
into the UDDI registry. This leads to have a single business service with two binding templates representing each endpoints. Look at this
simple publisher to have examples of JAXR requests.
Then a simple java client will invoke all the endpoints retrieved from the registry.
To go further, you can imagine to add your own categories to your services to allow more complex queries related to your own use cases.
First, add the new canonical tModels
The technical note defines some new tModels you must add into the UDDI registry.
You will find a canonicalTModels.ddl file into the example's root directory, containing SQL statements for this purpose.
You can add these statements to the juddi-service.sar/META-INF/ddl/juddi_data.ddl file and modify the
juddi-service.sar/META-INF/jboss-service.xml file to change the CreateOnStart attribute:
<attribute name="CreateOnStart">true</attribute>.
Now you can start your JBossAS.
Set up the properties
In the example's root directory, an example.properties file contains some properties you must set to fit your environment:
# -- the jboss home directory jboss.home=/your/jboss/home_directory # -- the jboss configuration jboss.conf=myUDDIConf # -- the tools.jar directory (used for the wscompile task) - This is not required for the JBoss 4.0.5.GA version of the example. java.tools.dir=/your/jdk/lib # -- no change hereafter uddi.publishURL=http://localhost:8080/juddi/publish uddi.inquiryURL=http://localhost:8080/juddi/inquiry uddi.userid=jboss uddi.password=null uddi.businessEntityName=JBoss ws.wsdlURL=http://localhost:8080/example/ExampleService?wsdl ws.wsdlURL2=http://localhost:8080/example2/ExampleService?wsdl
Modify for JBossAS 4.2
Build File
Add juddi-saaj.jar to the classpaths at lines 49 and 191 in the build.xml file
<fileset dir="${jboss.home}/server/${jboss.conf}/deploy/juddi-service.sar"> <include name="juddi.jar" ></include> <include name="juddi-saaj.jar" ></include> </fileset>
A ClassNotFoundException will result when the publisher-run target is executed if this change is not made.
Source Code
If using JBossAS 4.2, modify the import statement in Client.java from:
import org.jboss.ws.jaxrpc.ServiceFactoryImpl;
to:
import org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl;
A ClassCastException will result when the client-run target is executed if this change is not made.
Then you can use the Ant tasks
all-run : is doing all the work.
builds the web service
deploys it twice (2 endpoints by deploying the same webapp with 2 different names)
publishes the two WSDLs; leading to the same web service with two access points
runs the client that invokes the web service for each endpoint found in the registry
Results
The published wsdls
+Note: this view was from the UDDI4J version of this example I ran against the jboss-4.0.2 release. An exception from the UDDI Browser with the 4.0.3RC2 release
didn't allow me to produce this view. I don't have investigated yet to know where the problem is.+
The Simple Publisher trace
publisher-run: [echo] Publish the example ExampleService [java] - pulishing : [java] uddi inquiry URL = http://localhost:8080/juddi/inquiry [java] uddi publish URL = http://localhost:8080/juddi/publish [java] uddi user id = jboss [java] uddi password = [java] wsdl URL = http://localhost:8080/example/ExampleService?wsdl [java] business entity = JBoss [java] ... [java] - Using the Context ClassLoader [java] - creating Business Entity name = JBoss ... [java] - No Business Entity "JBoss" found. Will be created. [java] ?Org has services=true [java] ?Org has users=true [java] Method:save_business: ENlength=1 [java] After Saving Business. Obtained vector size:1 [java] - Business Entity "JBoss" created. Key = A1A455A0-2EB9-11DA-B320-B743697D74B5". [java] - creating Business Service ... [java] - No Business Service "ExampleService" found. Will be created. [java] BusinessService=org.apache.juddi.datatype.service.BusinessService@1d47b2b [java] - Business Service created. Key = A1DE5160-2EB9-11DA-B320-B2A6C795368B". [java] - Port Type ... [java] - No PortType "ExampleService" found. Will be created. [java] Method:save_concept: ENlength=1 [java] After Saving TModel. Obtained vector size:1 [java] - Port Type created. Key = uuid:A207AB50-2EB9-11DA-B320-EA0A9F4BD0F4". [java] - creating Binding with portType key = uuid:A207AB50-2EB9-11DA-B320-EA0A9F4BD0F4 ... [java] - No Binding "ExampleServiceBinding" found. Will be created. [java] Method:save_concept: ENlength=1 [java] After Saving TModel. Obtained vector size:1 [java] - Binding created. Key = uuid:A2201550-2EB9-11DA-B320-AC5596357A3A". [java] - creating Binding Template ... [java] - No Service Binding for access point "http://localhost:8080/example/ExampleService" found. Will be created. [java] BindingTemplate=org.apache.juddi.datatype.binding.BindingTemplate@1397e5c [java] - Service Binding for access point "http://localhost:8080/example/ExampleService" created. Key = A2496F40-2EB9-11DA-B320-B2BC74D16111". [java] Done. [echo] Publish the example2 ExampleService [java] - pulishing : [java] uddi inquiry URL = http://localhost:8080/juddi/inquiry [java] uddi publish URL = http://localhost:8080/juddi/publish [java] uddi user id = jboss [java] uddi password = [java] wsdl URL = http://localhost:8080/example2/ExampleService?wsdl [java] business entity = JBoss [java] ... [java] - Using the Context ClassLoader [java] - creating Business Entity name = JBoss ... [java] - Business Entity already exists. Key = A1A455A0-2EB9-11DA-B320-B743697D74B5". [java] - creating Business Service ... [java] - Business Service already exists. Key = A1DE5160-2EB9-11DA-B320-B2A6C795368B". [java] - Port Type ... [java] - Port Type already exists. Key = uuid:A207AB50-2EB9-11DA-B320-EA0A9F4BD0F4". [java] - creating Binding with portType key = uuid:A207AB50-2EB9-11DA-B320-EA0A9F4BD0F4 ... [java] - Binding already exists. Key = uuid:A2201550-2EB9-11DA-B320-AC5596357A3A". [java] - creating Binding Template ... [java] - No Service Binding for access point "http://localhost:8080/example2/ExampleService" found. Will be created. [java] BindingTemplate=org.apache.juddi.datatype.binding.BindingTemplate@20f237 [java] - Service Binding for access point "http://localhost:8080/example2/ExampleService" created. Key = A4665BD0-2EB9-11DA-B320-D89FAA745769". [java] Done.
The Client trace
client-run: [java] - Using the Context ClassLoader [java] access "http://localhost:8080/example2/ExampleService" multiply 100 by 2 = 200 [java] access "http://localhost:8080/example/ExampleService" multiply 100 by 2 = 200
The example application
Uddiv2JaxrTechnotev2JBoss4_0_5_GA.zip
Comments