Soap Message: To specify that parameters directly follow the Body element

Last post 07-06-2009 12:49 PM by _kalesh_. 3 replies.

Sort Posts:

  • Soap Message: To specify that parameters directly follow the Body element

    06-30-2009, 7:04 AM
    • Member
      462 point Member
    • _kalesh_
    • Member since 10-23-2007, 7:30 AM
    • Posts 110

    Method from Proxy class which I am calling.

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("initiate", OneWay = true,
                Use = System.Web.Services.Description.SoapBindingUse.Literal,
                ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
            public void initiate([XmlElement(Namespace = "http://xmlns.xxxx.com/whatever",
                         IsNullable=false)] XmlDocument Candidates1)
            {
                this.Invoke("initiate", new object[] { Candidates1 });
            }


    SOAP message format from fiddler :

    <soap:Envolope>
    <soap:Header>
    .....
    </soap:Header>
    <soap:Body>
    <Candidates1 xmlns="http://xmlns.xxxx.com/whatever">
    <Candidate xmlns="">
        -- XML Document nodes --
    </Candidate>
    </Candidates1>
    </soap:Body>
    </soap:Envelope>

    The problem is the <Candidates1> element. .NET is just converting the input parameter name to a xml root element in the final soap message. If I rename it to candidate2 then the xml element would be <candidate2>

    According to this msdn article here:
    http://msdn.microsoft.com/en-us/library/2b4bx2t6(VS.80,loband).aspx

    we can specify that parameters directly follow the Body element. By applying the xmlelement
    attribute  to the input parameter and setting ParameterStyle to Bare, along with setting the parameter formatting style to Literal.

    But even after appying these changes(as above), I am unable to remove the <Candidates1> element.

    Any suggestions are welcome on how to specify that parameters directly follow the body element. In my case the <Candidate> should follow the <soap:Body> element.

    Thanks.

    Aseem \../ (-_-) \./ Gautam
    "Do right and fear no man."
  • Re: Soap Message: To specify that parameters directly follow the Body element

    07-01-2009, 2:58 PM
    • Member
      462 point Member
    • _kalesh_
    • Member since 10-23-2007, 7:30 AM
    • Posts 110

    After some research I have found that SoapExtension can be used to access/modify soap message before serialization.

    Any other suggestions are also welcome.

    Aseem \../ (-_-) \./ Gautam
    "Do right and fear no man."
  • Re: Soap Message: To specify that parameters directly follow the Body element

    07-04-2009, 4:38 AM
    Answer

    Actually, if you look carefully, you'll see that you parameters do immediately follow the body. You have only one parameter, named candidate1. That parameter immediately follows the body. If it had been of type "int", you would have seen:

    <body><candidate1>1234567890</candidate1></body>

    John Saunders
  • Re: Soap Message: To specify that parameters directly follow the Body element

    07-06-2009, 12:49 PM
    • Member
      462 point Member
    • _kalesh_
    • Member since 10-23-2007, 7:30 AM
    • Posts 110

    johnwsaunders3:

    Actually, if you look carefully, you'll see that you parameters do immediately follow the body. You have only one parameter, named candidate1. That parameter immediately follows the body. If it had been of type "int", you would have seen:

    <body><candidate1>1234567890</candidate1></body>

    Ok.. yes you are right...

    I managed to implement Soap Extensions and created a new soap envelope after the serialization phase.

    Thanks

    Aseem \../ (-_-) \./ Gautam
    "Do right and fear no man."
Page 1 of 1 (4 items)