Jax-ws spec allow you to do this:

((BindingProvider)port).getRequestContext().put(
   *BindingProvider.ENDPOINT_ADDRESS_PROPERY*,
   "http://foo.com/blah";);

See this thread: http://www.nabble.com/Why-does-a-JAX-WS-client-use-the-WSDL-at-run-time--tf3683059.html#a10315931


Regards,
James


I had some doubts along similar lines.

Suppose that my client needs to access a web service published by
different servers at multiple endpoint urls. These urls will be known
only at runtime. How can I achieve this? (because if the wsdl url is a
file then it has the address of the service)

Arun says that when metro stubs are used the first call is used to
invoke the wsdl and second to get the results. Can we do the same in
CXF by specifying WS endpoint at runtime?

Thanks!
Mayank

On 11/12/07, Abid Hussain <[EMAIL PROTECTED]> wrote:
Thanks, putting the wsdl in the classpath and using the following code
in the ServiceImpl class finally did it:

    static {
        URL url = null;
        try {
//              url = new URL("file:etc/kvvservice.wsdl");
            url =
KvvServiceImplService.class.getResource("/kvvservice.wsdl");
            System.out.println("Using wsdl from (" + url + ").");
        } catch (Exception e) {
            System.err.println("Can not initialize the default wsdl
from classpath:/kvvservice.wsdl");
            // e.printStackTrace();
        }
        WSDL_LOCATION = url;
    }

Regards,

Abi

Glen Mazza schrieb:
Am Montag, den 12.11.2007, 11:08 +0100 schrieb Abid Hussain:
Hello everybody,

I generated a client using wsdl2java and packed it in a jar, so that I
can use it in other applications. When generating the client using
wsdl2java I indicated that the wsdl file is in etc/kvvservice.wsdl.

Now, when I try to use the client in an other application (using the jar
file) I get the following error (full stack trace at the end):
javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem
parsing 'file:etc/kvvservice.wsdl'.: java.io.FileNotFoundException:
etc\kvvservice.wsdl (Das System kann den angegebenen Pfad nicht finden)
First, I wonder how to indicate that the wsdl has moved to another place
when using the client in another application.

Your WSDL file will need to be in the classpath of the client app that
you are running.  Basically, at the root of the classes directory is the
easiest place to put it, but you can also specify other classpaths.

I find Ant easier to state classpaths, if you look at my "run-client"
target in step 5 of my eBay tutorial this may help you:

http://www.jroller.com/gmazza/date/20070817

Also, in your Service class generated by JAX-WS, you can alter the
syntax used for loading the file.  Instead of:

url = new URL("file:mywsdl.wsdl");  // filepath search, probably won't
work for JARs

you should be able to use something like:

URL wsdlURL = getClass().getClassLoader().getResource("mywsdl.wsdl");
// classpath search, should work for JARs


Second, I don't get why the CXF Runtime needs the wsdl file at all? The
clients classes have already been generated using wsdl2java and I
suppose that all information needed is contained in those generated classes.

Vivek and Arun of Sun Metro have much to say about this, links below.

http://forums.java.net/jive/message.jspa?messageID=244333#244333
http://blogs.sun.com/arungupta/date/20071108

HTH,
Glen



--

Abid Hussain
Mail: [EMAIL PROTECTED]
Web: http://www.abid76.de


Reply via email to