Skip to main content

Endpoint.publish fromwsdl problem

8 replies [Last post]
jfdenise
Offline
Joined: 2004-12-20
Points: 0

I am generating a WebService from a WSDL. I then use Endpoint.publish("http://...", myServiceInstance).

When I ask for the WSDL thanks to ?wsdl request, I receive back a WSDL that is not the one referenced by @WebService annotation.

It seems that the WSDL is generated at runtime to smartly replace schema import file locations (I pasted at the end of this message jaxws output).

BTW, the generated WSDL is not compliant with the original one.

What are the steps needed to have the returned WSDL (updated with valid locations) reflect exactly the original one?

Thanks

// JAXWS output

Oct 21, 2005 3:03:01 PM com.sun.xml.ws.server.WSDLPatcher patchImport
INFO: Fixing the relative location:JMXManagementProcessorService_schema1.xsd with absolute location:http://samosa:9999/jmxws?xsd=1
Oct 21, 2005 3:03:01 PM com.sun.xml.ws.server.WSDLPatcher patchImport
INFO: Fixing the relative location:JMXManagementProcessorService_schema2.xsd with absolute location:http://samosa:9999/jmxws?xsd=2
Oct 21, 2005 3:03:01 PM com.sun.xml.ws.server.WSDLPatcher patchImport
INFO: Fixing the relative location:JMXManagementProcessorService_schema3.xsd with absolute location:http://samosa:9999/jmxws?xsd=3
Oct 21, 2005 3:03:01 PM com.sun.xml.ws.server.WSDLPatcher patchImport
INFO: Fixing the relative location:JMXManagementProcessorService_schema4.xsd with absolute location:http://samosa:9999/jmxws?xsd=4
Oct 21, 2005 3:03:01 PM com.sun.xml.ws.server.WSDLPatcher patchImport
INFO: Fixing the relative location:JMXManagementProcessorService_schema5.xsd with absolute location:http://samosa:9999/jmxws?xsd=5
Oct 21, 2005 3:03:01 PM com.sun.xml.ws.server.WSDLPatcher handleSoapAddress
INFO: Fixing service:{http://wsdl.jmx.sun.com/2005/03/ManagementProcessor}JMXManagementProcessorService port:{http://wsdl.jmx.sun.com/2005/03/ManagementProcessor}JMXManagementProcessorPort address with http://samosa:9999/jmxws

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
stoicflame
Offline
Joined: 2005-10-19
Points: 0

I'm sorry, I'm interested in this thread, but I can't establish a context in my head for the sample code you've given. What is Endpoint.publish and where does this code go? Am I missing some documentation somewhere?

jitu
Offline
Joined: 2003-06-14
Points: 0

javax.xml.ws.Endpoint API contains a way to deploy a WebService endpoint on Java SE. Go through the API and spec for more details. Also there is a very simple supplychain sample in the nightly builds. src/supplychain/server/WarehouseLightWeight.java contains the source code that uses Endpoint API.

For e.g: To see the action

One Window:
.../samples/supplychain> ant server-j2se

Other window:
.../samples/supplychain> ant client
.../samples/supplychain> ant run

jitu
Offline
Joined: 2003-06-14
Points: 0

* At present, we ignore wsdlLocation on @WebService annotation. We generate WSDL at runtime if there is no metadata specified for the endpoint. It works great when starting from java.

* For some reason, if you want to use the same WSDL, and schema documents, you can set them as metadata on endpoint. Metadata support is not there in EA2 build but it is there in recent builds.

For e.g:
List metadata = new ArrayList();
for(File file : metadataFile) {
Source source = new StreamSource(new FileInputStream(file));
source.setSystemId(file.toURL().toExternalForm());
metadata.add(source);
}
endpoint.setMetadata(metadata);

Publishing of a webservice uses this metadata, and patches the import locations. You can access the primary wsdl using ...?wsdl etc.

* Also, Can you elaborate the statement "the generated WSDL is not compliant with the original one"

Let us know how it goes.

jfdenise
Offline
Joined: 2004-12-20
Points: 0

Jitu,
thanks for your reply.

- In which build do you plan to support wsdlLocation?
BTW,I would like to be able to bundle metadata files in my webservice jar. Then use jar resource resolution when publishing the files.
In fact I don't really want to rely on wsdlLocation.
Is it doable?

- Using the last week (or 2 weeks ago) jaxws-ri, setting metadata seems not to work. The same

List metadata = new ArrayList();
List metadataFile = new ArrayList();
metadataFile.add(new File("my.wsdl"));
for(File file : metadataFile) {
Source source = new StreamSource(new
FileInputStream(file));
source.setSystemId(file.toURL().toExternalForm());
metadata.add(source);
}
Endpoint endpoint = Endpoint.create(null, processor);
endpoint.setMetadata(metadata);
endpoint.publish("myurl"");

- The generated WSDL dosn't contain valid SOAP binding.
The message names are not the one expected. I understand know why but how do you manage to findout included xsd files if you ignore the annotation?

Expected WSDL
=============





































Generated WSDL
==============
































jitu
Offline
Joined: 2003-06-14
Points: 0

* We may not support wsdlLocation. I will discuss with the team and let you know.
* Yes, you should be able to bundle metadata files in a jar, and use them for publishing. You could create Source using

Source source = new StreamSouce(Thread.getContextClassLoader.getResouceAsStream(name))
source.setSystemId(Thread.getContextClassLoader.getResouce(name).toExternalForm())

* When you are setting metadata, you set all the metadata documents(including schema documents)

* 2 weeks old build has all the necessary metadata changes. If you don't mind, you can send the wsdl, and schema documents, I will see what's going on.

jfdenise
Offline
Joined: 2004-12-20
Points: 0

I just downloaded the latest RI.
If I add the set of schemas, I get a NPE when publishing the endpoint.

I pasted the stack at the end.

Code extract :

List metadata = new ArrayList();

String wsdl = "javax/management/remote/ws/resources/jmx-remote.wsdl";
String xsd1 = "javax/management/remote/ws/resources/resource-data.xsd";
String xsd2 = "javax/management/remote/ws/resources/resource-event.xsd";
String xsd3 = "javax/management/remote/ws/resources/resource-metadata.xsd";
String xsd4 = "javax/management/remote/ws/resources/resource-operations.xsd";

Source source = new StreamSource(loader.getResourceAsStream(wsdl));
source.setSystemId(loader.getResource(wsdl).toExternalForm());
metadata.add(source);

source = new StreamSource(loader.getResourceAsStream(xsd1));
source.setSystemId(loader.getResource(xsd1).toExternalForm());
metadata.add(source);

source = new
StreamSource(loader.getResourceAsStream(xsd2));
source.setSystemId(loader.getResource(xsd2).toExternalForm());
metadata.add(source);

source = new StreamSource(loader.getResourceAsStream(xsd3));
source.setSystemId(loader.getResource(xsd3).toExternalForm());
metadata.add(source);

source = new StreamSource(loader.getResourceAsStream(xsd4));
source.setSystemId(loader.getResource(xsd4).toExternalForm());
metadata.add(source);

Endpoint endpoint = Endpoint.create(null, processor);
endpoint.setMetadata(metadata);
//Null Pointer Exception endpoint.publish("http://samosa.france:9999/jmxws");

======== STACK =========================
Exception in thread "main" Server Runtime Error: Server Runtime Error: java.lang.NullPointerException
at com.sun.xml.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:199)
at com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:65)
at bundledhttpserver.Main.main(Main.java:70)
Caused by: Server Runtime Error: java.lang.NullPointerException
at com.sun.xml.ws.server.RuntimeEndpointInfo.generateWSDL(RuntimeEndpointInfo.java:390)
at com.sun.xml.ws.transport.http.server.HttpEndpoint.generateWSDLDocs(HttpEndpoint.java:184)
at com.sun.xml.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:236)
at com.sun.xml.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:193)
... 2 more
Caused by: java.lang.NullPointerException
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:419)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$800(XmlSchemaGenerator.java:312)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:289)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.generateSchema(JAXBContextImpl.java:700)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.generateTypes(WSDLGenerator.java:214)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.generateDocument(WSDLGenerator.java:197)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.doGeneration(WSDLGenerator.java:147)
at com.sun.xml.ws.server.RuntimeEndpointInfo.generateWSDL(RuntimeEndpointInfo.java:388)
... 5 more

jfdenise
Offline
Joined: 2004-12-20
Points: 0

The NPE exception was due to a XSD file missing from the set of Source.

I fixed it.

The WSDL is generated. It looks like the original one (except the binding element. input and output have no name attribute).

I was then able to load it using JAXWS 2.0 tooling. wsimport was able to generate code from it. This is fine.

I tried to do the same thing using .Net Studio and it failed. Seems a namespace multiple defined.

.Net bug? Investigation seems needed...

jitu
Offline
Joined: 2003-06-14
Points: 0

Your original wsdl has the following QNames for Service, and Port
Service={http://wsdl.jmx.sun.com/2005/03/ManagementProcessor}ManagementProcessorService
port={http://wsdl.jmx.sun.com/2005/03/ManagementProcessor}ManagementProcessor

This isn't captured in your @WebService annotation and doesn't match defaults
( service name=JMXManagementProcessorService, and portname=JMXManagementProcessorPort).
Hence the runtime is generating a new wsdl.

1. You could add them to your @WebService annotation on the implementation class(JMXManagementProcessor.java) using serviceName, portName.

OR
2. Set them as properties on endpoint API
Map map = new HashMap();
map.put(Endpoint.WSDL_SERVICE, new QName("http://wsdl.jmx......", "ManagementProcessorService"));
map.put(Endpoint.WSDL_PORT, new QName("...", "..."));
endpoint.setProperties(map);

After this, Endpoint will be published using your original wsdl.