Has there been any thought to allowing WSDL2Java to generate the service
stub code even if the address is not specified ?  We have several use cases
where the client will not know the port address because the WSDL had not
been deployed yet, but they still would like to generate the stub code.

We have modified our version of the JavaServiceImplWriter class to work as
follows:

If the port address is specified in the WSDL, we generate (as normal):

package my.packagename;

public class Bank {

    // Use to get a proxy class for BankPort

    private final java.lang.String BankPort_address =
"http://www.myBank.com";;

    public String getBankPortAddress() {
        return BankPort_address;
    }

    public my.packagename.BankPortType getBankPort() {
       java.net.URL endpoint;
        try {
            endpoint = new java.net.URL(BankPort_address);
        }
        catch (java.net.MalformedURLException e) {
            return null; // unlikely as URL was validated in Wsdl2java
        }
        return getBankPort(endpoint);
    }

    public my.packagename.BankPortType getBankPort(java.net.URL portAddress)
{
        try {
            return new my.packagename.BankSoapBindingStub(portAddress);
        }
        catch (org.apache.axis.AxisFault e) {
            return null; // ???
        }
    }
}

If there is no port address specified, we only generate:

package my.packagename;

public class Bank {

    // Use to get a proxy class for BankPort

    public my.packagename.BankPortType getBankPort(java.net.URL portAddress)
{
        try {
            return new my.packagename.BankSoapBindingStub(portAddress);
        }
        catch (org.apache.axis.AxisFault e) {
            return null; // ???
        }
    }
}

This will then force the client programmer to specify the port address at
run time.

What do you think of this idea ?  Is there something else we are overlooking
?

Nancy

> -----Original Message-----
> From: Russell Butek [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 07, 2002 8:28 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Errors creating java files through "Wsdl2java"
> 
> 
> I suspect you did not specify the --location option.  That option is
> required.  Otherwise WSDL is generated that doesn't have a 
> location in the
> service clause and WSDL2Java fails for the reason given.
> 
> We've fixed Java2WSDL since alpha3 so that it doesn't run without a
> location.
> 
> Russell Butek
> [EMAIL PROTECTED]
> 
> 
> "Lakshmi Prasad" <[EMAIL PROTECTED]> on 02/07/2002 06:08:36 AM
> 
> Please respond to [EMAIL PROTECTED]
> 
> To:   <[EMAIL PROTECTED]>
> cc:   <[EMAIL PROTECTED]>
> Subject:  Errors creating java files through "Wsdl2java"
> 
> 
> 
> 
> Hi All ,
> 
> I am new to Axis and I have downloaded alpha3. I am  trying to run the
> samples.
> The samples are working fine but I struck at a  particular 
> example i.e.,
> I have generated a "wsdl" file by using tool  "Java2wsdl".for 
> the example
> Calculator.class in sample/userguide/example2  directory.
> 
> But when I try to generate Java Files  from this wsdl file using
> "wsdl2java" tool  I get the following  Errors. Can some one help me
> 
> I am giving the following commands through command  line
> C:\axis\samples>java  org.apache.axis.wsdl.Wsdl2java calculator.wsdl
> java.io.IOException: Emitter  failure.  Cannot find endpoint 
> address in
> port CalculatorPort in service  Calculator
>         at
> org.apache.axis.wsdl.JavaServiceImplWriter.writeFileBody(JavaS
> erviceImplWriter.java:145)
>          at  
> org.apache.axis.wsdl.JavaWriter.write(JavaWriter.java:165)
>          at
> org.apache.axis.wsdl.JavaServiceWriter.write(JavaServiceWriter
> .java:95)
>          at  org.apache.axis.wsdl.Emitter.emit(Emitter.java:225)
>          at  org.apache.axis.wsdl.Emitter.emit(Emitter.java:169)
>          at  org.apache.axis.wsdl.Emitter.emit(Emitter.java:141)
>          at org.apache.axis.wsdl.Wsdl2java.main(Wsdl2java.java:260)
> 
> awaiting an early reply.
> Thanks in advance.
> 
> Regards
> Prasad
> 
> 

Reply via email to