0

When creating a web method in an ASMX file of a C# web application, the associated WSDL is of this format:

<Envelope>
  <Header/>
  <Body>
    <WebMethodName>
      <WebMethodArgumentName>
        <WebMethodArgumentType>

I need to have it like this:

<Envelope>
  <Header/>
  <Body>
    <WebMethodName>
      <WebMethodArgumentType>

Or like this:

<Envelope>
  <Header/>
  <Body>
    <WebMethodArgumentName>
      <WebMethodArgumentType>

This is because the client sends the request in that format, so I need to control the name of the outer tag, and the only way I can think of is by changing the name of the web method or the web method argument, but in order to do that, I need to have only one of those tags.

By the way, I am generating the code with svcutil.exe (wsdl.exe produces the same result) like this:

svcutil /language:C# /out:IWebServiceName.cs /n:*,Web.Service.Namespace ^
..\XSD\SomeXsd.xsd ^
..\XSD\AnotherXsd.xsd ^
..\WSDL\TheWsdl.wsdl

How can I accomplish this?

Thanks!

  • 1
    Is your client working against a WSDL? Can you get a copy? Then you can [generate the code](http://stackoverflow.com/questions/548314/create-an-asmx-web-service-from-a-wsdl-file) from the WSDL instead of having to eyeball it like this. – John Wu Mar 25 '17 at 00:32
  • Thank you John. Yes, I have a WSDL and I have used both, svcutil.exe and wsdl.exe to generate the code. – Guillermo Alejandro Mar 25 '17 at 14:04

1 Answers1

1

It's been a while since I asked this question, but finally got the anwser: decorate the web method with an annotation like this:

[SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]

According to the docs, there are three members of the enumeration:

Bare, Default, Wrapped

Wrapped is the default, which encapsulates the parameters.

I was looking for Bare, which places the parameters directly following the Body element of a SOAP request or SOAP response.

Hope it helps to someone dealing with this problem like I Was.