01: /**
02: *
03: */package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.io;
04:
05: import java.io.IOException;
06:
07: import org.apache.xmlbeans.XmlException;
08:
09: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.models.SchematicWSDLmodel;
10: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.models.ServiceOperation;
11: import com.bostechcorp.cbesb.ws.wsdl.x10.CustomWsdlDocument;
12: import com.bostechcorp.cbesb.ws.wsdl.x10.FileDocument.File;
13: import com.bostechcorp.cbesb.ws.wsdl.x10.OperationDocument.Operation;
14:
15: /**
16: * @author LPS
17: *
18: */
19: public class CustomWSDLReader {
20: String fileName = "";
21:
22: /**
23: *
24: */
25: public CustomWSDLReader(String fileName) {
26: super ();
27: this .fileName = fileName;
28: }
29:
30: public SchematicWSDLmodel readModel() throws XmlException,
31: IOException {
32: SchematicWSDLmodel model = null;
33: CustomWsdlDocument doc = parseXml(this .fileName);
34: model = new SchematicWSDLmodel();
35: model.setSuName(doc.getCustomWsdl().getSuName());
36: model.setWsName(doc.getCustomWsdl().getWebServiceName());
37: //set files
38: for (File file : doc.getCustomWsdl().getXsdFiles()
39: .getFileArray()) {
40: model.putFileName(file.getNamespaceprefix(), file
41: .getStringValue());
42: }
43: //set operation
44: for (Operation operation : doc.getCustomWsdl().getOperastions()
45: .getOperationArray()) {
46: ServiceOperation sOperation = new ServiceOperation();
47: sOperation.setOperationName(operation.getName());
48: sOperation.setInputMessageName(operation.getInputName());
49: sOperation.setInputType(operation.getInputType());
50: if (operation.getOutputName() != null) {
51: sOperation.setOutputMessageName(operation
52: .getOutputName());
53: sOperation.setOutputType(operation.getOuputType());
54: sOperation.setOutMessage(true);
55: } else {
56: sOperation.setOutMessage(false);
57: }
58:
59: model.addOperation(sOperation);
60: }
61: return model;
62: }
63:
64: private CustomWsdlDocument parseXml(String xmlFile)
65: throws XmlException, IOException {
66: // Get the XML instance into a file using the path provided.
67: java.io.File xmlfile = new java.io.File(xmlFile);
68: // Parse the instance into the type generated from the schema.
69: return CustomWsdlDocument.Factory.parse(xmlfile);
70: }
71: }
|