FileDocCategorySizeDatePackage
JavaServiceIfaceWriter.javaAPI DocApache Axis 1.45762Sat Apr 22 18:57:28 BST 2006org.apache.axis.wsdl.toJava

JavaServiceIfaceWriter

public class JavaServiceIfaceWriter extends JavaClassWriter
This is Wsdl2java's service writer. It writes the .java file.

Fields Summary
private javax.wsdl.Service
service
Field service
private org.apache.axis.wsdl.symbolTable.SymbolTable
symbolTable
Field symbolTable
Constructors Summary
protected JavaServiceIfaceWriter(Emitter emitter, org.apache.axis.wsdl.symbolTable.ServiceEntry sEntry, org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Constructor.

param
emitter
param
sEntry
param
symbolTable


        super(emitter, sEntry.getName(), "service");

        this.service = sEntry.getService();
        this.symbolTable = symbolTable;
    
Methods Summary
protected java.lang.StringgetClassText()
Returns "interface ".

return

        return "interface ";
    
protected java.lang.StringgetExtendsText()
Returns "extends javax.xml.rpc.Service ".

return

        return "extends javax.xml.rpc.Service ";
    
protected voidwriteFileBody(java.io.PrintWriter pw)
Write the body of the service file.

param
pw
throws
IOException


        // output comments
        writeComment(pw, service.getDocumentationElement(), false);

        // get ports
        Map portMap = service.getPorts();
        Iterator portIterator = portMap.values().iterator();

        // write a get method for each of the ports with a SOAP binding
        while (portIterator.hasNext()) {
            Port p = (Port) portIterator.next();
            Binding binding = p.getBinding();

            if (binding == null) {
                throw new IOException(Messages.getMessage("emitFailNoBinding01",
                        new String[]{
                            p.getName()}));
            }

            BindingEntry bEntry =
                    symbolTable.getBindingEntry(binding.getQName());

            if (bEntry == null) {
                throw new IOException(
                        Messages.getMessage(
                                "emitFailNoBindingEntry01",
                                new String[]{binding.getQName().toString()}));
            }

            PortTypeEntry ptEntry =
                    symbolTable.getPortTypeEntry(binding.getPortType().getQName());

            if (ptEntry == null) {
                throw new IOException(
                        Messages.getMessage(
                                "emitFailNoPortType01",
                                new String[]{
                                    binding.getPortType().getQName().toString()}));
            }

            // If this isn't an SOAP binding, skip it
            if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
                continue;
            }

            // JSR 101 indicates that the name of the port used
            // in the java code is the name of the wsdl:port.  It
            // does not indicate what should occur if the
            // wsdl:port name is not a java identifier.  The
            // TCK depends on the case-sensitivity being preserved,
            // and the interop tests have port names that are not
            // valid java identifiers.  Thus the following code.

            // java port <--> wsdl port mapping
            String portName = (String) bEntry.getDynamicVar(JavaServiceWriter.PORT_NAME + ":" + p.getName());
            if (portName == null) {
                portName = p.getName();
            }

            if (!JavaUtils.isJavaId(portName)) {
                portName = Utils.xmlNameToJavaClass(portName);
            }

            // If there is not literal use, the interface name is the portType name.
            // Otherwise it is the binding name.
            String bindingType =
                    (String) bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME);

            // Write out the get<PortName> methods
            pw.println("    public java.lang.String get" + portName
                    + "Address();");
            pw.println();
            pw.println("    public " + bindingType + " get" + portName
                    + "() throws "
                    + javax.xml.rpc.ServiceException.class.getName() + ";");
            pw.println();
            pw.println("    public " + bindingType + " get" + portName
                    + "(java.net.URL portAddress) throws "
                    + javax.xml.rpc.ServiceException.class.getName() + ";");
        }