wood burning stoves*
The moose likes Web Services and the fly likes Doubt on Referring Inline Schema from WSDL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Doubt on Referring Inline Schema from WSDL" Watch "Doubt on Referring Inline Schema from WSDL" New topic
Author

Doubt on Referring Inline Schema from WSDL

Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Howdy Ranchers,

I have been working on Spring Web Services from sometime now and I am stuck and need some advice.

We have an extended wsdl file in which we have schema definitions inline, so there is a request and response information in form of


Above xsd definition is part of a wsdl file and not a seperate xsd file.

The schemaLocation attribute of the tag in spring web services, take 2 parameters i.e contextPath and schemaLocation. Ideally the schemaLocation attribute should have the relative path to the xsd, however the problem right now is we dont have a seperate xsd to refer. The XSD information is right there, inside the wsdl file. Can we refer to the schema inside the wsdl with the same attribute i.e schemaLocation ? or for inline schema inside a wsdl, we have a different way?

I tried looking up the web for bean API but somehow didnt get some good resources to read, It would be great if anyone of you out here throw some light on this.

Thanks in Advance,
Yogendra Joshi.


Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I think you will have to extract the XML schema from the WSDL and store in a file of its own before you can refer to it from a schemaLocation attribute.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Ivan Krizsan wrote:Hi!
I think you will have to extract the XML schema from the WSDL and store in a file of its own before you can refer to it from a schemaLocation attribute.
Best wishes!


Thanks Ivan,

I have seperated the xsd information into a seperate xsd file and now I am referring to the schemaLocation with the xsd file location and all works fine. My question was can we use the schemaLocation with wsdl file containing the xsd information?

-Yogendra.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Yogendra Joshi wrote:
I have seperated the xsd information into a seperate xsd file and now I am referring to the schemaLocation with the xsd file location and all works fine. My question was can we use the schemaLocation with wsdl file containing the xsd information?

Sorry, I misunderstood your question(?)!
...and I must admit that I do not quite understand the above question either.
I see two possibilities:
1. You want to import the XML schema into the WSDL.
2. You want to use the XML schema extracted from the WSDL in some other XML schema.

1.
In the <wsdl:types> element in the WSDL file, you need to use an <xsd:import> element wrapped in a <xsd:schema> element to import a XML schema.
For an example, see page 71 in my e-book: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287

2.
In this case you either use import or include.
Import is used to import one XML schema into another XML schema when the both schemas have different namespaces.
Include can be used when both the XML schemas have the same namespace.
For details, please refer to page 32 in my e-book: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287

Hope this helps. If I have misunderstood again, please accept my apologies.
Best wishes!
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Ivan,

I'd say both the possibilities that you are thinking are not something that I am wishing to do.

I would yet again try to explain and this time a little clearer. Sorry if I was not able to communicate my question properly. So here we go:

Currently in our Spring Web Services application, we have a set of xml file in which we have defined the following:

1. EndPoint
2. JAXB Marshalling references with use of bean tag.
3. XML Schema file through which the jaxb marshalling and unmarshalling will work.

So, we have the following line of code for marshaller:



As you can see the second property for jaxb2marshaller is the schemaLocation property which has the path to myExtendedSchema.xsd. Recently we have been provided a wsdl file by a third party vendor who hasnt supplied the xsd schema, so my question to you and everyone who has worked on Web Services is, since I don't have the xsd and I am only supplied with wsdl file, is there anyway to provide the schemaLocation property to fetch the xsd information from wsdl file? I do have the wsdl file which has the <wsdl:types> and the corresponding schema definitions.

I hope I have been a little clearer this time about what I want to achieve.

Thanks,
Yogendra N Joshi.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Yogendra Joshi wrote:...so my question to you and everyone who has worked on Web Services is, since I don't have the xsd and I am only supplied with wsdl file, is there anyway to provide the schemaLocation property to fetch the xsd information from wsdl file?

Ah, thanks for your patience - finally I understand.
I don't think there is a simple way of doing what you want. Certainly nothing available using only XML (with include, import or the alike).
The only way I can think of doing what you want to do is to process the WSDL programmatically (using, for instance, WSDL4J) and extract the XML schema, which you then feed a Resource object holding (or referring to) the XML schema to the Jaxb2Marshaller object.
I suspect that this will require some programming on your part.

Perhaps someone with more experience and/or more insights know about some better way?
Best wishes!
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Thanks so much Ivan,

I am glad that you were able to understand my question

I will trying my hands on this today, but even though we extract the information using wsdl4j what we would finally doing is using XML Schema, so that would be going back to square one where I had seperated the schema information from wsdl into a seperate xsd file.

But, I am really thankful to you for your patience and your suggestions!

Cheers !
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hi Ivan,

I succeeded finally !!

In my spring configuration file where I had given path of xsd, I just removed the schema property and when i tried running the web service through soapUI, It directly accessed the xsd information from wsdl file.

So, What I learnt was, If we do provide a schema property, it will use it. If we dont provide, then it will try to fetch the information from wsdl file and if it doesnt even find it in wsdl, then it would give you an error called , "cvc: element not found".

I am so happy that together with some ideas, we did it !!

Thanks again Ivan !
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hehe, I am not completely sure I understood everything, but I sure am glad you managed to do what you wanted to do! :-)
Thanks also for sharing the information!
 
GeeCON Prague 2014
 
subject: Doubt on Referring Inline Schema from WSDL