{
builder = domfactory.newDocumentBuilder();
}
catch (javax.xml.parsers.ParserConfigurationException e)
{
throw new GFacSchemaException("Parser configuration exception: " + e.getMessage());
}
DOMImplementation dImpl = builder.getDOMImplementation();
String policyID = portName + "_Policy";
String inputPolicyID = portName + "_operationPolicy";
UnknownExtensibilityElement serviceLevelPolicRef = null;
UnknownExtensibilityElement opLevelPolicRef = null;
String namespace = GFacConstants.GFAC_NAMESPACE;
Document doc = dImpl.createDocument(namespace, "factoryServices", null);
//TODO this is boken fix it
String description = serviceMap.getService().getServiceDescription();
if(description != null){
Element documentation = doc.createElementNS("http://schemas.xmlsoap.org/wsdl/","wsdl:documentation");
documentation.appendChild(doc.createTextNode(description));
def.setDocumentationElement(documentation);
}
if(GFacConstants.TRANSPORT_LEVEL.equals(security))
{
def.addExtensibilityElement(createTransportLevelPolicy(dImpl, policyID));
serviceLevelPolicRef = createWSPolicyRef(dImpl, policyID);
}
else if (GFacConstants.MESSAGE_SIGNATURE.equals(security))
{
def.addExtensibilityElement(WSPolicyGenerator.createServiceLevelPolicy(dImpl, policyID));
def.addExtensibilityElement(WSPolicyGenerator.createOperationLevelPolicy(dImpl, "inputPolicy", inputPolicyID));
serviceLevelPolicRef = createWSPolicyRef(dImpl, policyID);
opLevelPolicRef = createWSPolicyRef(dImpl, inputPolicyID);
}
// Create types
Types types = TypesGenerator.addTypes(def, dImpl, serviceMap, typens, globalTypens, methods);
def.setTypes(types);
// if(!abstractWSDL)
// {
// table = createMessageTable(serviceMap, typens, methods);
// }
// Create port types (only first port type)
PortTypeImpl portType = addPortTypes(def, dImpl, portTypes, serviceQName);
Binding binding = addBinding(def, nameSpaceURI, portType, serviceLevelPolicRef,dImpl);
Vector methodDesc = WSDLGenUtil.getMethodDescriptions(serviceMap);
for(int i = 0; i < methods.length; ++i)
{
String methodName = methods[i].getMethodName();
Vector outParams = WSDLGenUtil.getOutParams(serviceMap, methodName);
OperationImpl operation = addOperation(def, dImpl, methodName, (String) methodDesc.get(i),typens,outParams);
portType.addOperation(operation);
if(!abstractWSDL)
{
UnknownExtensibilityElement wsInPolicyRef = null;
UnknownExtensibilityElement wsOutPolicyRef = null;
BindingInputImpl bindingInput = addBindingInput(def, methodName, wsInPolicyRef);
BindingOutputImpl bindingOutput = addBindingOutput(def, methodName, outParams, wsOutPolicyRef);
BindingOperation bindingOperation = addBindingOperation(def, operation,dImpl);
bindingOperation.setBindingInput(bindingInput);
bindingOperation.setBindingOutput(bindingOutput);
binding.addBindingOperation(bindingOperation);
if(opLevelPolicRef != null)
{
binding.addExtensibilityElement(opLevelPolicRef); }
}
}
def.addPortType(portType);
// =========== end of wsdl binding ===========
// FIXME: This is done as factory information is not needed
// if(abstractWSDL)
// {
//
//
// Element factoryServices = doc.createElement("n:factoryServices");
// factoryServices.setAttribute("xmlns:n", namespace);
// Element factoryService = doc.createElement("n:factoryService");
// factoryService.setAttribute("location", "http://rainier.extreme.indiana.edu:12345");
// factoryService.setAttribute("portType", "n:GenericFactory");
// factoryService.setAttribute("operation", "n:CreateService");
// factoryServices.appendChild(factoryService);
// UnknownExtensibilityElement elem = new UnknownExtensibilityElement();
// elem.setElement(factoryServices);
// def.addExtensibilityElement(elem);
// }
if (!abstractWSDL)
{
def.addBinding(binding);
ServiceImpl service = (ServiceImpl) def.createService();
service.setQName(wsdlQName);
PortImpl port = (PortImpl) def.createPort();
port.setName(wsdlQName.getLocalPart() + WSDL_PORT_SUFFIX);
port.setBinding(binding);
service.addPort(port);
SOAPAddressImpl soapAddress = new SOAPAddressImpl();
soapAddress.setLocationURI(serviceLocation);
port.addExtensibilityElement(soapAddress);
def.addService(service);
}
if(!abstractWSDL)
{
table.put(WSDL_QNAME, wsdlQName);
}
table.put(SERVICE_QNAME, serviceQName);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
wsWriter.writeWSDL(def, bs);
wsdlString = bs.toString();
}
catch (WSDLException e)
{
throw new GFacSchemaException("Error generating WSDL: " + e.getMessage());
}
Reader reader = new StringReader(wsdlString);
Writer writer = new StringWriter();
try {
RoundTrip.roundTrip(reader, writer, " ");
} catch (XmlPullParserException e) {
throw new GFacSchemaException(e);
} catch (IOException e) {
throw new GFacSchemaException(e);
}
wsdlString = writer.toString();
if (abstractWSDL)
{