Pergunta

I've created an ASMX web service, which works fine, however, the sample soap generated has the name of the web method as the root node of the soap body.

The company consuming my web service want to have the parameter(s) as children of the soap body instead.

So, instead of having the output:

<?xml version="1.0" encoding="utf-8"?>
<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/">
  <soap:Body>
    <My_Web_Method xmlns="http://tempuri.org/">
      <My_Class>
          <Address>
            <AddrLine>string</AddrLine>
            <Suburb>string</Suburb>
            <PostCode>string</PostCode>
            <State>string</State>
            <StreetNumber>string</StreetNumber>
            <StreetName>string</StreetName>
            <StreetType>string</StreetType>
          </Address>
      </My_Class>
    </My_Web_Method>
  </soap:Body>
</soap:Envelope>

They want the output:

<?xml version="1.0" encoding="utf-8"?>
<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/">
  <soap:Body>
      <My_Class>
          <Address>
            <AddrLine>string</AddrLine>
            <Suburb>string</Suburb>
            <PostCode>string</PostCode>
            <State>string</State>
            <StreetNumber>string</StreetNumber>
            <StreetName>string</StreetName>
            <StreetType>string</StreetType>
          </Address>
      </My_Class>
  </soap:Body>
</soap:Envelope>

My guess is that it is probably invalid to have more than 1 node as a child of the soap body (which is possible if I had more than 1 input parameter), which is why Microsoft are automatically generating it the way they do. I guess I just need confirmation that this is the case. If not, a solution would be great.

Foi útil?

Solução

I found the answer - it was to use the following decoration on my web method:

<SoapDocumentMethod(ParameterStyle:=SoapParameterStyle.Bare)>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top