user2310909
user2310909

Reputation: 116

How to change the result name of web service method in .NET C#

I have a WebMethod that returns an XmlDocument:

    [WebMethod(Description =
        "Bla, bla"
     ), SoapDocumentMethod(ResponseElementName = "TestResponse")] 
    public  XmlDocument Service1(XmlDocument MsgIn) 
    {
        XmlDocument xmlDocument = new XmlDocument();
        ...

        return xmlDocument;
    }

and I got this response:

  <s:element name="TestResponse">
    <s:complexType>
      <s:sequence>
        <s:element name="Service1Result">
          <s:complexType mixed="true">
            <s:choice maxOccurs="unbounded" minOccurs="0">
              <s:any processContents="lax"/>
            </s:choice>
          </s:complexType>
        </s:element>
      </s:sequence>
    </s:complexType>
  </s:element>

How can I change the Service1Result name to some other specific name.

Thanks

Upvotes: 1

Views: 1261

Answers (1)

user2310909
user2310909

Reputation: 116

Solved, with this line of code:

[return: System.Xml.Serialization.XmlElementAttribute("MySpecificMethodName")]

public S050ResponseMensSalida S050(XmlDocument MsgIn) { ... }

Upvotes: 2

Related Questions