Link to home
Start Free TrialLog in
Avatar of ktmedlin
ktmedlin

asked on

Web service method return JSON text without XML tags

How can I create a webmethod in a web service that returns only text without the XML?  

Here is my code:
public class Services : System.Web.Services.WebService {
    [WebMethod]
    public string Sample()  {
        return "I want only text.";
    }

Current Result:
<?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="http://tempuri.org/">I want only text.</string>

Desired Result:
"I want only text."

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of tculler
tculler
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ktmedlin
ktmedlin

ASKER

Well since ASP.Net web services use SOAP I guess the only way to get a valid JSON string is to strip out the XML as you suggested.  Thanks.