webservice method with attribute asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lunet
    New Member
    • Dec 2008
    • 1

    webservice method with attribute asp.net

    hello,

    this has been asked before but no answers yet.. I need help!

    how can write a webservice method with attribute ?

    like this xml :
    [code=xml]
    <soap:Envelop e
    xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">
    <soap:Body>
    <CalcArea xmlns="http://example.org/geometry/" unite="radian"
    floor="3">
    <length>2.3</length>
    <width>1.2</width>
    </CalcArea>
    </soap:Body>
    </soap:Envelope>
    [/code]
    what is the cs class / method for corresponding with this soap call ?
    (with "unite" and "floor" attribute !)


    thanks!
    Last edited by Frinavale; Dec 15 '08, 03:06 PM. Reason: added [code] tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Hi there,

    I don't fully understand your question.
    You have posted some SOAP which is used to transfer information between a Web Service method and a client that is consuming the web service.

    There is no cs class method that corresponds to it that I can see based on the details of your problem.

    First you need to create a Web Service application and create a web method that does whatever you need to do.

    Then you need to consume this Web Service in your application.

    Please see this article on Consuming XML Web Service for more information.

    -Frinny

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Decorate your CalcArea properties accordingly:
      VB
      Code:
      Imports System.Xml.Serialization
      Class CalcArea
       
          <SoapAttribute(), XmlAttribute()> _
          Public Property unit() as String...
       
          <SoapElement(), XmlElement()> _
          Public Property Length As Single...
       
      End Class
      C#
      Code:
      using System.Xml.Serialization;
      Class CalcArea{
       
        [SoapAttribute(), XmlAttribute()]
        public string unite() { get; set; }
       
        [SoapElement(), XmlElement()]
        public single Length() { get; set; }
       
      }

      There's a reasonably comprehensive document on the MSDN website about this:
      XML Serialization with XML Web Services

      Comment

      Working...