ASMX Net String Return

I have an ASP.NET web service (.asmx). My service is defined as follows:

[System.Web.Services.WebService(Namespace = "http://tempuri.org/")]
[System.Web.Services.WebServiceBinding(ConformsTo = System.Web.Services.WsiProfiles.BasicProfile1_1)]
public class MyService : System.Web.Services.WebService
{
  [System.Web.Services.WebMethod]
  public string GetResult()
  {
    string result = "";

    int day = System.DateTime.UtcNow.Day;
    if ((day % 1) == 1)
      result = "odd";
    else
      result = "even";
    return result;
  }
}

Currently, if I call this service method, I get the following result:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">even</string>

My problem: I need to return only part of the string. I do not want to return XML wrapping. How to do it with .asmx?

Thank!

+5
source share
3 answers

To do this, you need to be a web service .asmx? I mean, excluding the SOAP envelope, you essentially say, “This is not a SOAP web service,” because why not do it even further and make it a regular page .aspxinstead of a .asmxmaintenance web site .

, , , . , Response.Headers, , Response.Write() Response.End(), .

+4

json

- -, , .

-: [ScriptService]

-: [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

+2

XML? , -, , . XML .

0

All Articles