1 16 package org.apache.axis.wsdl.toJava; 17 18 import org.apache.axis.utils.JavaUtils; 19 import org.apache.axis.utils.Messages; 20 import org.apache.axis.wsdl.symbolTable.BindingEntry; 21 import org.apache.axis.wsdl.symbolTable.PortTypeEntry; 22 import org.apache.axis.wsdl.symbolTable.ServiceEntry; 23 import org.apache.axis.wsdl.symbolTable.SymbolTable; 24 25 import javax.wsdl.Binding; 26 import javax.wsdl.Port; 27 import javax.wsdl.Service; 28 import java.io.IOException ; 29 import java.io.PrintWriter ; 30 import java.util.Iterator ; 31 import java.util.Map ; 32 33 36 public class JavaServiceIfaceWriter extends JavaClassWriter { 37 38 39 private Service service; 40 41 42 private SymbolTable symbolTable; 43 44 51 protected JavaServiceIfaceWriter(Emitter emitter, ServiceEntry sEntry, 52 SymbolTable symbolTable) { 53 54 super(emitter, sEntry.getName(), "service"); 55 56 this.service = sEntry.getService(); 57 this.symbolTable = symbolTable; 58 } 60 65 protected String getClassText() { 66 return "interface "; 67 } 69 74 protected String getExtendsText() { 75 return "extends javax.xml.rpc.Service "; 76 } 78 84 protected void writeFileBody(PrintWriter pw) throws IOException { 85 86 writeComment(pw, service.getDocumentationElement(), false); 88 89 Map portMap = service.getPorts(); 91 Iterator portIterator = portMap.values().iterator(); 92 93 while (portIterator.hasNext()) { 95 Port p = (Port) portIterator.next(); 96 Binding binding = p.getBinding(); 97 98 if (binding == null) { 99 throw new IOException (Messages.getMessage("emitFailNoBinding01", 100 new String []{ 101 p.getName()})); 102 } 103 104 BindingEntry bEntry = 105 symbolTable.getBindingEntry(binding.getQName()); 106 107 if (bEntry == null) { 108 throw new IOException ( 109 Messages.getMessage( 110 "emitFailNoBindingEntry01", 111 new String []{binding.getQName().toString()})); 112 } 113 114 PortTypeEntry ptEntry = 115 symbolTable.getPortTypeEntry(binding.getPortType().getQName()); 116 117 if (ptEntry == null) { 118 throw new IOException ( 119 Messages.getMessage( 120 "emitFailNoPortType01", 121 new String []{ 122 binding.getPortType().getQName().toString()})); 123 } 124 125 if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) { 127 continue; 128 } 129 130 138 String portName = (String ) bEntry.getDynamicVar(JavaServiceWriter.PORT_NAME + ":" + p.getName()); 140 if (portName == null) { 141 portName = p.getName(); 142 } 143 144 if (!JavaUtils.isJavaId(portName)) { 145 portName = Utils.xmlNameToJavaClass(portName); 146 } 147 148 String bindingType = 151 (String ) bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME); 152 153 pw.println(" public java.lang.String get" + portName 155 + "Address();"); 156 pw.println(); 157 pw.println(" public " + bindingType + " get" + portName 158 + "() throws " 159 + javax.xml.rpc.ServiceException .class.getName() + ";"); 160 pw.println(); 161 pw.println(" public " + bindingType + " get" + portName 162 + "(java.net.URL portAddress) throws " 163 + javax.xml.rpc.ServiceException .class.getName() + ";"); 164 } 165 } } | Popular Tags |