TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Omar Kh
NA
301
21.8k
how to return xml while using webservice?
Feb 22 2021 12:43 PM
i have created a webservice using c# asp.net as below
string ok = "<Result><ResultCode>1</ResultCode><ResultDesc>Success</ResultDesc></Result>";
[WebMethod]
public
string
GetcontsXML(
string
agent_no,
string
username,
string
password)
{
OracleConnection conn =
new
OracleConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings[
"myConnectionString"
].ConnectionString;
string
query =
"select cont,cont_code from cont where cont>0 order by cont"
;
conn.Open();
OracleCommand cmd =
new
OracleCommand(query, conn);
OracleDataAdapter oda =
new
OracleDataAdapter(query,conn);
OracleDataReader dr = cmd.ExecuteReader();
while
(dr.Read())
{
response = response +
"<Code>"
+ dr[
"cont"
].ToString() +
"</Code><Name>"
+ dr[
"cont_code"
].ToString() +
"</Name>"
;
}
return
ok+response;
}
and it retrive everything ok
<
string
xmlns
=
"http://tempuri.org/"
>
<
Result
>
<
ResultCode
>
1
</
ResultCode
>
<
ResultDesc
>
Success
</
ResultDesc
>
</
Result
>
<
Code
>
1
</
Code
>
<
Name
>
JOR
</
Name
>
<
Code
>
2
</
Code
>
<
Name
>
EGY
</
Name
>
</
string
>
but when i tried to consume this webservice
it returns the following response
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetcontsXMLResponse xmlns="http://tempuri.org/">
<GetcontsXMLResult>
<Result><ResultCode>1</ResultCode><ResultDesc>Success</ResultDesc></Result><Code>1</Code><Name>JOR</Name><Code>2</Code><Name>EGY</Name><Code>3</Code><Name>IRQ</Name><Code>4</Code><Name>AUS</Name><Code>5</Code><Name>ABW</Name><Code>6</Code><Name>AFG</Name><Code>7</Code><Name>AGO</Name><Code>8</Code><Name>AIA</Name><Code>9</Code><Name>ALB</Name><Code>10</Code><Name>AND</Name><Code>11</Code><Name>ANT</Name><Code>12</Code><
;Name>ARE</Name><Code>13</Code><Name>ARG</Name><Code>14</Code><Name>ARM</Name><Code>15</Code><Name>ASM</Name><Code>16</Code><Name>ATA</Name><Code>17</Code><Name>ATF</Name><Code>18</Code><Name>ATG</Name><Code>19</Code><Name>AUT</Name><Code>20</Code><Name>AZE</Name><Code>21</Code><Name>BDI</Name><Code>22</Code><Name>BEL</Name><Code>23</Code><Name>BEN</Name><Code>24</Code><Name>BFA</Name><Code>25</Code><Name>BGD</Name><Code>26</Code><Name>BGR</Name><Code>27</Code><Name>BHR</Name><Code>28</Code><Name>BHS</Name><Code>29</Code><Name>BIH</Name><Code>30</Code><Name>BLR</Name><Code
</GetcontsXMLResult>
</GetcontsXMLResponse>
</soap:Body>
</soap:Envelope>
i know it returns "@gt" instead of ">" and "<" instead of "<"
but i want my my response as xml not string
any help ? thanks in advanced
Reply
Answers (
3
)
Link progress bar with value in function during function execution
Use of Group by and aggregate function on given table