public void saveBusinessService(BusinessService bs) throws UDDIRegistrationException {
// Preconditions URL, username and password not null.
if ((userName == null) || (password == null) || (publishURL == null))
throw new UDDIRegistrationException(
"userName, password or publishURL is"
+ "null, valid entries are required for all these fields");
try {
UDDIProxy proxy= new UDDIProxy();
proxy.setPublishURL(publishURL);
log.info(
"logging into publish URL: [" + userName + "/" + password + "]");
// Pass in userid and password registered at the UDDI site
AuthToken token= proxy.get_authToken(userName, password);
BindingTemplates bindingTemplates= new BindingTemplates();
org.uddi4j.datatype.service.BusinessService businessService=
new org.uddi4j.datatype.service.BusinessService(
"",
bs.getName(),
bindingTemplates);
businessService.setBusinessKey(bs.getBusinessKey());
Vector services= new Vector();
services.addElement(businessService);
// **** First save a Business Service
ServiceDetail serviceDetail=
proxy.save_service(token.getAuthInfoString(), services);
// Process returned ServiceDetail object to list the
// saved services.
Vector businessServices= serviceDetail.getBusinessServiceVector();
org.uddi4j.datatype.service.BusinessService businessServiceReturned=
(org
.uddi4j
.datatype
.service
.BusinessService) (businessServices
.elementAt(0));
String serviceKey= businessServiceReturned.getServiceKey();
log.info("saved : " + businessServiceReturned.getDefaultNameString());
log.info(
"returned service key : "
+ businessServiceReturned.getServiceKey());
} catch (UDDIException e) {
DispositionReport dr= e.getDispositionReport();
if (dr != null) {
log.error(
"UDDIException faultCode:"
+ e.getFaultCode()
+ "\n operator:"
+ dr.getOperator()
+ "\n generic:"
+ dr.getGeneric()
+ "\n errno:"
+ dr.getErrno()
+ "\n errCode:"
+ dr.getErrCode()
+ "\n errInfoText:"
+ dr.getErrInfoText());
}
} catch (TransportException tex) {
log.error("Transport exception: " + tex.toString());
} catch (MalformedURLException murlex) {
log.error(
"Malformed exception error: " + publishURL + murlex.toString());
}
}
|