Determin How WebService method was invoked

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    Determin How WebService method was invoked

    Hi there,

    Is it possible to tell how a WebMethod was invoked? For example I would
    like to determin if it was invoked via SOAP or HTTP Post. Other than
    creating 2 methods I am no sure if I can do this.

    Many thanks for your time.

    Nick.


  • Phill W.

    #2
    Re: Determin How WebService method was invoked

    Nick wrote:
    Is it possible to tell how a WebMethod was invoked? For example I would
    like to determine if it was invoked via SOAP or HTTP Post.
    I've no idea how to do this but I'm curious - why would need to know this?

    Regards,
    Phill W.

    Comment

    • parez

      #3
      Re: Determin How WebService method was invoked

      On Jun 17, 6:51 am, "Nick" <a...@a.comwrot e:
      Hi there,
      >
      Is it possible to tell how a WebMethod was invoked? For example I would
      like to determin if it was invoked via SOAP or HTTP Post. Other than
      creating 2 methods I am no sure if I can do this.
      >
      Many thanks for your time.
      >
      Nick.
      Since its a web application, i would first try

      HttpContext.Cur rent.Request.Ht tpMethod

      Comment

      • Nick

        #4
        Re: Determin How WebService method was invoked

        Hi Phil,

        Well basically I'm creating an API that reacts differently depending how
        it is invoked. For example, if invoked via SOAP within a client based
        application I want to return some verbose XML data, but if invoked via HTTP
        Post I would like to respond by redirecting to different URLS with limited
        return value information. The idea behind this is that it won't mean that
        the Post based calls won't have to parse loads of XML data.

        That's the theory anyway.

        Nick.

        "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
        news:g3893c$1me $2@south.jnrs.j a.net...
        Nick wrote:
        >
        >Is it possible to tell how a WebMethod was invoked? For example I would
        >like to determine if it was invoked via SOAP or HTTP Post.
        >
        I've no idea how to do this but I'm curious - why would need to know this?
        >
        Regards,
        Phill W.

        Comment

        • Nick

          #5
          Re: Determin How WebService method was invoked

          Hi Parez,

          Thanks for the help, unfortunately that only seems to return GET, POST
          or HEAD, so SOAP requests return POST. Unfortunately I need to know if it's
          a SOAP request.

          Maybe I'm misunderstandin g something which is quite possible...

          Nick.

          "parez" <psawant@gmail. comwrote in message
          news:2e93c713-1506-44b3-8e23-0de98f9f61ca@x4 1g2000hsb.googl egroups.com...
          On Jun 17, 6:51 am, "Nick" <a...@a.comwrot e:
          >Hi there,
          >>
          > Is it possible to tell how a WebMethod was invoked? For example I
          >would
          >like to determin if it was invoked via SOAP or HTTP Post. Other than
          >creating 2 methods I am no sure if I can do this.
          >>
          > Many thanks for your time.
          >>
          >Nick.
          >
          Since its a web application, i would first try
          >
          HttpContext.Cur rent.Request.Ht tpMethod

          Comment

          • Nick

            #6
            Re: Determin How WebService method was invoked

            Ahhaa got it...

            If (Not
            String.IsNullOr Empty(HttpConte xt.Current.Requ est.Headers.Ite m("SOAPAction") ))
            Then
            '//It was a SOAP request
            Else
            '//It wasn't a SOAP request
            End If

            excellent, thanks for your time peeps.

            "Nick" <a@a.comwrote in message
            news:OAmKxSH0IH A.4676@TK2MSFTN GP05.phx.gbl...
            Hi Parez,
            >
            Thanks for the help, unfortunately that only seems to return GET, POST
            or HEAD, so SOAP requests return POST. Unfortunately I need to know if
            it's a SOAP request.
            >
            Maybe I'm misunderstandin g something which is quite possible...
            >
            Nick.
            >
            "parez" <psawant@gmail. comwrote in message
            news:2e93c713-1506-44b3-8e23-0de98f9f61ca@x4 1g2000hsb.googl egroups.com...
            >On Jun 17, 6:51 am, "Nick" <a...@a.comwrot e:
            >>Hi there,
            >>>
            >> Is it possible to tell how a WebMethod was invoked? For example I
            >>would
            >>like to determin if it was invoked via SOAP or HTTP Post. Other than
            >>creating 2 methods I am no sure if I can do this.
            >>>
            >> Many thanks for your time.
            >>>
            >>Nick.
            >>
            >Since its a web application, i would first try
            >>
            >HttpContext.Cu rrent.Request.H ttpMethod
            >
            >

            Comment

            • Steven Cheng [MSFT]

              #7
              Re: Determin How WebService method was invoked

              Hi Nick,

              Generally both http post and SOAP based webservice invoking are over http
              POST protocol. And after the requests arrive at ASP.NET side, different
              kind of requewst( http get/post or SOAP are handled by different webservice
              handler).

              But I think your solution on using the "SoapAction " header is really smart
              :)

              Regards,


              Sincerely,

              Steven Cheng
              Microsoft MSDN Online Support Lead


              Delighting our customers is our #1 priority. We welcome your comments and
              suggestions about how we can improve the support we provide to you. Please
              feel free to let my manager know what you think of the level of service
              provided. You can send feedback directly to my manager at:
              msdnmg@microsof t.com.

              --------------------
              >From: "Nick" <a@a.com>
              >References: <#ORQlgG0IHA.48 16@TK2MSFTNGP03 .phx.gbl>
              <2e93c713-1506-44b3-8e23-0de98f9f61ca@x4 1g2000hsb.googl egroups.com>
              <OAmKxSH0IHA.46 76@TK2MSFTNGP05 .phx.gbl>
              >Subject: Re: Determin How WebService method was invoked
              >Date: Tue, 17 Jun 2008 13:25:53 +0100
              >
              >Ahhaa got it...
              >
              >If (Not
              >String.IsNullO rEmpty(HttpCont ext.Current.Req uest.Headers.It em("SOAPAction" )
              ))
              >Then
              '//It was a SOAP request
              >Else
              '//It wasn't a SOAP request
              >End If
              >
              >excellent, thanks for your time peeps.
              >
              >"Nick" <a@a.comwrote in message
              >news:OAmKxSH0I HA.4676@TK2MSFT NGP05.phx.gbl.. .
              >Hi Parez,
              >>
              > Thanks for the help, unfortunately that only seems to return GET,
              POST
              >or HEAD, so SOAP requests return POST. Unfortunately I need to know if
              >it's a SOAP request.
              >>
              > Maybe I'm misunderstandin g something which is quite possible...
              >>
              >Nick.
              >>
              >"parez" <psawant@gmail. comwrote in message
              >news:2e93c71 3-1506-44b3-8e23-0de98f9f61ca@x4 1g2000hsb.googl egroups.com...
              >>On Jun 17, 6:51 am, "Nick" <a...@a.comwrot e:
              >>>Hi there,
              >>>>
              >>> Is it possible to tell how a WebMethod was invoked? For example I
              >>>would
              >>>like to determin if it was invoked via SOAP or HTTP Post. Other than
              >>>creating 2 methods I am no sure if I can do this.
              >>>>
              >>> Many thanks for your time.
              >>>>
              >>>Nick.
              >>>
              >>Since its a web application, i would first try
              >>>
              >>HttpContext.C urrent.Request. HttpMethod
              >>
              >>
              >
              >
              >

              Comment

              • Nick

                #8
                Re: Determin How WebService method was invoked

                Hi Steven

                Cheers for the information that's really helpful, it makes sense why it
                was always Post now :)

                Thanks.

                Nick.

                "Steven Cheng [MSFT]" <stcheng@online .microsoft.comw rote in message
                news:Pvc8TnQ0IH A.3956@TK2MSFTN GHUB02.phx.gbl. ..
                Hi Nick,
                >
                Generally both http post and SOAP based webservice invoking are over http
                POST protocol. And after the requests arrive at ASP.NET side, different
                kind of requewst( http get/post or SOAP are handled by different
                webservice
                handler).
                >
                But I think your solution on using the "SoapAction " header is really smart
                :)
                >
                Regards,
                >
                >
                Sincerely,
                >
                Steven Cheng
                Microsoft MSDN Online Support Lead
                >
                >
                Delighting our customers is our #1 priority. We welcome your comments and
                suggestions about how we can improve the support we provide to you. Please
                feel free to let my manager know what you think of the level of service
                provided. You can send feedback directly to my manager at:
                msdnmg@microsof t.com.
                >
                --------------------
                >>From: "Nick" <a@a.com>
                >>References: <#ORQlgG0IHA.48 16@TK2MSFTNGP03 .phx.gbl>
                <2e93c713-1506-44b3-8e23-0de98f9f61ca@x4 1g2000hsb.googl egroups.com>
                <OAmKxSH0IHA.46 76@TK2MSFTNGP05 .phx.gbl>
                >>Subject: Re: Determin How WebService method was invoked
                >>Date: Tue, 17 Jun 2008 13:25:53 +0100
                >
                >>
                >>Ahhaa got it...
                >>
                >>If (Not
                >>String.IsNull OrEmpty(HttpCon text.Current.Re quest.Headers.I tem("SOAPAction ")
                ))
                >>Then
                > '//It was a SOAP request
                >>Else
                > '//It wasn't a SOAP request
                >>End If
                >>
                >>excellent, thanks for your time peeps.
                >>
                >>"Nick" <a@a.comwrote in message
                >>news:OAmKxSH0 IHA.4676@TK2MSF TNGP05.phx.gbl. ..
                >>Hi Parez,
                >>>
                >> Thanks for the help, unfortunately that only seems to return GET,
                POST
                >>or HEAD, so SOAP requests return POST. Unfortunately I need to know if
                >>it's a SOAP request.
                >>>
                >> Maybe I'm misunderstandin g something which is quite possible...
                >>>
                >>Nick.
                >>>
                >>"parez" <psawant@gmail. comwrote in message
                >>news:2e93c7 13-1506-44b3-8e23-0de98f9f61ca@x4 1g2000hsb.googl egroups.com...
                >>>On Jun 17, 6:51 am, "Nick" <a...@a.comwrot e:
                >>>>Hi there,
                >>>>>
                >>>> Is it possible to tell how a WebMethod was invoked? For example I
                >>>>would
                >>>>like to determin if it was invoked via SOAP or HTTP Post. Other than
                >>>>creating 2 methods I am no sure if I can do this.
                >>>>>
                >>>> Many thanks for your time.
                >>>>>
                >>>>Nick.
                >>>>
                >>>Since its a web application, i would first try
                >>>>
                >>>HttpContext. Current.Request .HttpMethod
                >>>
                >>>
                >>
                >>
                >>
                >

                Comment

                Working...