WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
Definition definition = reader.readWSDL(null, new InputSource(new StringReader(
wsdlAsStr)));
if (definition.getServices() == null) {
throw new XregistryException(
"WSDL must be a concreate WSDL, it must have service defined");
}
Iterator it = definition.getServices().values().iterator();
if (it.hasNext()) {
Service service = (Service) it.next();
QName wsdlQname = service.getQName();
QName portTypeName;
Iterator ports = service.getPorts().values().iterator();
if (ports.hasNext()) {
Port port = (Port) ports.next();
portTypeName = port.getBinding().getPortType().getQName();
} else {
throw new XregistryException(
"WSDL must be a concreate WSDL, it must have port defined");
}
String resourceID = ResourceUtils
.getResourceID(DocType.CWsdl,wsdlQname.toString());
// INSERT INTO
// cwsdl_table(resourceid,qname,wsdl_str,time_stamp,life_time,port_type_name)
// VALUES (?, ?, ?, ?, ?, ?)
//if CWSDL is alredy there, delete it
removeResource(resourceID, DELETE_CWSDL_SQL, new String[]{wsdlQname.toString()});
//Add CWSDL
return registerResource(user, resourceID, ADD_CWSDL_SQL, new SqlParam[] {
new SqlParam(resourceID), new SqlParam(wsdlQname.toString()),
new SqlParam(wsdlAsStr),
new SqlParam(String.valueOf(System.currentTimeMillis()), SqlParmType.Long),
new SqlParam(String.valueOf(lifetimeAsSeconds*1000), SqlParmType.Int),
new SqlParam(portTypeName.toString()) });
} else {
throw new XregistryException(
"WSDL must be a concreate WSDL, it must have service defined");
}
} catch (WSDLException e) {
throw new XregistryException(e);
}
}