You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Steve Cohen <sc...@javactivity.org> on 2008/11/25 02:33:17 UTC
Generated javax.jws annotations and file:// URLs
CXF generates java code with annotations like this:
@WebServiceClient(name = "XyzService",
wsdlLocation = "file:///path/to/XyzService.wsdl",
targetNamespace = "http://xyz.com/")
public class XyzService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://xyz.com/",
"XyzService");
public final static QName EmergencyProvisioningPort = new
QName("http://xyz.com/", "XyzPort");
static {
URL url = null;
try {
url = new URL("file:///path/to/XyzService.wsdl");
} catch (MalformedURLException e) {
System.err.println("Can not initialize the default wsdl from
file:///path/to/XyzService.wsdl");
// e.printStackTrace();
}
WSDL_LOCATION = url;
}
...
}
Note that the file URL file:///path/to/XyzService.wsdl is repeated three
times by the generator in different contexts and its reference comes
from the machine where the generator was run.
But suppose I want to write a JUnit test, say, that tests the client I
am building, and let's further suppose that I want to run that test on
different machines, perhaps even on Linux and Windows machines. I will
have to modify the generated code, but I am not aware of any file:// URL
that could be correctly interpreted on both linux and windows unless I
do something ugly like create a /C: directory in linux. If I wanted to
make a requirement that no machine could run this code that did not have
working web server on it, then I could use an http://localhost URL
instead, but that is also not optimal.
Is there some way to have the generator create more portable code than
this? And if not, and I am forced to modify generated code, is there
any possible file:// URL that will work cross-platform?
Re: Generated javax.jws annotations and file:// URLs
Posted by Steve Cohen <sc...@javactivity.org>.
Thanks. That's a help.
Daniel Kulp wrote:
> The code generator has a "-wsdlLocation" flag that can be used to specify what
> is put in those annotations. It might be good to try investigating various
> ways to use that. A "common" thing to do is to
> specify "/WEB-INF/wsdl/hello.wsdl" or similar to point to a location in the
> current war.
>
> Dan
>
>
> On Monday 24 November 2008 8:33:17 pm Steve Cohen wrote:
>
>> CXF generates java code with annotations like this:
>>
>> @WebServiceClient(name = "XyzService",
>> wsdlLocation = "file:///path/to/XyzService.wsdl",
>> targetNamespace = "http://xyz.com/")
>> public class XyzService extends Service {
>>
>> public final static URL WSDL_LOCATION;
>> public final static QName SERVICE = new QName("http://xyz.com/",
>> "XyzService");
>> public final static QName EmergencyProvisioningPort = new
>> QName("http://xyz.com/", "XyzPort");
>> static {
>> URL url = null;
>> try {
>> url = new URL("file:///path/to/XyzService.wsdl");
>> } catch (MalformedURLException e) {
>> System.err.println("Can not initialize the default wsdl from
>> file:///path/to/XyzService.wsdl");
>> // e.printStackTrace();
>> }
>> WSDL_LOCATION = url;
>> }
>> ...
>> }
>>
>> Note that the file URL file:///path/to/XyzService.wsdl is repeated three
>> times by the generator in different contexts and its reference comes
>> from the machine where the generator was run.
>>
>> But suppose I want to write a JUnit test, say, that tests the client I
>> am building, and let's further suppose that I want to run that test on
>> different machines, perhaps even on Linux and Windows machines. I will
>> have to modify the generated code, but I am not aware of any file:// URL
>> that could be correctly interpreted on both linux and windows unless I
>> do something ugly like create a /C: directory in linux. If I wanted to
>> make a requirement that no machine could run this code that did not have
>> working web server on it, then I could use an http://localhost URL
>> instead, but that is also not optimal.
>>
>>
>> Is there some way to have the generator create more portable code than
>> this? And if not, and I am forced to modify generated code, is there
>> any possible file:// URL that will work cross-platform?
>>
>
>
>
>
Re: Generated javax.jws annotations and file:// URLs
Posted by Daniel Kulp <dk...@apache.org>.
The code generator has a "-wsdlLocation" flag that can be used to specify what
is put in those annotations. It might be good to try investigating various
ways to use that. A "common" thing to do is to
specify "/WEB-INF/wsdl/hello.wsdl" or similar to point to a location in the
current war.
Dan
On Monday 24 November 2008 8:33:17 pm Steve Cohen wrote:
> CXF generates java code with annotations like this:
>
> @WebServiceClient(name = "XyzService",
> wsdlLocation = "file:///path/to/XyzService.wsdl",
> targetNamespace = "http://xyz.com/")
> public class XyzService extends Service {
>
> public final static URL WSDL_LOCATION;
> public final static QName SERVICE = new QName("http://xyz.com/",
> "XyzService");
> public final static QName EmergencyProvisioningPort = new
> QName("http://xyz.com/", "XyzPort");
> static {
> URL url = null;
> try {
> url = new URL("file:///path/to/XyzService.wsdl");
> } catch (MalformedURLException e) {
> System.err.println("Can not initialize the default wsdl from
> file:///path/to/XyzService.wsdl");
> // e.printStackTrace();
> }
> WSDL_LOCATION = url;
> }
> ...
> }
>
> Note that the file URL file:///path/to/XyzService.wsdl is repeated three
> times by the generator in different contexts and its reference comes
> from the machine where the generator was run.
>
> But suppose I want to write a JUnit test, say, that tests the client I
> am building, and let's further suppose that I want to run that test on
> different machines, perhaps even on Linux and Windows machines. I will
> have to modify the generated code, but I am not aware of any file:// URL
> that could be correctly interpreted on both linux and windows unless I
> do something ugly like create a /C: directory in linux. If I wanted to
> make a requirement that no machine could run this code that did not have
> working web server on it, then I could use an http://localhost URL
> instead, but that is also not optimal.
>
>
> Is there some way to have the generator create more portable code than
> this? And if not, and I am forced to modify generated code, is there
> any possible file:// URL that will work cross-platform?
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Generated javax.jws annotations and file:// URLs
Posted by Benson Margulies <bi...@gmail.com>.
The rest of us just test through the API where we specify the port and
ignore what is sitting in the annotations.
On Mon, Nov 24, 2008 at 8:33 PM, Steve Cohen <sc...@javactivity.org> wrote:
> CXF generates java code with annotations like this:
>
> @WebServiceClient(name = "XyzService",
> wsdlLocation = "file:///path/to/XyzService.wsdl",
> targetNamespace = "http://xyz.com/")
> public class XyzService extends Service {
>
> public final static URL WSDL_LOCATION;
> public final static QName SERVICE = new QName("http://xyz.com/",
> "XyzService");
> public final static QName EmergencyProvisioningPort = new
> QName("http://xyz.com/", "XyzPort");
> static {
> URL url = null;
> try {
> url = new URL("file:///path/to/XyzService.wsdl");
> } catch (MalformedURLException e) {
> System.err.println("Can not initialize the default wsdl from
> file:///path/to/XyzService.wsdl");
> // e.printStackTrace();
> }
> WSDL_LOCATION = url;
> }
> ...
> }
>
> Note that the file URL file:///path/to/XyzService.wsdl is repeated three
> times by the generator in different contexts and its reference comes from
> the machine where the generator was run.
>
> But suppose I want to write a JUnit test, say, that tests the client I am
> building, and let's further suppose that I want to run that test on
> different machines, perhaps even on Linux and Windows machines. I will have
> to modify the generated code, but I am not aware of any file:// URL that
> could be correctly interpreted on both linux and windows unless I do
> something ugly like create a /C: directory in linux. If I wanted to make a
> requirement that no machine could run this code that did not have working
> web server on it, then I could use an http://localhost URL instead, but that
> is also not optimal.
>
>
> Is there some way to have the generator create more portable code than this?
> And if not, and I am forced to modify generated code, is there any possible
> file:// URL that will work cross-platform?
>
>
>