WebMethod is returned as a String (without the <? Xml tag)

[WebMethod(EnableSession=true)]
[ScriptMethod(UseHttpGet=true, XmlSerializeString =  false)]
public string RaiseCallbackEvent(string eventArgument)

return value started with <?xml. How can I get rid of it?

+3
source share
1 answer

I assume this does this because it is a SOAP web service and this is what is expected from a SOAP web service. If you want to return only plain text to the client, I would create ashx to handle the request manually.

Like this (these are the default default subdirectory forests)

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Test : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
+3
source

Source: https://habr.com/ru/post/1720473/


All Articles