Professional Web Applications Themes

Consuming a web service from VB 6 - ASP.NET Web Services

Hi, I have written a web service use ASP.NET I can access i from VB 6 via XMLHTTP and everything works fine until I try to pass parameters to it. According to what doentation I can find I could pass the parameters in an XML file or as a querystring attatched to the URL. However these both return 'Invalid request' Is there something I'm missing ? Any ideas of where else I can look ? Thanks for you time Sam PS. Code sBuffer = "http://localhost/MapWS/MapService.asmx/GetMapURL" XMLhttp.open "POST", sBuffer, False XMLhttp.setRequestHeader "Content-type", "text/xml" XMLhttp.send ("C:\Coords.xml") MsgBox XMLhttp.responseText PosHTTP = InStr(XMLhttp.responseText, ">http") ...

  1. #1

    Default Consuming a web service from VB 6

    Hi,

    I have written a web service use ASP.NET
    I can access i from VB 6 via XMLHTTP and everything works
    fine until I try to pass parameters to it. According to
    what doentation I can find I could pass the parameters
    in an XML file or as a querystring attatched to the URL.
    However these both return 'Invalid request'

    Is there something I'm missing ? Any ideas of where else I
    can look ?

    Thanks for you time
    Sam

    PS. Code

    sBuffer
    = "http://localhost/MapWS/MapService.asmx/GetMapURL"

    XMLhttp.open "POST", sBuffer, False
    XMLhttp.setRequestHeader "Content-type", "text/xml"
    XMLhttp.send ("C:\Coords.xml")
    MsgBox XMLhttp.responseText

    PosHTTP = InStr(XMLhttp.responseText, ">http")

    XML File :

    <?xml version="1.0" encoding="utf-8"?>
    <GetMapURL xmlns="MaporamaWS">
    <Latitude>51.522249476571</Latitude>
    <Longitude>-0.105867806149086</Longitude>
    </GetMapURL>


    Samantha Dixon Guest

  2. #2

    Default Re: Consuming a web service from VB 6

    Unless I'm mistaken, the problem is a misunderstanding of what the Send
    method does. It sends a string. It doesn't send the contents of a
    file. So the request you're sending to the service is "C:\Coords.xml",
    which by almost any definition is a badly formatted request.

    HTH

    Bruce Johnson
    [url]http://www.ObjectSharp.com/Bruce[/url]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    BruceJohnson Guest

  3. #3

    Default Re: Consuming a web service from VB 6


    Thanks,

    Found it worked if I sent the parameters as a string
    ie. XMLHTTP.send "Longitude=-0.105867806149086&Latitude=51.522249476571"

    and changed the 'Content-type' from "text/xml" to
    "application/x-www-form-urlencoded"

    Thanks
    Sam


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Samantha Dixon Guest

  4. #4

    Default Consuming a web service from VB 6

    Hello, I hope that you have already found the solution.
    If not, here is what I do.

    Private Function Login()

    ' Determine who our user is
    ' Via AUTH
    ' Log them in that way
    '
    '

    On Error GoTo Login_Error

    Dim objXMLHeader As XMLDoent
    Dim objHTTP As MSXML2.XMLHTTP
    Dim strEnvelope As String

    Dim sUserName As String
    Dim sPassword As String

    sUserName = GetNetworkUserName
    sPassword = GetNetworkPassword(sUserName)

    Set objXMLHeader = New XMLDoent
    Set objHTTP = New MSXML2.XMLHTTP

    strEnvelope = "<?xml version='1.0' encoding='utf-8'?>"
    strEnvelope = strEnvelope & "<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/'>"
    strEnvelope = strEnvelope & " <soap:Body>"
    strEnvelope = strEnvelope & " <Login
    xmlns='https://apps.americasdoctor.com/'>"
    strEnvelope = strEnvelope & " <UserName>" &
    sUserName & "</UserName>"
    strEnvelope = strEnvelope & " <Password>" &
    sPassword & "</Password>"
    strEnvelope = strEnvelope & " </Login>"
    strEnvelope = strEnvelope & " </soap:Body>"
    strEnvelope = strEnvelope & "</soap:Envelope>"

    objHTTP.Open "POST", WebserviceLocation, False
    Call objHTTP.setRequestHeader("Content-
    Type", "text/xml")

    objHTTP.setRequestHeader "SOAPAction", "https://localhost/
    Login"
    objHTTP.send strEnvelope


    'Do While Not objHTTP.readyState = 4
    'Sleep 1
    'Loop

    Dim x As MSXML2.DOMDoent
    Set x = New DOMDoent

    If x.loadXML(objHTTP.responseText) Then
    If x.selectSingleNode
    ("soap:Envelope/soap:Body/LoginResponse/LoginResult/Status
    ").nodeTypedValue = "lSuccess" Then
    UserHandle = x.selectSingleNode
    ("soap:Envelope/soap:Body/LoginResponse/LoginResult/Return
    Value").nodeTypedValue
    mIsLoggedIn = True
    Else
    Err.Raise vbObjectError + 1001, "SOAP:Login",
    x.selectSingleNode
    ("soap:Envelope/soap:Body/LoginResponse/LoginResult/ErrDes
    cription").nodeTypedValue
    End If
    End If

    Exit Function

    Login_Error:

    End Function

    >-----Original Message-----
    >Hi,
    >
    >I have written a web service use ASP.NET
    >I can access i from VB 6 via XMLHTTP and everything
    works
    >fine until I try to pass parameters to it. According to
    >what doentation I can find I could pass the
    parameters
    >in an XML file or as a querystring attatched to the URL.
    >However these both return 'Invalid request'
    >
    >Is there something I'm missing ? Any ideas of where else
    I
    >can look ?
    >
    >Thanks for you time
    >Sam
    >
    >PS. Code
    >
    >sBuffer
    >= "http://localhost/MapWS/MapService.asmx/GetMapURL"
    >
    > XMLhttp.open "POST", sBuffer, False
    > XMLhttp.setRequestHeader "Content-type", "text/xml"
    > XMLhttp.send ("C:\Coords.xml")
    > MsgBox XMLhttp.responseText
    >
    > PosHTTP = InStr(XMLhttp.responseText, ">http")
    >
    >XML File :
    >
    ><?xml version="1.0" encoding="utf-8"?>
    ><GetMapURL xmlns="MaporamaWS">
    > <Latitude>51.522249476571</Latitude>
    > <Longitude>-0.105867806149086</Longitude>
    ></GetMapURL>
    >
    >
    >.
    >
    Matthew Holton Guest

  5. #5

    Default Consuming a web service from VB 6

    I should also point out that...

    if you view the [url]http://localhost/servicename.asmx[/url]
    file. WDSL will display your functions and methods. If
    you choose one of those functions (a link), you will be
    directed to a page describing that method or function.
    Below that description and, usually a means to test, will
    be the SOAP definition for both the input and output of
    that method or function. This part describes how you
    create the SOAP envelope to communicate via the XMLHTTP
    object, and the ACTION header to specify.


    HTH,

    Matthew

    >-----Original Message-----
    >Hi,
    >
    >I have written a web service use ASP.NET
    >I can access i from VB 6 via XMLHTTP and everything
    works
    >fine until I try to pass parameters to it. According to
    >what doentation I can find I could pass the
    parameters
    >in an XML file or as a querystring attatched to the URL.
    >However these both return 'Invalid request'
    >
    >Is there something I'm missing ? Any ideas of where else
    I
    >can look ?
    >
    >Thanks for you time
    >Sam
    >
    >PS. Code
    >
    >sBuffer
    >= "http://localhost/MapWS/MapService.asmx/GetMapURL"
    >
    > XMLhttp.open "POST", sBuffer, False
    > XMLhttp.setRequestHeader "Content-type", "text/xml"
    > XMLhttp.send ("C:\Coords.xml")
    > MsgBox XMLhttp.responseText
    >
    > PosHTTP = InStr(XMLhttp.responseText, ">http")
    >
    >XML File :
    >
    ><?xml version="1.0" encoding="utf-8"?>
    ><GetMapURL xmlns="MaporamaWS">
    > <Latitude>51.522249476571</Latitude>
    > <Longitude>-0.105867806149086</Longitude>
    ></GetMapURL>
    >
    >
    >.
    >
    Matthew Holton Guest

Similar Threads

  1. consuming web service
    By JPinto in forum ASP.NET Web Services
    Replies: 2
    Last Post: April 24th, 10:59 AM
  2. Error consuming web service
    By John in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: March 31st, 09:16 AM
  3. Consuming .NET Web Service
    By Bogey in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: February 21st, 07:13 PM
  4. Replies: 0
    Last Post: July 20th, 01:58 PM
  5. Consuming a web service in javascript
    By ScottyMTL in forum Macromedia Dynamic HTML
    Replies: 1
    Last Post: May 6th, 05:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139