Listing 1: Web service supporting a getVersion message
<%@ WebService Language="C#" Class="SomeService" %>
using System.Web.Services;
public class SomeService {
[ WebMethod ]
public Version getVersion() {
Version result = new Version(); 
result.setMajor(1);
result.setMinor(2);
result.setPatch(3);
return result;
}
}


public class Version {
private int major = 0;
private int minor = 0;
private int patch = 0;
public void setMajor(int x) {
major = x;
}
public int getMajor() {
return major;
}
public void setMinor(int x) {
minor = x;
}
public int getMinor() {
return minor;
}
public void setPatch(int x) {
patch = x;
}
public int getPatch() {
return patch;
}
}

Listing 2: Performing the wider search
UDDIProxy proxy = new UDDIProxy();
Collection results = new TreeSet(new VersionCompare());

// Find all businesses 

Vector businessInfoVector = null; 
BusinessList bl = 
proxy.find_business("%", new FindQualifiers(), 0);

try {
businessInfoVector =
bl.getBusinessInfos().getBusinessInfoVector(); 
} catch (NullPointerException e) {
// do nothing; let the function return an empty collection
}

// Find all services

if (businessInfoVector != null) {
for (int i = 0; i < businessInfoVector.size(); i++) {
BusinessInfo businessInfo = 
(BusinessInfo)businessInfoVector.elementAt(i);

// Retrieve list of service
Vector serviceInfos;
try {
serviceInfos = 
businessInfo.getServiceInfos().getServiceInfoVector();
} catch (NullPointerException e) {
// may not have any service details
continue;
}

Enumeration enum1 = serviceInfos.elements();
while (enum1.hasMoreElements()) {

ServiceInfo si = (ServiceInfo)enum1.nextElement();

// set up tModel bag
Vector vTModels = new Vector();
vTModels.add(tModelKey);

TModelBag tmBag = new TModelBag(vTModels);

// Find all bindings matching tModel

BindingDetail bd = 
proxy.find_binding(new FindQualifiers(),
si.getServiceKey(),
tmBag,
0);

Vector vBindings = bd.getBindingTemplateVector();
Enumeration enumBindings = vBindings.elements();
while (enumBindings.hasMoreElements()) {
BindingTemplate bt = 
(BindingTemplate) enumBindings.nextElement();
// add to TreeSet
results.add(new BindingObj(bt));
}
}
}


return results;

Listing 3: Deserialize the structure
SOAPMappingRegistry smr =
new SOAPMappingRegistry(Constants.NS_URI_2001_SCHEMA_XSD);
BeanSerializer beanSer = new BeanSerializer();
IntDeserializer id = new IntDeserializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://tempuri.org/","getVersionResult"),
Version.class, beanSer, beanSer);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://tempuri.org/","major"),null, null, id);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://tempuri.org/","minor"),null, null, id);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://tempuri.org/","patch"),null, null, id);
call.setSOAPMappingRegistry(smr);

Listing 4: Java code to retrive a tModel object.
UDDIProxy proxy = new UDDIProxy();

try { 
// Point to UDDI server
proxy.setInquiryURL
("http://localhost/uddi/api/inquire.asmx");
} catch (Exception e) {
e.printStackTrace();
}

// Task 1A: Retrieve tModel identifiers
Vector vTM = new Vector();
try {
vTM =
proxy.get_tModelDetail(tModelKey).getTModelVector();
} catch (Exception e) {
// Proxy threw a SOAP or UDDI error.
// Throw fatal exception. 
System.err.println("UDDI Registry access error: " + e);
}

// take the TModel off the Vector.
TModel tm = null;
if (vTM.size() > 0) {
tm = (TModel) vTM.elementAt(0);
} else {
// No TModel returned. Hmmm. That shouldn't happen. 
// Exit with empty collection
return bindings;
}

Listing 5: identifierBag.
// Grab its identifiers
String deprecated = null;
String deprecatedLink = null;
String deprecatedMsg = null;

Enumeration enumIdentifiers = 
tm.getIdentifierBag().getKeyedReferenceVector().elements();
while (enumIdentifiers.hasMoreElements()) {
KeyedReference kr = (KeyedReference)enumIdentifiers.nextElement();
if (kr.getKeyName().equals("DEPRECATED")) {
deprecated = kr.getKeyValue(); 
} else if (kr.getKeyName().equals("DEPRECATED_MSG")) {
deprecatedMsg = kr.getKeyValue(); 
} else if (kr.getKeyName().equals("DEPRECATED_LINK")) {
deprecatedLink = kr.getKeyValue(); 
}
}

Listing 6: Generated message.
if (!(deprecated.equals(null))) {
// convert deprecated value to date
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
Date today = new Date();
Date deprecationDate = new Date();
try {
deprecationDate = formatter.parse(deprecated);
} catch (ParseException e) {
// Unparseable date string: set to 3000/12/31
try {
deprecationDate = formatter.parse("3000/12/31");
} catch (ParseException e1) {
System.err.println("Very serious parsing problem: " + e1);
}
}

if (deprecationDate.after(today))
{
// value >= today, exception
// include values of DEPRECATED_MSG and DEPRECATED-LINK in
// any exception.
System.err.println
("TModel will be formally deprecated after " + 
formatter.format(deprecationDate) +
" (" + deprecatedMsg + " [" + 
deprecatedLink + "]).");
} else if (deprecationDate.equals(today) || 
deprecationDate.before(today)) {
// value < today, fatal exception
// include values of DEPRECATED_MSG and DEPRECATED-LINK
throw new WebServiceDeprecationException
("TModel has been formally deprecated as of " + 
formatter.format(deprecationDate) +
" (" + deprecatedMsg + " [" + 
deprecatedLink + "]).");
}
}