sending soap over http

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

    sending soap over http

    i have a very simple web servive

    Imports System.Web.Serv ices

    <System.Web.Ser vices.WebServic e(Namespace:="u rn:Example1")> _

    Public Class Example1

    Inherits System.Web.Serv ices.WebService




    <WebMethod()> _

    Public Function HelloWorld(ByVa l name As String) As String

    Return "Hello " & name

    End Function

    End Class



    I have a VB Script with which I'm trying to send a soap message with. When
    i execute i get to the input soap message message box showing me the
    message, but when i click ok, it seems to hang. i have to kill the script
    through taskmgr. this is on windows 2000.

    Any ideas why it wouldn't return?





    Dim x, h
    Set x = CreateObject("M SXML2.DOMDocume nt")
    x.loadXML "<s:Envelop e xmlns:s='http://schemas.xmlsoap .org/soap/envelope/'
    xmlns:xsi='http ://www.w3.org/1999/XMLSchema-instance'
    xmlns:xsd='http ://www.w3.org/1999/XMLSchema'><s:B ody><m:sayHello
    xmlns:m='urn:Ex ample1'><name
    xsi:type='xsd:s tring'>James</name></m:sayHello></s:Body></s:Envelope>"

    msgbox x.xml, , "Input SOAP Message"
    Set h = CreateObject("M icrosoft.XMLHTT P")
    h.open "POST", "http://localhost/HelloWorld/Service1.asmx"
    h.send (x)
    while h.readyState <> 4
    wend
    msgbox h.responseText, ,"Output SOAP Message"



  • Mark

    #2
    Re: sending soap over http

    Correction:

    I had to change the word sayHello to Helloworld, since that is my method
    name.

    Dim x, h,r, s, t, u, v,z

    Set x = CreateObject("M SXML2.DOMDocume nt")

    s ="<s:Envelop e xmlns:s='http://schemas.xmlsoap .org/soap/envelope/'"
    t = " xmlns:xsi='http ://www.w3.org/1999/XMLSchema-instance'"
    u = " xmlns:xsd='http ://www.w3.org/1999/XMLSchema'>"
    v = " <s:Body><m:Hell oWorld xmlns:m='urn:Ex ample1'>"
    r = " <name
    xsi:type='xsd:s tring'>James</name></m:HelloWorld></s:Body></s:Envelope>"

    z= s & t & u & v & r

    x.loadXML z
    msgbox x.xml, , "Input SOAP Message"
    Set h = CreateObject("M icrosoft.XMLHTT P")
    h.open "POST", "http://localhost/HelloWorld/Service1.asmx"
    h.send (x)
    while h.readyState <> 4
    wend
    msgbox h.responseText, ,"Output SOAP Message"


    "Mark" <mark_kurten@ac ordia.com> wrote in message
    news:ed28Ui9BFH A.2428@TK2MSFTN GP14.phx.gbl...[color=blue]
    > i have a very simple web servive
    >
    > Imports System.Web.Serv ices
    >
    > <System.Web.Ser vices.WebServic e(Namespace:="u rn:Example1")> _
    >
    > Public Class Example1
    >
    > Inherits System.Web.Serv ices.WebService
    >
    >
    >
    >
    > <WebMethod()> _
    >
    > Public Function HelloWorld(ByVa l name As String) As String
    >
    > Return "Hello " & name
    >
    > End Function
    >
    > End Class
    >
    >
    >
    > I have a VB Script with which I'm trying to send a soap message with.[/color]
    When[color=blue]
    > i execute i get to the input soap message message box showing me the
    > message, but when i click ok, it seems to hang. i have to kill the script
    > through taskmgr. this is on windows 2000.
    >
    > Any ideas why it wouldn't return?
    >
    >
    >
    >
    >
    > Dim x, h
    > Set x = CreateObject("M SXML2.DOMDocume nt")
    > x.loadXML "<s:Envelop e xmlns:s='http://schemas.xmlsoap .org/soap/envelope/'
    > xmlns:xsi='http ://www.w3.org/1999/XMLSchema-instance'
    > xmlns:xsd='http ://www.w3.org/1999/XMLSchema'><s:B ody><m:sayHello
    > xmlns:m='urn:Ex ample1'><name
    > xsi:type='xsd:s tring'>James</name></m:sayHello></s:Body></s:Envelope>"
    >
    > msgbox x.xml, , "Input SOAP Message"
    > Set h = CreateObject("M icrosoft.XMLHTT P")
    > h.open "POST", "http://localhost/HelloWorld/Service1.asmx"
    > h.send (x)
    > while h.readyState <> 4
    > wend
    > msgbox h.responseText, ,"Output SOAP Message"
    >
    >
    >[/color]


    Comment

    • Mark

      #3
      Re: sending soap over http

      I'm getting close.. It appears something is wrong with my soap message
      itself. I'm using the
      HttpWebRequest and HttpWebResponse objects to send/receive this data.
      Any help would be much appreciated.

      -----------------------------------------------------------------
      I have a string which contains the following data.

      "<s:Envelop e xmlns:s='http://schemas.xmlsoap .org/soap/envelope/'
      xmlns:xsi='http ://www.w3.org/1999/XMLSchema-instance'
      xmlns:xsd='http ://www.w3.org/1999/XMLSchema'>
      <s:Body><m:Hell oWorld xmlns:m='urn:Ex ample1'>
      <name
      xsi:type='xsd:s tring'>James</name></m:HelloWorld></s:Body></s:Envelope>"

      -----------------------------------------------------------------
      The web service i'm sending this to is

      Imports System.Web.Serv ices

      <System.Web.Ser vices.WebServic e(Namespace:="u rn:Example1")> _

      Public Class Example1

      Inherits System.Web.Serv ices.WebService

      <WebMethod()> _

      Public Function HelloWorld(ByVa l name As String) As String

      Return "Hello " & name

      End Function

      End Class

      -----------------------------------------------------------------
      The error I'm getting is


      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelop e xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
      xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <soap:Fault>
      <faultcode>soap :Client</faultcode>
      <faultstring>Un able to handle request without a valid action
      parameter. Please supply a valid soap action.</faultstring>
      <detail />
      </soap:Fault>
      </soap:Body>
      </soap:Envelope>


      Comment

      • Martin Honnen

        #4
        Re: sending soap over http



        Mark wrote:
        [color=blue]
        > It appears something is wrong with my soap message
        > itself. I'm using the
        > HttpWebRequest and HttpWebResponse objects to send/receive this data.[/color]

        Why? If you are using .NET (as HttpWebRequest suggests) then simply
        create a proxy class to use the web service, .NET has a tool called
        wsdl.exe to do exactly that to avoid anyone having to deal with SOAP
        itself (which is complex). The wsdl.exe tool reads the WSDL file
        describing the web service and generates .NET source code for a proxy
        class which you can compile and then include in your .NET project to
        easily access the web service transparently calling methods on the proxy
        without ever dealing with SOAP.

        As for your earlier message that looked like you were using VBScript,
        even there MS has a toolkit named SOAP toolkit that helps you with
        accessing web services without the need to construct the raw SOAP from
        hand. Look on http://msdn.microsoft.com/ for SOAP toolkit, download it
        and check the examples on how to build a SOAP client with script.


        [color=blue]
        > The error I'm getting is
        >
        >
        > <?xml version="1.0" encoding="utf-8"?>
        > <soap:Envelop e xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
        > xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
        > xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
        > <soap:Body>
        > <soap:Fault>
        > <faultcode>soap :Client</faultcode>
        > <faultstring>Un able to handle request without a valid action
        > parameter. Please supply a valid soap action.</faultstring>
        > <detail />
        > </soap:Fault>
        > </soap:Body>
        > </soap:Envelope>[/color]

        Well SOAP over HTTP needs a custom HTTP header named SOAPAction which
        (untested and written from memory) needs to be alike

        SOAPAction: urn:Example1/HelloWorld

        for your web service so if you really want to use HttpWebRequest or
        Msmxl2.XMLHTTP to access a web service then you need to make sure you
        set that HTTP header (not SOAP header!) before sending your request.

        But as said, there are tools with both COM based application (like VB or
        VBScript or JScript) and .NET to free you from thinking about that
        stuff, you simply call a method and get a result in the language of your
        choice and the whole SOAP creation and parsing is done by the tools
        reading the WSDL description of the web service.



        --

        Martin Honnen

        Comment

        • Mark

          #5
          Re: sending soap over http

          That is part of my problem and why I am lost.

          I've been told by the folks that developed this web service that they are
          not using WSDL.
          I've used the soap toolkit in the past with VB 6.0 and it was very easy.

          I was told i had to generate these "raw" soap message to send to this
          service. I spoke with another person yesterday who sent data to this
          service and they stated that they wrote out the xml doc line by line in code
          and then sent it.

          That is why i'm trying to understand how to write a soap message manually.

          thank you for the suggestions.


          "Martin Honnen" <mahotrash@yaho o.de> wrote in message
          news:udpTJrICFH A.3936@TK2MSFTN GP09.phx.gbl...[color=blue]
          >
          >
          > Mark wrote:
          >[color=green]
          > > It appears something is wrong with my soap message
          > > itself. I'm using the
          > > HttpWebRequest and HttpWebResponse objects to send/receive this data.[/color]
          >
          > Why? If you are using .NET (as HttpWebRequest suggests) then simply
          > create a proxy class to use the web service, .NET has a tool called
          > wsdl.exe to do exactly that to avoid anyone having to deal with SOAP
          > itself (which is complex). The wsdl.exe tool reads the WSDL file
          > describing the web service and generates .NET source code for a proxy
          > class which you can compile and then include in your .NET project to
          > easily access the web service transparently calling methods on the proxy
          > without ever dealing with SOAP.
          >
          > As for your earlier message that looked like you were using VBScript,
          > even there MS has a toolkit named SOAP toolkit that helps you with
          > accessing web services without the need to construct the raw SOAP from
          > hand. Look on http://msdn.microsoft.com/ for SOAP toolkit, download it
          > and check the examples on how to build a SOAP client with script.
          >
          >
          >[color=green]
          > > The error I'm getting is
          > >
          > >
          > > <?xml version="1.0" encoding="utf-8"?>
          > > <soap:Envelop e xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
          > > xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
          > > xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
          > > <soap:Body>
          > > <soap:Fault>
          > > <faultcode>soap :Client</faultcode>
          > > <faultstring>Un able to handle request without a valid action
          > > parameter. Please supply a valid soap action.</faultstring>
          > > <detail />
          > > </soap:Fault>
          > > </soap:Body>
          > > </soap:Envelope>[/color]
          >
          > Well SOAP over HTTP needs a custom HTTP header named SOAPAction which
          > (untested and written from memory) needs to be alike
          >
          > SOAPAction: urn:Example1/HelloWorld
          >
          > for your web service so if you really want to use HttpWebRequest or
          > Msmxl2.XMLHTTP to access a web service then you need to make sure you
          > set that HTTP header (not SOAP header!) before sending your request.
          >
          > But as said, there are tools with both COM based application (like VB or
          > VBScript or JScript) and .NET to free you from thinking about that
          > stuff, you simply call a method and get a result in the language of your
          > choice and the whole SOAP creation and parsing is done by the tools
          > reading the WSDL description of the web service.
          >
          >
          >
          > --
          >
          > Martin Honnen
          > http://JavaScript.FAQTs.com/[/color]


          Comment

          Working...