1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.utils.JavaUtils; 58 import org.jboss.axis.utils.Messages; 59 import org.jboss.axis.wsdl.symbolTable.BindingEntry; 60 import org.jboss.axis.wsdl.symbolTable.PortTypeEntry; 61 import org.jboss.axis.wsdl.symbolTable.ServiceEntry; 62 import org.jboss.axis.wsdl.symbolTable.SymbolTable; 63 64 import javax.wsdl.Binding; 65 import javax.wsdl.Port; 66 import javax.wsdl.Service; 67 import java.io.IOException ; 68 import java.io.PrintWriter ; 69 import java.util.Iterator ; 70 import java.util.Map ; 71 72 75 public class JavaServiceIfaceWriter extends JavaClassWriter 76 { 77 private Service service; 78 private SymbolTable symbolTable; 79 80 83 protected JavaServiceIfaceWriter(Emitter emitter, 84 ServiceEntry sEntry, 85 SymbolTable symbolTable) 86 { 87 super(emitter, sEntry.getName(), "service"); 88 this.service = sEntry.getService(); 89 this.symbolTable = symbolTable; 90 } 92 95 protected String getClassText() 96 { 97 return "interface "; 98 } 100 103 protected String getExtendsText() 104 { 105 return "extends javax.xml.rpc.Service "; 106 } 108 111 protected void writeFileBody(PrintWriter pw) throws IOException 112 { 113 writeComment(pw, service.getDocumentationElement()); 115 116 Map portMap = service.getPorts(); 118 Iterator portIterator = portMap.values().iterator(); 119 120 while (portIterator.hasNext()) 122 { 123 Port p = (Port)portIterator.next(); 124 Binding binding = p.getBinding(); 125 if (binding == null) 126 { 127 throw new IOException (Messages.getMessage("emitFailNoBinding01", 128 new String []{p.getName()})); 129 } 130 131 BindingEntry bEntry = 132 symbolTable.getBindingEntry(binding.getQName()); 133 if (bEntry == null) 134 { 135 throw new IOException (Messages.getMessage("emitFailNoBindingEntry01", 136 new String []{binding.getQName().toString()})); 137 } 138 139 PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(binding.getPortType().getQName()); 140 if (ptEntry == null) 141 { 142 throw new IOException (Messages.getMessage("emitFailNoPortType01", 143 new String [] 144 {binding.getPortType().getQName().toString()})); 145 } 146 147 if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) 149 { 150 continue; 151 } 152 153 String portName = p.getName(); 161 if (!JavaUtils.isJavaId(portName)) 162 { 163 portName = Utils.xmlNameToJavaClass(portName); 164 } 165 166 String bindingType = (String )bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME); 169 170 pw.println(" public java.lang.String get" + portName + "Address();"); 172 pw.println(); 173 pw.println(" public " + bindingType + " get" + portName 174 + "() throws " + javax.xml.rpc.ServiceException .class.getName() + ";"); 175 pw.println(); 176 pw.println(" public " + bindingType + " get" + portName 177 + "(java.net.URL portAddress) throws " + javax.xml.rpc.ServiceException .class.getName() + ";"); 178 } 179 } 181 } | Popular Tags |