ASA 9.0.2 I have a Web Service that exposes an XML result set, my problem is that I want complete control over the XML generated, and Sybase keeps wrapping a <root> element around my result. I already have a root element by another name (other than 'root'). How can I stop the addition of this 'root' node?
Example of my result set: <Settings> <SettingOne>SettingValue</SettingOne> </Settings>
Sybase is adding <root></root> tags around that result, I need to remove/suppress/prevent this ..
asked 06 Dec '11, 12:02
The design of the web service type 'XML' is to:
There is currently no plans to change this behaviour.
You have two options:
Type 'RAW' web services will return to the client exactly the output from the SQL procedure with no additional text added. E.g.
CREATE SERVICE "MyGroup/GetSettings" TYPE 'RAW' AUTHORIZATION ON USER DBA AS CALL sp_GetSettings(; CREATE PROCEDURE sp_GetSettings() RESULT ( rawdoc long varchar ) BEGIN SELECT XMLELEMENT(NAME "Settings", XMLELEMENT(NAME "SettingOne", 1)) FROM DUMMY; END;
Note that the sp_GetSettings procedure declares its result set as a long varchar. Since the output is a character type the web service call will automatically do character set conversion between the database character set and the client character set as needed. If you don't want this character set conversion to occur you need to either:
Are you looking for the '@mp:xmltext' property to get a subtree of the XML document in XML form?
SELECT * FROM openxml( '<root><Settings> <SettingOne>SettingValue</SettingOne> </Settings></root>', '//*' ) WITH (ID int '@mp:id', parent int '../@mp:id', name char(128) '@mp:localname', othertext XML '@mp:xmltext' ) ORDER BY ID;
Produces these results in DBISQL's results window (cut-and-pasted):
ID,parent,name,othertext 5,,'root',<root><Settings> <SettingOne>SettingValue</SettingOne> </Settings></root> 15,5,'Settings',<Settings> <SettingOne>SettingValue</SettingOne> </Settings> 28,15,'SettingOne',<SettingOne>SettingValue</SettingOne>
answered 06 Dec '11, 14:05