Author |
Message
|
dotaneli |
Posted: Thu Jun 26, 2008 7:20 am Post subject: MQ Bindings (Export) - Parsing simple XMLs |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
Hey everyone.
I have created a simple MQ Example program to demonstrate the abilities of WESB regarding MQ.
The program has an interface called MQExampleInterface, which has 3 2-way operations:
opString - gets a string, returns a string
opXML - gets a string, returns XML structure of type MQExampleParentObject
opXMLFull - gets an XML (MQExampleParentObject) and returns an xml
(MQExampleParentObject)
The first 2 operations work perfect.
The 3rd one is the tricky one. When i put an MQ message, it is crucial that i specify this header:
<MQExampleParentObject xsi:type="MQExampleParentObject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://MQExample">
when i specify it, and put the following xml, the operation succeeds:
<?xml version="1.0" encoding="UTF-8"?>
<MQExampleParentObject xsi:type="MQExampleParentObject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://MQExample">
<name>eli</name>
</MQExampleParentObject>
however, when i try something like:
<?xml version="1.0" encoding="UTF-8"?>
<MQExampleParentObject>
<name>eli</name>
</MQExampleParentObject>
the parsing fails.
So i have 2 questions for you
1. How do i take a string input, already in SMO, and convert it to XML, assuming it is an XML?
2. why are the fields, besides the tag itself, required? Can't i get a simple XML structure with no schema reference? (let it use the xsd created once i created the MQExampleParentObject BO).
Any help would be appreciated.
Thanks,
Eli. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jun 26, 2008 10:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
dotaneli wrote: |
<?xml version="1.0" encoding="UTF-8"?>
<MQExampleParentObject>
<name>eli</name>
</MQExampleParentObject> |
The parsing fails because you do not have the namespaces defined.
you would need to do something like (to be taken with a grain of salt as I am no XML expert)
<?xml version="1.0" encoding="UTF-8"?>
<MQExampleParentObject xsi:type="MQExampleParentObject" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns="http://MQExample" >
<name>eli</name>
</MQExampleParentObject>
This defines the XML to be in the default namespace MQExample and defines the type of the message to be MQExampleParentObject
The rest are just namespace declarations (you can't say xsi:type without defining xsi...
Your parser is looking for something to conform to the namespace it is expecting and what you sent had no namespace definitions at all.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
dotaneli |
Posted: Sat Jun 28, 2008 10:10 pm Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
Thank you very much..
It works just fine with the name space supplied.
However it puzzles me... what happens if i don't want the consumer of the service to supply me with that namespace header? And say i do want to export it with BO and not a simple string to manipulate after wards... |
|
Back to top |
|
 |
dhilton |
Posted: Fri Aug 22, 2008 1:04 pm Post subject: |
|
|
 Newbie
Joined: 22 Aug 2008 Posts: 1 Location: Pennsylvania USA
|
Is it possible to take an XML in without the namespace being specified and have it bound to the BO automatically? |
|
Back to top |
|
 |
Paul D |
Posted: Wed Sep 10, 2008 6:44 pm Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 200 Location: Green Bay Packer Country
|
I have that same issue, an inbound XML without any namespaces and I'd like it bound to the BO automatically. Any ideas on this? Thanks!!! _________________ Thanks!!!
Paul D |
|
Back to top |
|
 |
upcominggeek |
Posted: Thu Oct 16, 2008 9:06 am Post subject: |
|
|
 Apprentice
Joined: 21 Aug 2006 Posts: 35 Location: Boston, US
|
Yes, it is possible. We have done that in our project. We removed the namespace from the BusinessObject and then WPS doesn't look for the namespace. Also, we turned off the validation for the input message while setting QoS params. |
|
Back to top |
|
 |
Paul D |
Posted: Mon Oct 20, 2008 12:55 pm Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 200 Location: Green Bay Packer Country
|
I've recieved some other guidance on this topic from IBM. I'll do some testing and report back to the thread on anything new I learn that has not been covered here yet. _________________ Thanks!!!
Paul D |
|
Back to top |
|
 |
|