Calling a .NET web service from classic ASP w/o soap tookit

Discussion in 'ASP .Net' started by ryan.mclean@gmail.com, Jan 18, 2005.

  1. Guest

    Hi everyone! I'm hoping that someone can help me out. I have a
    webservice written in vb.net. This service uses the SoapHeader to
    secure the webservice to users that give a username and password. I am
    trying to call this webservice via classic asp. This works as long as
    the service is not authenticated. Here is the asp code:

    response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/randomchars/randomchars.asmx/Range?minLength=25&maxLength=35"))

    Function GetHTML(strURL)
    Dim objXMLHTTP, strReturn
    Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
    objXMLHTTP.Open "GET", strURL, False
    objXMLHTTP.Send
    strReturn = objXMLHTTP.responseText
    Set objXMLHTTP = Nothing
    GetHTML = strReturn
    End Function

    This call works great unless I try to call the service that requires
    header information, I'm not sure how best to attach the header
    information. I have tried passing the two variables (strUserName,
    strPassword) in the querystring to the service:

    response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/tripledes/tripledes.asmx/Encrypt?strUserName=help&strPassword=please&plainText=test"))

    This does not error, but it does not recognize the header information.

    These services work great when being called via .net, the service is
    fine (hopefully).

    Any help would be greatly appreciated.

    Ryan
     
    , Jan 18, 2005
    #1
    1. Advertising

  2. bruce barker Guest

    you are not using soap at all. you are using the html form interface the
    asp.net webservices support (which is usually doabled for remote calls). to
    pass a soap header you will need to pass a soap body. you can do this with
    xmlhttp, but you will need to learn enough of the soap protocal to build the
    right body, and pass the correct header.

    -- bruce (sqlwork.com)


    <> wrote in message
    news:...
    | Hi everyone! I'm hoping that someone can help me out. I have a
    | webservice written in vb.net. This service uses the SoapHeader to
    | secure the webservice to users that give a username and password. I am
    | trying to call this webservice via classic asp. This works as long as
    | the service is not authenticated. Here is the asp code:
    |
    |
    response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/randomchars/r
    andomchars.asmx/Range?minLength=25&maxLength=35"))
    |
    | Function GetHTML(strURL)
    | Dim objXMLHTTP, strReturn
    | Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
    | objXMLHTTP.Open "GET", strURL, False
    | objXMLHTTP.Send
    | strReturn = objXMLHTTP.responseText
    | Set objXMLHTTP = Nothing
    | GetHTML = strReturn
    | End Function
    |
    | This call works great unless I try to call the service that requires
    | header information, I'm not sure how best to attach the header
    | information. I have tried passing the two variables (strUserName,
    | strPassword) in the querystring to the service:
    |
    |
    response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/tripledes/tri
    pledes.asmx/Encrypt?strUserName=help&strPassword=please&plainText=test"))
    |
    | This does not error, but it does not recognize the header information.
    |
    | These services work great when being called via .net, the service is
    | fine (hopefully).
    |
    | Any help would be greatly appreciated.
    |
    | Ryan
    |
     
    bruce barker, Jan 19, 2005
    #2
    1. Advertising

  3. Guest

    Thank you for the response Bruce! I am familiar enough with soap. It
    is that I don't understand the interaction between the asp and
    webservice. Here is my attempt using the xmlhttp object. I'm hoping
    that you or someone else can give me further assistance.

    This is the basic function:

    function GetIt(strUrl)
    Dim xmlhttp
    Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.open "GET",strUrl,false
    xmlhttp.send
    GetIt = xmlhttp.responseText
    Set xmlhttp=nothing
    end function

    I then tried to send the username and password using this:

    str = _
    "<?xml version=""1.0""><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/"">" & _
    "<soap:Header>" & _
    "<AuthHeader xmlns=""http://tempuri.org/TripleDES/TripleDES"">" & _
    "<strUserName>my_uid</strUserName>" & _
    "<strPassword>none_of_your_beezwax</strPassword>" & _
    "</AuthHeader>" & _
    "</soap:Header>" & _
    "<soap:Body>" & _
    "<Encrypt xmlns=""http://tempuri.org/TripleDES/TripleDES"">" & _
    "<plainText>text</plainText>" & _
    "</Encrypt>" & _
    "</soap:Body>" & _
    "</soap:Envelope>"

    set x=Server.createObject("MSXML2.DOMDocument")
    x.async=false
    x.load str

    (I got the xml from when I test the webservice, this seems to be the
    format it would like)

    and modifying this line:
    xmlhttp.send

    to be:
    xmlhttp.send x

    This did not work, it did not recognize the nodes in the xml (Missing
    parameter: plainText).

    I've also tried changing the line:

    xmlhttp.send

    to be:
    xmlhttp.send xmlhttp.send
    "strUserName=my_uid&strPassword=pass&plainText=text"

    and get the same Missing parameter: plainText error

    When I try to send the three arguments using the querystring, I get no
    error, but it is not authenticating either . . .

    At this point, I'm hoping that I am correct in my assumption that if
    the web service call works correctly in asp.net, that the problem is
    not with the webservice. I feel like I am floundering around . . .
    Thanks again.

    More help would be greatly appreciated.

    Ryan
     
    , Jan 19, 2005
    #3
  4. Guest

    Oops, where I put:

    xmlhttp.send xmlhttp.send

    That should read:

    xmlhttp.send
    "strUserNamemy_uid&strPassword=none_of_your_beezwax&plainText=text"
    Thanks!
    Ryan
     
    , Jan 19, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julian Hershel

    Calling a .NET web service from classic ASP

    Julian Hershel, Apr 15, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    47,504
    pankajgharge
    Apr 17, 2009
  2. =?ISO-8859-2?Q?Mateusz_=A3oskot?=

    GUI tookit for science and education

    =?ISO-8859-2?Q?Mateusz_=A3oskot?=, Aug 15, 2005, in forum: Python
    Replies:
    12
    Views:
    499
  3. =?ISO-8859-2?Q?Mateusz_=A3oskot?=

    GUI tookit for science and education

    =?ISO-8859-2?Q?Mateusz_=A3oskot?=, Aug 15, 2005, in forum: Python
    Replies:
    8
    Views:
    370
    Robert Kern
    Aug 18, 2005
  4. Replies:
    0
    Views:
    425
  5. Celia Leung via .NET 247

    HELP!! Classic ASP and .net web service - service restarted often!

    Celia Leung via .NET 247, Apr 26, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    286
    Celia Leung via .NET 247
    Apr 26, 2004
Loading...

Share This Page