ALFA
ALFA

Reputation: 285

SOAP Web service custom soap xml response

This is my XML response soap (WS in c# ".asmx") :

<?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>
        <TestrequestResponse xmlns="http://tempuri.org/">
            <TestrequestResult>
                <name>filename.xml</name>
                <code>30</code>
            </TestrequestResult>
        </TestrequestResponse>
    </soap:Body>
</soap:Envelope>

I want to have a response like this :

<?xml version="1.0" encoding="utf-8"?>
    <Response result=”KO”>
		<name>filename.xml</name>
		<code>30</code>
    </Response>

how can I do this?

Thank you very much for your help.

edit :

   [WebMethod]
        public Response Testrequest()
        {
            var r = new Response();
            r.name = "30";
            r.code = "0";

            return r;
        }

object response :

 public class Response
    {
        public string name { get; set; }
        public string code { get; set; }
        
        
    }

Upvotes: 0

Views: 3232

Answers (1)

Dexion
Dexion

Reputation: 1101

You may do SOAP message formatting ( https://msdn.microsoft.com/en-us/library/dkwy2d72%28v=vs.100%29.aspx ), but creating a simple web page returning the desired format instead of calling a SOAP service is easier.

Upvotes: 1

Related Questions