ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » WAS Web Service mangling tags.

Post new topic  Reply to topic
 WAS Web Service mangling tags. « View previous topic :: View next topic » 
Author Message
stephendl
PostPosted: Tue Jul 26, 2005 7:17 am    Post subject: WAS Web Service mangling tags. Reply with quote

Newbie

Joined: 26 Jul 2005
Posts: 7

Hi all,

Followed on from http://www.mqseries.net/phpBB2/viewtopic.php?t=23384

I have a session bean method that reads data from a database, looked up from an ID. It creates the result as an XML string, eg.

public String getMyInfoAsXML(String ID);

I have then turned this method into a web service using the WSAD wizard - Right Click the Session bean -> Web Services -> Deploy as Web Service (or similar, can't remember exactly what I did).

The Web Service works, but the data that is being returned in the payload of the response message is being parsed so that < becomes &lt; and > becomes &gt; which is not what I am looking for (I want it to be proper XML tags).

I'm getting this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><getMyDataResponse xmlns="http://test"><getMyDataReturn>&lt;DATA&gt;
&lt;SUBDATA1&gt;325442004&lt;/SUBDATA1&gt;
        &lt;SUBDATA2&gt;
                &lt;SUBSUBDATA2 id="858811000001104"&gt;
                        &lt;TEXT&gt;Some Info&lt;/TEXT&gt;
                &lt;/SUBSUBDATA2&gt;
        &lt;/SUBDATA2&gt;
&lt;/DATA&gt;</getDrugDataForSnomedReturn></getDrugDataForSnomedResponse></soapenv:Body></soapenv:Envelope>


When I'd really very much like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><getMyDataResponse xmlns="http://test"><getMyDataReturn><DATA>
        <SUBDATA1>325442004</SUBDATA1>
        <SUBDATA2>
                <SUBSUBDATA2 id="858811000001104">
                        <TEXT>Some Info</TEXT>
                </SUBSUBDATA2>
        </SUBDATA2>
</DATA></getMyDataReturn></getMyDataResponse></soapenv:Body></soapenv:Envelope>


Any ideas?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jul 26, 2005 7:27 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I think there's a reason most people don't use the wizards to build production code...

My guess is that it's being done the way it is because the wizard doesn't know that your String returned data is supposed to be XML - so it's escaping the entities.

What happens if you change the method to return a parsed XML document object instead of a flattened string? You'd have to regenerate the web service...
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
stephendl
PostPosted: Fri Jul 29, 2005 12:56 am    Post subject: Reply with quote

Newbie

Joined: 26 Jul 2005
Posts: 7

Jeff

I agree wholly. I think that because the Web Service reply is namespaced, all of the elements in the message must be namespaced. This (I believe) would be done if the session bean returned an XML document rather than a string.

I will try it in the future (when I have time) but I have a workaround at the moment, and as the web service is used by other applications that don't seem to have a problem there is no priority. When I do I'll post a little follow-up.

Cheers for the advice.
Back to top
View user's profile Send private message
JLRowe
PostPosted: Mon Aug 01, 2005 2:57 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

The reason is that you are returning a string containing XML, the XML string is all escaped out (&lt; etc etc) so that it is parsed as a string and not more XML.

Look up some JAX-RPC tutorials on how to return a SOAPElement from the session bean.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » WAS Web Service mangling tags.
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.