In the first article in this series (see Resources for links to Parts 1, 2, and 3), you learned about a new approach to constructing a UDDI model of a WSDL description. The second article described the types of UDDI query this new approach enables, with examples of several queries given in the form of UDDI V2 API requests. The third presented a more complex example than the one in the Technical Note, including screenshots showing you how to publish the UDDI entities and how to construct the types of query described in the Technical Note and in Part 2.
In this fourth article, you'll see some sample Java code that will publish WSDL descriptions to UDDI programmatically. The fifth article in the series will describe how to write a Java application that can issue the queries described in the other articles in this series, using UDDI4J.
The UDDI registry used in this example is an instance of the UDDI implementation that is shipped with IBM® WebSphere® Application Server Network Deployment V5.1.
I added the tModels required by the new Technical Note to the registry, along with the tModel required by WS-I.
These tModels are added using the UDDI Utility Tools that are new in Application Server V5.1.
The definitions of the Technical Note tModels are shown in Listing 1 in this sidefile.
There are a couple of differences between the definitions in Listing 1 and the definitions given in the Technical Note:
- I removed the checked categorization, as the UDDI registry in WebSphere Application Server V5.1 has not been updated to check these category systems in the special way that they require.
- I added the IBM-specific
keyedReferencesnecessary to use the custom taxonomy support for the WSDL entity types taxonomy.
The definition of the WS-I tModel is illustrated in Listing 2.
Listing 2. Definition of the WS-I tModel
<promote:uddiEntities xmlns="urn:uddi-org:api_v2" xmlns:promote=
"urn:com.ibm.uddi:uddiPromote">
<promote:tModels>
<tModel tModelKey="uuid:65719168-72c6-3f29-8c20-62defb0961c0">
<name>ws-i-org:conformsTo:2002_12</name>
<description xml:lang="EN">Category system used for UDDI entities
to point to the WS-I concept to which they conform.</description>
<overviewDoc>
<overviewURL>http://ws-i.org/schemas/conformanceClaim/</overviewURL>
</overviewDoc>
<categoryBag>
<keyedReference tModelKey=
"uuid:c1acf26d-9672-4404-9d70-39b756e62ab4" keyValue=
"categorization"/>
<keyedReference keyName=
"urn:x-ibm:uddi:customTaxonomy:key" keyValue=
"wsiconfm"/>
<keyedReference keyName=
"urn:x-ibm:uddi:customTaxonomy:displayName" keyValue=
"WS-I Conformance"/>
</categoryBag>
</tModel>
</promote:tModels>
</promote:uddiEntities>
|
I also added a custom taxonomy for the WSDL entity type category system so that the WSDL entity type can be chosen from the category tree view. Listing 3 illustrates the data for this taxonomy.
Listing 3. Definition of the WSDL entity type taxonomy
wsdltype#root#WSDL Entity Types#root wsdltype#portType#WSDL portType#root wsdltype#binding#WSDL binding#root wsdltype#service#WSDL service#root wsdltype#port#WSDL port#root |
Finally, I added a custom taxonomy for the WS-I conformance taxonomy. Listing 4 illustrates the data for this taxonomy. Note that because taxonomy values are limited to 32 characters, it is not possible to include the entire string defined by the WS-I Basic Profile, as that string is 34 characters long. The remaining 2 characters have to be supplied manually after the value has been chosen.
Listing 4. Definition of the WS-I conformance taxonomy
wsiconfm#root#WS-I Conformance#root wsiconfm#http://ws-i.org/profiles/basic/1#WS-I_conformance:BasicProfile1.0#root |
The API presented here is at a fairly low level of abstraction. For example, the caller must be aware that a portType is mapped
to a tModel, and must know the various keys.
A higher-level API that reads a WSDL file and automatically publishes the UDDI model corresponding to it could be built on top of this API, but discussion of such an API is beyond the scope of this article.
The API is structured as a single Java class that is a wrapper around an instance of the UDDI4J UDDIProxy class.
An instance of the Publish class is constructed from an instance of the UDDIProxy class and the appropriate authInfo value to use for publishing.
The Publish class provides methods to publish each of the entities used in the WSDL Technical Note.
There are two methods for each type of entity. The first takes as parameters only the information required by the WSDL Technical Note.
The second takes, in addition, an instance of the corresponding UDDI4J type; this instance can be used to pass in additional information. For example, in the case of the publish_binding_tModel() method, the extra parameter tModel is used to pass any additional information that should be added to the binding tModel that is published.
In the sample, this is used to pass in the WS-I conformance information by passing in a tModel that contains a categoryBag, which in turn contains the WS-I keyedReference.
As already mentioned, the API is a single Java class; its fully-qualified name is uddi.wsdl.v2.publish.Publish, and it has a constructor and eight methods.
The class and the constructor are shown in Listing 5.
Listing 5. Definition of the Publish class and its constructor
package uddi.wsdl.v2.publish;
import java.util.Vector;
import org.uddi4j.UDDIException;
import org.uddi4j.client.UDDIProxy;
import org.uddi4j.datatype.Name;
import org.uddi4j.datatype.OverviewDoc;
import org.uddi4j.datatype.binding.AccessPoint;
import org.uddi4j.datatype.binding.BindingTemplate;
import org.uddi4j.datatype.binding.BindingTemplates;
import org.uddi4j.datatype.binding.InstanceDetails;
import org.uddi4j.datatype.binding.InstanceParms;
import org.uddi4j.datatype.binding.TModelInstanceDetails;
import org.uddi4j.datatype.binding.TModelInstanceInfo;
import org.uddi4j.datatype.service.BusinessService;
import org.uddi4j.datatype.tmodel.TModel;
import org.uddi4j.response.BindingDetail;
import org.uddi4j.response.ServiceDetail;
import org.uddi4j.response.TModelDetail;
import org.uddi4j.transport.TransportException;
import org.uddi4j.util.CategoryBag;
import org.uddi4j.util.KeyedReference;
public class Publish
{
private final static String WSDL_ENTITY_TYPE_TMODELKEY =
"uuid:6e090afa-33e5-36eb-81b7-1ca18373f457";
private final static String WSDL_ENTITY_TYPE_KEYNAME =
"WSDL entity type";
private final static String XML_NAMESPACE_TMODELKEY =
"uuid:d01987d1-ab2e-3013-9be2-2a66eb99d824";
private final static String XML_NAMESPACE_KEYNAME =
"XML namespace";
private final static String WSDL_PORTTYPE_REFERENCE_TMODELKEY =
"uuid:082b0851-25d8-303c-b332-f24a6d53e38e";
private final static String WSDL_PORTTYPE_REFERENCE_KEYNAME =
"WSDL portType reference";
private final static String UDDI_TYPES_TMODELKEY =
"uuid:c1acf26d-9672-4404-9d70-39b756e62ab4";
private final static String UDDI_TYPES_KEYNAME =
"uddi-org:types";
private final static String PROTOCOL_CATEGORIZATION_TMODELKEY =
"uuid:4dc74177-7806-34d9-aecd-33c57dc3a865";
private final static String PROTOCOL_CATEGORIZATION_KEYNAME =
"protocol";
private final static String TRANSPORT_CATEGORIZATION_TMODELKEY =
"uuid:e5c43936-86e4-37bf-8196-1d04b35c0099";
private final static String TRANSPORT_CATEGORIZATION_KEYNAME =
"transport";
private final static String XML_LOCAL_NAME_TMODELKEY =
"uuid:2ec65201-9109-3919-9bec-c9dbefcaccf6";
private final static String XML_LOCAL_NAME_KEYNAME =
"XML local name";
private String authInfo;
private UDDIProxy proxy;
public Publish(UDDIProxy proxy, String authInfo)
{
this.proxy = proxy;
this.authInfo = authInfo;
}
}
|
The first parameter is an instance of a UDDI4J proxy, which is assumed to be configured with the appropriate URLs and so on. The second parameter is the authInfo string to be used when making UDDI4J calls to publish to the UDDI registry.
The class's eight methods are made up of four pairs of methods, one pair for each of the different UDDI entities that can be published:
publish_portType_tModel()publish_binding_tModel()publish_service()publish_bindingTemplate()
As mentioned above, the difference between the methods of each pair is that one method takes an instance of the appropriate UDDI4J type as an extra parameter. The method that does not take the extra parameter creates a new instance of the appropriate type and then calls the method that does take the extra parameter. The method that takes the extra parameter then generally adds the information required by the WSDL Technical Note to the instance passed in and publishes the instance to the UDDI registry represented by the UDDI4J proxy. The following sections detail each of these pairs of methods.
The publish_portType_tModel() method that takes the extra parameter is shown in Listing 6.
Listing 6. Signature of the publish_portType_tModel() method with the extra parameter
public TModelDetail publish_portType_tModel(
TModel tModel,
String namespaceName,
String portTypeName,
String url)
throws UDDIException, TransportException
{
// Overwrite any supplied name.
tModel.setName(portTypeName);
// Overwrite any supplied overviewDoc.
OverviewDoc overviewDoc = new OverviewDoc();
overviewDoc.setOverviewURL(url);
tModel.setOverviewDoc(overviewDoc);
// Add keyedReferences required by Technical Note.
CategoryBag categoryBag = tModel.getCategoryBag();
if (categoryBag == null)
{
categoryBag = new CategoryBag();
tModel.setCategoryBag(categoryBag);
}
KeyedReference wsdlEntityTypeKR =
new KeyedReference(
WSDL_ENTITY_TYPE_KEYNAME,
"portType",
WSDL_ENTITY_TYPE_TMODELKEY);
categoryBag.add(wsdlEntityTypeKR);
KeyedReference xmlNamespaceKR =
new KeyedReference(
XML_NAMESPACE_KEYNAME,
namespaceName,
XML_NAMESPACE_TMODELKEY);
categoryBag.add(xmlNamespaceKR);
Vector tModels = new Vector();
tModels.add(tModel);
TModelDetail tModelDetail = proxy.save_tModel(authInfo, tModels);
return tModelDetail;
}
|
The publish_portType_tModel() method does the following:
- Sets the
tModelname to be the value of theportTypeNameparameter, overwriting any name supplied as part of thetModelparameter. - Replaces any supplied
overviewDocwith a newoverviewDocthat has anoverviewURLof the value of theuriparameter. - Creates a
categoryBagif one was not supplied in thetModelparameter and adds twokeyedReferences to it: one for the WSDL entity type taxonomy and one for the XML namespace taxonomy, using the value of thenamespaceNameparameter as the namespace name.
The publish_portType_tModel() method that does not take an extra parameter is shown in Listing 7.
Listing 7. publish_portType_tModel() method without an extra argument
public TModelDetail publish_portType_tModel(
String namespaceName,
String portTypeName,
String url)
throws UDDIException, TransportException
{
TModel tModel = new TModel();
tModel.setTModelKey("");
return publish_portType_tModel(tModel, namespaceName, portTypeName, url);
}
|
The version of this method that takes an additional parameter is shown in Listing 8.
Listing 8. Method to publish a binding tModel, with additional information
public TModelDetail publish_binding_tModel(
TModel tModel,
String namespaceName,
String bindingName,
String url,
String portTypeTModelKey,
String protocolTModelKey,
String transportTModelKey)
throws UDDIException, TransportException
{
// Overwrite any supplied name.
tModel.setName(bindingName);
// Overwrite any supplied overviewDoc.
OverviewDoc overviewDoc = new OverviewDoc();
overviewDoc.setOverviewURL(url);
tModel.setOverviewDoc(overviewDoc);
// Add keyedReferences required by Technical Note.
CategoryBag categoryBag = tModel.getCategoryBag();
if (categoryBag == null)
{
categoryBag = new CategoryBag();
tModel.setCategoryBag(categoryBag);
}
KeyedReference wsdlEntityTypeKR =
new KeyedReference(
WSDL_ENTITY_TYPE_KEYNAME,
"binding",
WSDL_ENTITY_TYPE_TMODELKEY);
categoryBag.add(wsdlEntityTypeKR);
KeyedReference xmlNamespaceKR =
new KeyedReference(
XML_NAMESPACE_KEYNAME,
namespaceName,
XML_NAMESPACE_TMODELKEY);
categoryBag.add(xmlNamespaceKR);
KeyedReference wsdlPortTypeReferenceKR =
new KeyedReference(
WSDL_PORTTYPE_REFERENCE_KEYNAME,
portTypeTModelKey,
WSDL_PORTTYPE_REFERENCE_TMODELKEY);
categoryBag.add(wsdlPortTypeReferenceKR);
KeyedReference wsdlSpecKR =
new KeyedReference(
UDDI_TYPES_KEYNAME,
"wsdlSpec",
UDDI_TYPES_TMODELKEY);
categoryBag.add(wsdlSpecKR);
KeyedReference protocolKR =
new KeyedReference(
PROTOCOL_CATEGORIZATION_KEYNAME,
protocolTModelKey,
PROTOCOL_CATEGORIZATION_TMODELKEY);
categoryBag.add(protocolKR);
if (transportTModelKey != null)
{
KeyedReference transportKR =
new KeyedReference(
TRANSPORT_CATEGORIZATION_KEYNAME,
transportTModelKey,
TRANSPORT_CATEGORIZATION_TMODELKEY);
categoryBag.add(transportKR);
}
Vector tModels = new Vector();
tModels.add(tModel);
TModelDetail tModelDetail = proxy.save_tModel(authInfo, tModels);
return tModelDetail;
}
|
The publish_binding_tModel() method does the following:
- Sets the
tModelname to be the value of thebindingNameparameter, overwriting any name supplied as part of thetModelparameter. - Replaces any supplied
overviewDocwith a newoverviewDocthat has anoverviewURLof the value of theuriparameter. - Creates a
categoryBagif one was not supplied in thetModelparameter and adds the appropriatekeyedReferences to it. The WSDL entity typekeyedReferencehas a value ofbinding. The XML namespacekeyedReferencehas a value that is the value of thenamespaceNameparameter. TheportTypereferencekeyedReferencehas a value that is the value of theportTypeTModelKeyparameter. ThetModelis categorized with the valuewsdlSpec. The protocol categorizationkeyedReferencehas a value that is the value of theprotocolTModelKeyparameter. If the value of thetransportTModelKeyparameter is not null, then a transport categorizationkeyedReferenceis added; its value is the value of thetransportTModelKeyparameter.
The version of the method to publish a binding tModel that takes as parameters only the information required by the Technical Note is shown in Listing 9.
Listing 9. Method to publish a binding tModel, without any additional information
public TModelDetail publish_binding_tModel(
String namespaceName,
String bindingName,
String url,
String portTypeTModelKey,
String protocolTModelKey,
String transportTModelKey)
throws UDDIException, TransportException
{
TModel tModel = new TModel();
tModel.setTModelKey("");
return publish_binding_tModel(tModel, namespaceName, bindingName,
url, portTypeTModelKey, protocolTModelKey, transportTModelKey);
}
|
The publish_service() method that takes the extra parameter is shown in Listing 10.
Listing 10. publish_service() method with extra parameter
public ServiceDetail publish_service(
BusinessService service,
String namespaceName,
String serviceName)
throws UDDIException, TransportException
{
// Add name only if the user has not supplied one.
Name defaultName = service.getDefaultName();
if (defaultName == null)
{
defaultName = new Name(serviceName);
service.setDefaultName(defaultName);
}
// Add keyedReferences required by Technical Note.
CategoryBag categoryBag = service.getCategoryBag();
if (categoryBag == null)
{
categoryBag = new CategoryBag();
service.setCategoryBag(categoryBag);
}
KeyedReference wsdlEntityTypeKR =
new KeyedReference(
WSDL_ENTITY_TYPE_KEYNAME,
"service",
WSDL_ENTITY_TYPE_TMODELKEY);
categoryBag.add(wsdlEntityTypeKR);
KeyedReference xmlNamespaceKR =
new KeyedReference(
XML_NAMESPACE_KEYNAME,
namespaceName,
XML_NAMESPACE_TMODELKEY);
categoryBag.add(xmlNamespaceKR);
KeyedReference xmlLocalNameKR =
new KeyedReference(
XML_LOCAL_NAME_KEYNAME,
serviceName,
XML_LOCAL_NAME_TMODELKEY);
categoryBag.add(xmlLocalNameKR);
Vector services = new Vector();
services.add(service);
ServiceDetail serviceDetail = proxy.save_service(authInfo, services);
return serviceDetail;
}
|
The publish_service() method does the following:
- Sets the
businessServicename to the value of theserviceNameparameter if the service does not already have a default name. TheserviceNameparameter is the name of the WSDL service; this should only be used as the name of the UDDIbusinessServiceif thebusinessServicedoes not already have a name. - Creates a
categoryBag, if one was not supplied in the service parameter, and adds threekeyedReferences to it: one for the WSDL entity type taxonomy, with a value ofservice; one for the XML namespace taxonomy, using the value of thenamespaceNameparameter as the namespace name; and one for the XML local name taxonomy, using the value of theserviceNameparameter as the local name, regardless of whether or not thebusinessServicename was supplied.
The version of the method to publish a service that takes as parameters only the information required by the Technical Note is shown in Listing 11.
Listing 11. Method to publish a service, without any additional information
public ServiceDetail publish_service(
String businessKey,
String namespaceName,
String serviceName)
throws UDDIException, TransportException
{
BusinessService service = new BusinessService();
service.setBusinessKey(businessKey);
service.setServiceKey("");
BindingTemplates bindingTemplates = new BindingTemplates();
service.setBindingTemplates(bindingTemplates);
return publish_service(service, namespaceName, serviceName);
}
|
The publish_bindingTemplate() method that takes the extra parameter is shown in Listing 12.
Listing 12. publish_bindingTemplate() method with an extra parameter
public BindingDetail publish_bindingTemplate(
BindingTemplate bindingTemplate,
String endpoint,
String urlType,
String portName,
String bindingTModelKey,
String portTypeTModelKey)
throws UDDIException, TransportException
{
AccessPoint accessPoint = new AccessPoint(endpoint, urlType);
bindingTemplate.setAccessPoint(accessPoint);
TModelInstanceDetails tmid = new TModelInstanceDetails();
InstanceParms ip = new InstanceParms(portName);
InstanceDetails id = new InstanceDetails();
id.setInstanceParms(ip);
TModelInstanceInfo bindingTMII =
new TModelInstanceInfo(bindingTModelKey);
bindingTMII.setInstanceDetails(id);
tmid.add(bindingTMII);
TModelInstanceInfo portTypeTMII =
new TModelInstanceInfo(portTypeTModelKey);
tmid.add(portTypeTMII);
bindingTemplate.setTModelInstanceDetails(tmid);
Vector bindingTemplates = new Vector();
bindingTemplates.add(bindingTemplate);
BindingDetail bindingDetail =
proxy.save_binding(authInfo, bindingTemplates);
return bindingDetail;
}
|
The publish_bindingTemplate() method does the following:
- Creates an
AccessPointbased on theendpointandurlTypeparameters and sets it as theaccessPointof the suppliedbindingTemplate. - Creates a new instance of
tModelInstanceDetailsand sets it as thetModelInstanceDetailsof thebindingTemplate. - Creates an instance of
InstanceDetailsand sets the value of theportNameparameter as theInstanceParmsof theInstanceDetails. - Creates an instance of
TModelInstanceInfousing thebindingTModelKeyparameter value and sets theinstanceDetailsproperty to that created in the previous step. This instance ofTModelInstanceInfois added to theTModelInstanceDetails. - Creates an instance of
TModelInstanceInfousing theportTypeTModelKeyparameter value and adds it to theTModelInstanceDetails.
The version of the method to publish a bindingTemplate that takes as parameters only the information required by the Technical Note is shown in Listing 13.
Listing 13. Method to publish a bindingTemplate, without any additional information
public BindingDetail publish_bindingTemplate(
String serviceKey,
String endpoint,
String urlType,
String portName,
String bindingTModelKey,
String portTypeTModelKey)
throws UDDIException, TransportException
{
BindingTemplate bindingTemplate = new BindingTemplate();
bindingTemplate.setBindingKey("");
bindingTemplate.setServiceKey(serviceKey);
return publish_bindingTemplate(
bindingTemplate,
endpoint,
urlType,
portName,
bindingTModelKey,
portTypeTModelKey);
} |
The purpose of the sample application is to show how you can use the Java language to achieve the same effect achieved in Part 3 of the series using the UDDI GUI. The goal is to publish a UDDI model of the WSDL for an implementation of the WS-I sample application. Apart from the keys generated for the tModels and so forth, the UDDI model published should be exactly the same as the one described in Part 3.
A full description of the support for authentication in the IBM WebSphere UDDI registry is outside the scope of this article. It should be noted that when WebSphere Global Security is off, no UDDI authentication is required. This is the mode of operation that this sample assumes.
Our sample application is written as a Java class with a main() method.
The fully-qualified name of the class is uddi.wsdl.v2.publish.PublishSample.
The class definition and the main() method are shown in Listing 14.
Listing 14. Class definition and main method of our sample application
package uddi.wsdl.v2.publish;
import java.net.MalformedURLException;
import java.util.Vector;
import org.uddi4j.UDDIException;
import org.uddi4j.client.UDDIProxy;
import org.uddi4j.datatype.binding.BindingTemplate;
import org.uddi4j.datatype.business.BusinessEntity;
import org.uddi4j.datatype.service.BusinessService;
import org.uddi4j.datatype.tmodel.TModel;
import org.uddi4j.response.BindingDetail;
import org.uddi4j.response.BusinessDetail;
import org.uddi4j.response.ServiceDetail;
import org.uddi4j.response.TModelDetail;
import org.uddi4j.transport.TransportException;
import org.uddi4j.util.CategoryBag;
import org.uddi4j.util.KeyedReference;
public class PublishSample
{
private static String configuratorAKey = null;
private static String loggingFacilityAKey = null;
private static String manufacturerAKey = null;
private static String warehouseAKey = null;
private static String retailerAKey = null;
private static String configuratorPortTypeKey = null;
private static String loggingFacilityPortTypeKey = null;
private static String manufacturerPortTypeKey = null;
private static String retailerPortTypeKey = null;
private static String warehouseShipmentsPortTypeKey = null;
private static String configuratorBindingKey = null;
private static String loggingFacilityBindingKey = null;
private static String manufacturerBindingKey = null;
private static String retailerBindingKey = null;
private static String warehouseShipmentsBindingKey = null;
private final static String SOAP_PROTOCOL_KEY =
"uuid:aa254698-93de-3870-8df3-a5c075d64a0e";
private final static String HTTP_TRANSPORT_KEY =
"uuid:68DE9E80-AD09-469D-8A37-088422BFBC36";
public static void main(String[] args)
{
UDDIProxy proxy = new UDDIProxy();
try
{
proxy.setPublishURL(args[0]);
try
{
String authInfo = ""; // Assume no security
Publish publish = new Publish(proxy, authInfo);
publishBusinesses(proxy, authInfo);
publishPortTypeTModels(publish);
publishBindingTModels(publish);
publishServices(publish);
}
catch (TransportException te)
{
te.printStackTrace(System.err);
}
catch (UDDIException uddie)
{
uddie.printStackTrace(System.err);
}
}
catch (MalformedURLException murle)
{
System.err.println("publish URL malformed");
}
}
|
The main() method expects a single argument: the publishURL to be used with the UDDI4J proxy.
The method constructs the UDDI4J proxy and then constructs an instance of the Publish class using this UDDI4J proxy instance and a fixed authInfo value of "" (as WebSphere Global Security is assumed to be off).
The main method then calls the following private static methods in turn, passing in either the UDDI4J proxy or the Publish instance, as appropriate:
publishBusinesses()publishPortTypeTModels()publishBindingTModels()publishServices()
The following sections consider each of these methods in more detail.
As the WSDL Technical Note does not say anything about the businessEntity elements used to contain WSDL-described services, there are no special considerations for the businesses used for the WS-I sample application. Thus, this method only requires the UDDI4J proxy; it does not require the Publish instance.
This method creates the five businesses used in Part 3 of this series and prints out the key of each businessEntity.
The code for this method is shown in Listing 15.
Listing 15. Method to publish sample businesses
private static void publishBusinesses(UDDIProxy proxy, String authInfo)
throws UDDIException, TransportException
{
BusinessDetail result = null;
Vector businessVector = new Vector();
BusinessEntity configuratorA = new BusinessEntity();
configuratorA.setBusinessKey("");
configuratorA.setDefaultNameString("ConfiguratorA", "en-US");
businessVector.add(configuratorA);
BusinessEntity loggingFacilityA = new BusinessEntity();
loggingFacilityA.setBusinessKey("");
loggingFacilityA.setDefaultNameString("LoggingFacilityA", "en-US");
businessVector.add(loggingFacilityA);
BusinessEntity manufacturerA = new BusinessEntity();
manufacturerA.setBusinessKey("");
manufacturerA.setDefaultNameString("ManufacturerA", "en-US");
businessVector.add(manufacturerA);
BusinessEntity warehouseA = new BusinessEntity();
warehouseA.setBusinessKey("");
warehouseA.setDefaultNameString("WarehouseA", "en-US");
businessVector.add(warehouseA);
BusinessEntity retailerA = new BusinessEntity();
retailerA.setBusinessKey("");
retailerA.setDefaultNameString("RetailerA", "en-US");
businessVector.add(retailerA);
result = proxy.save_business(authInfo, businessVector);
if (!result.getTruncatedBoolean())
{
Vector resultVector = result.getBusinessEntityVector();
if (resultVector.size() == 5)
{
configuratorAKey =
((BusinessEntity) (resultVector.elementAt(0)))
.getBusinessKey();
System.out.println("configuratorA key is " + configuratorAKey);
loggingFacilityAKey =
((BusinessEntity) (resultVector.elementAt(1)))
.getBusinessKey();
System.out.println(
"loggingFacilityA key is " + loggingFacilityAKey);
manufacturerAKey =
((BusinessEntity) (resultVector.elementAt(2)))
.getBusinessKey();
System.out.println("manufacturerA key is " + manufacturerAKey);
warehouseAKey =
((BusinessEntity) (resultVector.elementAt(3)))
.getBusinessKey();
System.out.println("warehouseA key is " + warehouseAKey);
retailerAKey =
((BusinessEntity) (resultVector.elementAt(4)))
.getBusinessKey();
System.out.println("retailerA key is " + retailerAKey);
}
}
}
|
This method creates five portType tModels, one for each of the interfaces in the WS-I sample application.
As there is no extra information required for the portType tModels, the version of publish_portType_tModel() that does not take the extra parameter is called; only the appropriate namespace name, portType name, and URL are required.
The key of each created tModel is printed out.
The code for this method is shown in Listing 16 in this sidefile.
This method creates five binding tModels, one for each of the portType tModels.
As mentioned earlier, because the WS-I conformance information needs to be added to the binding tModels, this example uses the publish_binding_tModel() method that takes an extra parameter.
The TModel instance that is passed in contains only a categoryBag with a single keyedReference for the WS-I conformance statement.
As the publish_binding_tModel() method updates the tModel instance passed to it, the instance must be recreated before each call to the method.
The key of each created tModel is then printed out.
The code for this method is shown in Listing 17 in this sidefile.
This method creates the five businessServices, and for each one creates a bindingTemplate.
No additional information is required for either the businessServices or the bindingTemplates, so the appropriate methods that do not take the extra parameter are used.
The keys of each created businessService and bindingTemplate are printed out.
The code for this method is shown in Listing 18.
Listing 18. Method to publish sample services
private static void publishServices(Publish publish)
throws UDDIException, TransportException
{
// ConfiguratorA businessService
ServiceDetail configuratorAServiceDetail =
publish.publish_service(
configuratorAKey,
"urn:x-configuratora.com:configurator_service",
"ConfiguratorA's Configurator Service");
Vector configuratorAVector =
configuratorAServiceDetail.getBusinessServiceVector();
BusinessService configuratorABusinessService =
(BusinessService)configuratorAVector.elementAt(0);
String configuratorAServiceKey =
configuratorABusinessService.getServiceKey();
System.out.println(
"ConfiguratorA's Configurator Service key is "
+ configuratorAServiceKey);
// ConfiguratorA bindingTemplate
BindingDetail configuratorABindingDetail =
publish.publish_bindingTemplate(
configuratorAServiceKey,
"http://configuratora.com/Configurator/",
"http",
"Configurator_Port",
configuratorBindingKey,
configuratorPortTypeKey);
Vector configuratorABindingVector =
configuratorABindingDetail.getBindingTemplateVector();
BindingTemplate configuratorABindingTemplate =
(BindingTemplate)configuratorABindingVector.elementAt(0);
String configuratorABindingKey =
configuratorABindingTemplate.getBindingKey();
System.out.println(
"ConfiguratorA binding key is " + configuratorABindingKey);
// LoggingFacilityA businessService
ServiceDetail loggingFacilityAServiceDetail =
publish.publish_service(
loggingFacilityAKey,
"urn:x-loggingfacilitya.com:loggingfacility_service",
"LoggingFacilityA's LoggingFacility Service");
Vector loggingFacilityAVector =
loggingFacilityAServiceDetail.getBusinessServiceVector();
BusinessService loggingFacilityABusinessService =
(BusinessService)loggingFacilityAVector.elementAt(0);
String loggingFacilityAServiceKey =
loggingFacilityABusinessService.getServiceKey();
System.out.println(
"LoggingFacilityA's LoggingFacility Service key is "
+ loggingFacilityAServiceKey);
// LoggingFacilityA bindingTemplate
BindingDetail loggingFacilityABindingDetail =
publish.publish_bindingTemplate(
loggingFacilityAServiceKey,
"http://loggingfacilitya.com/LoggingFacility/",
"http",
"LoggingFacility_Port",
loggingFacilityBindingKey,
loggingFacilityPortTypeKey);
Vector loggingFacilityABindingVector =
loggingFacilityABindingDetail.getBindingTemplateVector();
BindingTemplate loggingFacilityABindingTemplate =
(BindingTemplate)loggingFacilityABindingVector.elementAt(0);
String loggingFacilityABindingKey =
loggingFacilityABindingTemplate.getBindingKey();
System.out.println(
"LoggingFacilityA binding key is " + loggingFacilityABindingKey);
// ManufacturerA businessService
ServiceDetail manufacturerAServiceDetail =
publish.publish_service(
manufacturerAKey,
"urn:x-manufacturera.com:manufacturer_service",
"ManufacturerA's Manufacturer Service");
Vector manufacturerAVector =
manufacturerAServiceDetail.getBusinessServiceVector();
BusinessService manufacturerABusinessService =
(BusinessService)manufacturerAVector.elementAt(0);
String manufacturerAServiceKey =
manufacturerABusinessService.getServiceKey();
System.out.println(
"ManufacturerA's Manufacturer Service key is "
+ manufacturerAServiceKey);
// ManufacturerA bindingTemplate
BindingDetail manufacturerABindingDetail =
publish.publish_bindingTemplate(
manufacturerAServiceKey,
"http://manufacturera.com/Manufacturer/",
"http",
"Manufacturer_Port",
manufacturerBindingKey,
manufacturerPortTypeKey);
Vector manufacturerABindingVector =
manufacturerABindingDetail.getBindingTemplateVector();
BindingTemplate manufacturerABindingTemplate =
(BindingTemplate)manufacturerABindingVector.elementAt(0);
String manufacturerABindingKey =
manufacturerABindingTemplate.getBindingKey();
System.out.println(
"ManufacturerA binding key is " + manufacturerABindingKey);
// WarehouseA businessService
ServiceDetail warehouseAServiceDetail =
publish.publish_service(
warehouseAKey,
"urn:x-warehousea.com:warehouse_service",
"WarehouseA's Warehouse Service");
Vector warehouseAVector =
warehouseAServiceDetail.getBusinessServiceVector();
BusinessService warehouseABusinessService =
(BusinessService)warehouseAVector.elementAt(0);
String warehouseAServiceKey = warehouseABusinessService.getServiceKey();
System.out.println(
"WarehouseA's Warehouse Service key is " + warehouseAServiceKey);
// WarehouseA bindingTemplate
BindingDetail warehouseABindingDetail =
publish.publish_bindingTemplate(
warehouseAServiceKey,
"http://warehousea.com/Warehouse/",
"http",
"Warehouse_Port",
warehouseShipmentsBindingKey,
warehouseShipmentsPortTypeKey);
Vector warehouseABindingVector =
warehouseABindingDetail.getBindingTemplateVector();
BindingTemplate warehouseABindingTemplate =
(BindingTemplate)warehouseABindingVector.elementAt(0);
String warehouseABindingKey = warehouseABindingTemplate.getBindingKey();
System.out.println("WarehouseA binding key is " + warehouseABindingKey);
// RetailerA businessService
ServiceDetail retailerAServiceDetail =
publish.publish_service(
retailerAKey,
"urn:x-retailera.com:retailer_service",
"RetailerA's Retailer Service");
Vector retailerAVector =
retailerAServiceDetail.getBusinessServiceVector();
BusinessService retailerABusinessService =
(BusinessService)retailerAVector.elementAt(0);
String retailerAServiceKey = retailerABusinessService.getServiceKey();
System.out.println(
"RetailerA's Retailer Service key is " + retailerAServiceKey);
// RetailerA bindingTemplate
BindingDetail retailerABindingDetail =
publish.publish_bindingTemplate(
retailerAServiceKey,
"http://retailera.com/Retailer/",
"http",
"Retailer_Port",
retailerBindingKey,
retailerPortTypeKey);
Vector retailerABindingVector =
retailerABindingDetail.getBindingTemplateVector();
BindingTemplate retailerABindingTemplate =
(BindingTemplate)retailerABindingVector.elementAt(0);
String retailerABindingKey = retailerABindingTemplate.getBindingKey();
System.out.println("RetailerA binding key is " + retailerABindingKey);
}
|
To run the sample, execute the uddi.wsdl.v2.publish.PublishSample class, passing in as a single argument the publishURL to be used.
You should see output similar to that shown in Listing 19.
Listing 19. Sample application output
configuratorA key is CB2444CB-D81D-4DCF-B4E2-318C1A31E218 loggingFacilityA key is AC34BDAC-C08E-4E39-A216-5450A4541658 manufacturerA key is CA49F8CA-4162-4259-AFC4-3A05C43AC445 warehouseA key is 76FB1E76-C514-442F-8EB4-0E44790EB48C retailerA key is C74584C7-1DE3-437D-8951-8F03F18F51A3 ConfiguratorPortType key is UUID:E517DBE5-76C5-4576-938B-278BE8278B1B LoggingFacilityLogPortType key is UUID:83AD5A83-DF9C-4C46-B4FE-3C282C3CFE42 ManufacturerPortType key is UUID:ADD0AEAD-E8A7-478F-B153-C47AECC45380 RetailerPortType key is UUID:C356B6C3-013A-4A94-92E6-1F10981FE665 WarehouseShipmentsPortType key is UUID:C49D46C4-8DB1-411B-BBA9-20B16520A9DF ConfiguratorBinding key is UUID:D0DA7DD0-E8A2-42C0-A047-6C19D96C4799 LoggingFacilitySoapBinding key is UUID:E7CD6FE7-C351-415E-918C-0784E1078C93 ManufacturerSoapBinding key is UUID:F62927F6-9968-481F-B803-2B074B2B039C RetailerSoapBinding key is UUID:141F4614-2BE7-4764-A5E0-5C65C05CE0DA warehouseSoapBinding key is UUID:08FFBE08-3758-48A2-A320-B80B85B8203E ConfiguratorA's Configurator Service key is 0E377A0E-D947-47BB-97EE-9359A193EED4 ConfiguratorA binding key is DA4FE5DA-58F1-4163-B948-43EB3543487F LoggingFacilityA's LoggingFacility Service key is 4B9EB14B-25FF-4FB4-B34C-65FEE3654C90 LoggingFacilityA binding key is 28104E28-5D9B-4BA8-8197-32C33E32978B ManufacturerA's Manufacturer Service key is 06E85606-6C2D-4D8E-A8B6-BBF594BBB6B4 ManufacturerA binding key is D9969ED9-C06A-4AFE-B610-0503DB0510B0 WarehouseA's Warehouse Service key is E85E94E8-85C6-46CB-A37D-117AAD117DCA WarehouseA binding key is 256E8625-E5A4-44F2-8614-0A0CDE0A1468 RetailerA's Retailer Service key is DCC416DC-B3FF-4FDA-8532-249BFD2432A2 RetailerA binding key is 863FB286-CCCD-4D36-BB45-CEBB46CE45A9 |
In this article, you've learned how to use the Java language and UDDI4J to implement the approach to publishing as defined in the Technical Note. You also saw a sample class that publishes the UDDI model for the WS-I Sample Application.
The next article in this series will show you how to write code to issue the queries described in the Technical Note.
- Read the other parts of this series:
- "A new approach to UDDI and WSDL, Part 1" (developerWorks, August 2003) describes the new Technical Note on using WSDL and UDDI together.
- "A new approach to UDDI and WSDL, Part 2" (developerWorks, September 2003) describes the queries that are supported by the approach defined in the new Technical Note.
- "A new approach to UDDI and WSDL, Part 3" (developerWorks, October 2003) describes how to publish and query the UDDI model for the WS-I Sample Application, following the approach defined in the new Technical Note.
- "A new approach to UDDI and WSDL, Part 5" (developerWorks, October 2004) describes how to apply the approach defined in the new OASIS UDDI Technical Note to query from a Java application.
- The WS-I Sample Application "Supply Chain Management Sample Application Architecture" is published by the Web Services-Interoperability Organization. (Article is in PDF format.)
- Learn more about the UDDI4J library.
- The OASIS UDDI Specifications Technical Committee is now responsible for UDDI standards.
- This article is based on the Technical Note "Using WSDL in a UDDI registry, Version 2.0," which has recently been published as an official Technical Note by the OASIS UDDI Specifications Technical Committee.
- The previous best practice, "Using WSDL in a UDDI registry, Version 1.08," has been updated by the OASIS UDDI Specifications Technical Committee since the previous developerWorks articles were written.
- Access Web services knowledge, tools, and skills with Speed-start Web services, which offers the latest Java-based software development tools and middleware from IBM (trial editions), plus online tutorials and articles, and an online technical forum.
- Browse for books on these and other technical topics.
- Want more? The developerWorks SOA and Web services zone hosts hundreds of informative articles and introductory, intermediate, and advanced tutorials on how to develop Web services applications.
Comments (Undergoing maintenance)





