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: import org.apache.xmlbeans.XmlOptions;
09:
10: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.models.SchematicWSDLmodel;
11: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.models.ServiceOperation;
12: import com.bostechcorp.cbesb.ws.wsdl.x10.CustomWsdlDocument;
13: import com.bostechcorp.cbesb.ws.wsdl.x10.CustomWsdlDocument.CustomWsdl;
14: import com.bostechcorp.cbesb.ws.wsdl.x10.FileDocument.File;
15: import com.bostechcorp.cbesb.ws.wsdl.x10.OperastionsDocument.Operastions;
16: import com.bostechcorp.cbesb.ws.wsdl.x10.OperationDocument.Operation;
17: import com.bostechcorp.cbesb.ws.wsdl.x10.XsdFilesDocument.XsdFiles;
18:
19: /**
20: * @author LPS
21: *
22: */
23: public class CustomWSDLWriter {
24: String fileName = "";
25:
26: /**
27: * @param fileName
28: */
29: public CustomWSDLWriter(String fileName) {
30: super ();
31: this .fileName = fileName;
32: }
33:
34: public void writeModel(SchematicWSDLmodel model) throws IOException {
35: CustomWsdlDocument doc = CustomWsdlDocument.Factory
36: .newInstance();
37: CustomWsdl root = doc.addNewCustomWsdl();
38: root.setWebServiceName(model.getWsName());
39: root.setSuName(model.getSuName());
40: //files
41: XsdFiles files = root.addNewXsdFiles();
42: for (String ns : model.getXsdFileNames().keySet()) {
43: File file = files.addNewFile();
44: file.setNamespaceprefix(ns);
45: file.setStringValue(model.getFileName(ns));
46: }
47: //operations
48: Operastions operations = root.addNewOperastions();
49: for (ServiceOperation soper : model.getOperations()) {
50: Operation oper = operations.addNewOperation();
51: oper.setInputName(soper.getInputMessageName());
52: oper.setInputType(soper.getInputType());
53: oper.setName(soper.getOperationName());
54: if (soper.hasOutMessage()) {
55: oper.setOuputType(soper.getOutputType());
56: oper.setOutputName(soper.getOutputMessageName());
57: }
58: }
59: doc.save(new java.io.File(fileName), new XmlOptions()
60: .setSavePrettyPrint());
61: }
62:
63: public static void main(String[] args) {
64: CustomWSDLReader reader = new CustomWSDLReader(
65: "c:\\asd\\custWsdl.xml");
66: try {
67: SchematicWSDLmodel model = reader.readModel();
68: CustomWSDLWriter writer = new CustomWSDLWriter(
69: "c:\\asd\\custWsdlNew.xml");
70: writer.writeModel(model);
71: } catch (XmlException e) {
72: // TODO Auto-generated catch block
73: e.printStackTrace();
74: } catch (IOException e) {
75: // TODO Auto-generated catch block
76: e.printStackTrace();
77: }
78: }
79:
80: }
|