• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to create XML from XSD dynamically at runtime

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have got a requirement, where a client has to send a XML inside another xml tag to a web service.
For ex:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tut="http://tutorial.com">
<soapenv:Header/>
<soapenv:Body>
<tut:sayHello>
<tut:name>
<![CDATA[
<Details>
<FirstName>Harbeer</FirstName>
<LastName>Kadian</LastName>
<Details>
]]>
</tut:name>
</tut:sayHello>
</soapenv:Body>
</soapenv:Envelope>

The information inside CDATA will be used to create another soap message. The server will create the another soap message and will use it to invoke another
web service which may exist on some other server.

The problem here is that the xsd for xml given in CDATA is not known to the client.
Now I need my server to pass this information to the client. The server has the required xsd for the xml inside CDATA.
The communication between client and server is through java web service.

Please tell how we can pass this information to the client.

With Regards
Harbeer kadian
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The problem here is that the xsd for xml given in CDATA is not known to the client.



What does the client know?

How is the client generating the initial request?

Based on my experience, sending XML inside CDATA is a very bad design and has the potential for causing all sorts of problems. Perhaps it is time to rethink the design.

Bill
 
Sheriff
Posts: 28371
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the relationship between "a web service" and "my server"? And is the "client" a client of your server and of the web service, or only a client of one of them?
 
harbeer kadian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will be some thing like this:

The client will invoke an operation on the server web service (Some thing like getInuputMessageStructureForOperation()).
The client will pass the name of wsdl with which he wants to communicate.
The server web service here is acting as a transportation layer, which intercepts client soap messages, and after reading the
information inside soap message, create another soap message and parses the appropriate wsdl file to know what is the valid
input xml structure required to invoke an operation.
In my case Apache ServiceMix Enterprise Service Bus is acting as the server web service.
The other web service may exist on a tom cat server.

The ServiceMix has the wsdl to talk to the webservice existing on the tom cat server.
Now I am thinking some thing like this, tell me if it has flaws
The serviceMix will parse the wsdl, when the client will invoke the method getInuputMessageStructureForOperation() in which client
will pass the name of operation and the name of wsdl.

Now I have to parse the wsdl and have to send the input message structure(which is defined as xsd) back to the client.
For ex:

<schema elementFormDefault="qualified" targetNamespace="http://tutorial.com" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="sayHello">
<complexType>
<sequence>
<element name="name" type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
<wsdl:message name="sayHelloRequest">
<wsdl:part element="impl:sayHello" name="parameters"/>
</wsdl:message
<wsdl:operation name="sayHello">
<wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest"/>
<wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse"/>
</wsdl:operation>

So that next time when he want to invoke that operation, he can use the xsd input message structure to create valid xml.

As the server web service is independent of the webservice residing on tom cat.
Hence I thought that I will pass the soap message required for tom cat inside a xml tag defined for server web service.
Some thing like content tag.
So that at server web service, i will invoke getContent() method which will give me an xml.
Change the xml to a soap message and communicate it to the web service on tom cat.

As i have never done this type of programming, hence I have no clue regarding how to send the xsd structure back to the client.
Please help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic