Skip to main content

WSDL

13 replies [Last post]
tsegreti
Offline
Joined: 2008-12-20

Can someone explain why the published WSDL differs from the original WSDL that is used to create a WSDL first web service? In particular the wsp:Policy element does not appear in my published WSDL. Neither do all the namespaces that are referenced in the document. Why is this? Also, if that information is not present in the published WSDL then where is it?
Thanks,
Tom

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Clive Brettingham-Moore

Assuming that you haven't already found it (it's linked from several
places in the javadoc & java.net site) it was the JAX-WS standard JSR 224:
http://jcp.org/en/jsr/detail?id=224
To download you'll have to agree to a license but it's not too onerous.
I was quoting from the most recent version, Maintenance release 2,
although that part hasn't changed much.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

Clive Brettingham-Moore

From my understanding for this layout you would want:
wsdlLocation="com/trmi/java/lane/plazawebservice/PlazaWebService.wsdl"

The standard doesn't say explicitly, but I'm fairly sure when they use
the url as a resource they mean
ClassLoader.getResource not Class.getResource
(PlazaWebServiceImpl.class.getResource(...)); Class.getResource is
really just a convenience method that pre-processes the resource path
for the loader method to emulate class relative names.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

tsegreti
Offline
Joined: 2008-12-20

Nice! It works now with: wsdlLocation="./com/trmi/java/lane/plazawebservice/PlazaWebService.wsdl"
Also, now that I am specifying the wsdlLocation it is publishing that wsdl instead of generating its own and my policy element is showing up. Thanks for all the help guys.

BTW, Clive, can you give the link to that spec you mentioned in your first post?

Thanks!
Tom

tsegreti
Offline
Joined: 2008-12-20

Sorry to keep this thread going but the resolution to the above issue ran me into another snag relating to the schema location. When I specify the wsdlLocation="...." on my service class the schemaLocation is not updated in the published wsdl file to point to the actual URL that the schema is at. Is there something else that I need to do to make sure that the schema location is correct in the published wsdl? It worked fine when I didn't specify the local wsdl to use.
Thanks again,
Tom

wierob
Offline
Joined: 2007-03-26

I think I did this a long time ago but I can't remember exactly.

Try http://java.sun.com/javase/6/docs/api/javax/xml/ws/Endpoint.html#setMetadata(java.util.List) to set the schema on your Endpoint.

Otherwise the WSDL should be the same as your local file so you may publish the schema file separately by using the build in HTTP server http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/ne... and let the WSDL point to the URL of this schema

regards
robert

wierob
Offline
Joined: 2007-03-26

Hi,

you can specify the WSDL location on you service class: http://java.sun.com/javase/6/docs/api/javax/jws/WebService.html#wsdlLocation().

If no WSDL is specified, the runtime will generate a new one which might not be [i]exactly [/i]the same.

regards
robert

tsegreti
Offline
Joined: 2008-12-20

I tried to do this (I also found another post by you at http://forums.java.net/jive/message.jspa?messageID=214214 and I followed those directions) but I get this stack trace:

Exception in thread "main" com.sun.xml.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(PlazaWebService.wsdl)
at com.sun.xml.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java:291)
at com.sun.xml.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:224)
at com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:154)
at com.sun.xml.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:113)
at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
at com.trmi.java.lane.plazawebservice.PlazaWebServiceImpl.main(PlazaWebServiceImpl.java:27)

I don't know if it makes any difference but I am deploying my web service using the built in javax.xml.ws.Endpoint class.
Thanks,
Tom

Clive Brettingham-Moore

Looking at the spec:

JAXWS 2.1 # 5.2.5.3
The value of the wsdlLocation annotation element on an endpoint
implementation class, if any, MUST be a relative URL. The document it
points to MUST be packaged with the application.
In the Java SE platform, relative URLs are treated as resources.

Ie if wsdlLocation="my.wsdl" then the wsdl should be loadable as
resource "my.wsdl" (if you are used to Class.getResource think
"/my.wsdl") using the classpath of the application.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

tsegreti
Offline
Joined: 2008-12-20

Hi Clive,
Thanks. I gave this a shot and I am still getting the same error. I have my service class as:

com.trmi.java.lane.plazawebservice.PlazaWebServiceImpl.java

with the wsdl located at:

com/trmi/java/lane/plazawebservice/PlazaWebService.wsdl (the same folder as the service class)

As expected, I am able to get the file with PlazaWebServiceImpl.class.getResource("PlazaWebService.wsdl")

but when I specify wsdlLocation="PlazaWebService.wsdl" it fails.
Am I missing something?
Tom

wierob
Offline
Joined: 2007-03-26

Your wsdlLocation must be relative to the current working directory!! As far as I know getResource searches for a file in the class path. Hence if getResource finds it, this only means it is in your classpath.

>with the wsdl located at:
>
>com/trmi/java/lane/plazawebservice/PlazaWebService.wsdl (the same folder as the service class)

So I would guess it should be

wsdlLocation="./com/trmi/java/lane/plazawebservice/PlazaWebService.wsdl"

I'm always confused about the current working directory, so the follwoing should print the relative path:
[code]
URL url = Main.class.getResource();

String workingDirectory = new File (".").getAbsolutePath();
String file = new File(url.toURI()).getAbsolutePath();

System.out.println(workingDirectory);
System.out.println(file);

String relativePath = "." + System.getProperty("file.separator");
relativePath = relativePath.concat(file.substring(workingDirectory.length() - 1));
System.out.println(relativePath);
[/code]

Just insert your .

hope that helps
robert

Glen Mazza

Your policy elements should be there--the only thing I can see is that you
might be incorrectly using the JAX-WS RI and *not* Metro (JAX-WS RI + WSIT =
Metro), and the JAX-WS RI ignores policy elements.

The published WSDL may also differ with respect to the web service URL in
the wsdl:service/wsdl:port section--if necessary, the servlet providing the
web service will update it to point to the actual URL that the servlet
container is hosting the web service at.

Glen

metro-3 wrote:
>
> Can someone explain why the published WSDL differs from the original WSDL
> that is used to create a WSDL first web service? In particular the
> wsp:Policy element does not appear in my published WSDL. Neither do all
> the namespaces that are referenced in the document. Why is this? Also, if
> that information is not present in the published WSDL then where is it?
> Thanks,
> Tom
> [Message sent by forum member 'tsegreti' (tsegreti)]
>
> http://forums.java.net/jive/thread.jspa?messageID=322994
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/WSDL-tp21133710p21135457.html
Sent from the Metro - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

tsegreti
Offline
Joined: 2008-12-20

Ok, I thought I was using Metro. Could you tell me where I went wrong? I downloaded the Metro jar from https://metro.dev.java.net/1.4/
then I extracted it using the command they gave on the page and set the resulting directory as metro home in my ant file. I then defined the wsimport ant task to point to this directory:






After that I ran the wsimport target with my WSDL as input.
Thanks,
Tom

Glen Mazza

If the jars are webservices*.jar then that's Metro and not just the JAX-WS
RI. Otherwise, I'm not sure how to fix your problem. FWIW, My WSDL-first
tutorial is here:
http://www.jroller.com/gmazza/entry/creating_a_wsdl_first_web1.

#5 in the collection of links at the very bottom of it are a couple of
working WS-Security samples with WS-Policy information in the WSDL.

Glen

metro-3 wrote:
>
> Ok, I thought I was using Metro. Could you tell me where I went wrong? I
> downloaded the Metro jar from https://metro.dev.java.net/1.4/
> then I extracted it using the command they gave on the page and set the
> resulting directory as metro home in my ant file. I then defined the
> wsimport ant task to point to this directory:
>

--
View this message in context: http://www.nabble.com/WSDL-tp21133710p21138973.html
Sent from the Metro - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net