相关文章推荐
憨厚的烈酒  ·  golang处理json转义符 ...·  1 年前    · 
追风的斑马  ·  iOS NSLog ...·  2 年前    · 
逃课的风衣  ·  php reset array index ...·  2 年前    · 

C# Web Service - Removing <method + result> element in SOAP response

1 This is my first time coding a web service in .NET and ran into a slight snag that I was hoping that anyone could help me out on. I'm using the generic Hello World web service that is stubbed out on a new web service project since it can convey what I would like to do in the smallest amount of code.

I've figured out how to change the <HelloWorldResponse> to a different element name by using the SoapDocumentMethod parameters, but I can't find any information on removing the <HelloWorldResult> element.

Web Method:
Expand | Select | Wrap | Line Numbers
  1. [SoapDocumentMethod(ResponseElementName="response")]
  2. [WebMethod]
  3. public string HelloWorld()
  4. return "Hello World";
  5. Request:
    Expand | Select | Wrap | Line Numbers
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    3. <soap:Body>
    4. <HelloWorld xmlns="http://tempuri.org/" />
    5. </soap:Body>
    6. </soap:Envelope>
    Response:
    Expand | Select | Wrap | Line Numbers
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    3. <soap:Body>
    4. <response xmlns="http://tempuri.org/">
    5. <HelloWorldResult>Hello world!</HelloWorldResult>
    6. </response>
    7. </soap:Body>
    8. </soap:Envelope>
    What I would like to do:

    Expand | Select | Wrap | Line Numbers
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    3. <soap:Body>
    4. <response xmlns="http://tempuri.org/">
    5. Hello world!
    6. </response>
    7. </soap:Body>
    8. </soap:Envelope>
    Thanks for your time! # 1
0 1878
Message
Cancel Changes

Sign in to post your reply or Sign up for a free account.