-1

I am on really sturbie ground here, this is my first time I have worked with ASMX WebServices, so I am doing a trial and error on this, so please bare with me on this.

I have been able to connect and do a login to the service using below ASP Classic, but have now "hit a wall" which I have not been able to find a solution for neigther here or by googling, propably because I am a noob on this and does not know what to look after.

When I call the below script, I get the following error:

Procedure or function 'stp_ws_GetWebServiceSessionBySessionID' expects parameter '@WebServiceSessionID', which was not supplied

The script I have so far:

Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
oXmlHTTP.Open "POST", "https://api.domain.com/services/ws3.asmx", False 

oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlHTTP.setRequestHeader "SOAPAction", "http://sub.domain.com/GetCurrentCallStats4"

SOAPRequest = _
"<?xml version=""1.0"" encoding=""utf-8""?>" &_
"<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" &_

"<soap12:Body>" &_
    "<Login xmlns=""http://sub.domain.com/Login"">" &_
    "<UserIdentifier>a81aeXX-XXXXXXXXXXX-XXX4bec7</UserIdentifier>" &_
    "<PrivateKey>71e3aXX-XXXXXXXXXXX-XXX9e2</PrivateKey>" &_
    "<PublicKey>XD87XX-XXXXXXXXXXX-XXXC45</PublicKey>" &_
    "</Login>" &_  
    "<GetCurrentCallStats4Response xmlns=""https://api.domain.com/services/ws3.asmx"">" &_
    "<GetCurrentCallStats4Result>" &_
        "<StatResult4>" &_
        "<CustomerID>int</CustomerID>" &_
        "<SiteID>int</SiteID>" &_
        "<BrandID>int</BrandID>" &_
        "<CategoryID>int</CategoryID>" &_
        "<Category>string</Category>" &_
        "<TotalCases>int</TotalCases>" &_
        "<NewSince>dateTime</NewSince>" &_
        "<CasesNewSince>int</CasesNewSince>" &_
        "<CasesDue>int</CasesDue>" &_
        "</StatResult4>" &_
    "</GetCurrentCallStats4Result>" &_
    "</GetCurrentCallStats4Response>" &_
"</soap12:Body>" &_
"</soap12:Envelope>"

oXmlHTTP.send SOAPRequest    
Response.Write oXmlHTTP.responseText

How can I "catch" the @WebServiceSessionID and send it to the WS again?

*If one also could help me on the next step on how I can catch the data response from the service I would be really thankfully :-)

UPDATE! The little documentation they provided

The for each web service key, you must repeat the following steps to collect the category level statistic information:

Using the web service at https://api.domain.com/services/ws3.asmx:

  • Call Login(), and save the returned session identifier
  • Call GetSite(), using the session identifier and the private key – save the Name value
  • Call GetCurrentCallStats3() – this will return a list / array of the categories with the different monitor values for each.
    • NewCasesSince – we use the start of the current day, older values use more resources and can result in the call being terminated for excessive use of resources. The format of the dates is either YYYY-MM-DD HH:mm e.g. 2017-09-30 00:00 You can select it to a more recent date/time – e.g. 1 hour ago to show a new cases in the last hour.
    • HoursUntilDue – this controls the value returned in the result CasesDueInXMinutes Our monitor sets this value to 4 - count of cases due in the next 4 hours.
  • Call Logout()
user692942
  • 16,398
  • 7
  • 76
  • 175
Stig Kølbæk
  • 432
  • 2
  • 18
  • That error if I’m not mistaken is referring to a missing parameter being passed to a SQL Server stored procedure. If you are saying you get this error by running the code above then it must be happening at the ASMX WebService. Do you have access to the WebService codebase? Either way it has nothing to do with the code you’ve posted. – user692942 Jun 19 '21 at 08:35
  • Also `oXmlHTTP.responseText` is the "captured response" so not sure what you mean by that either. – user692942 Jun 19 '21 at 08:36
  • Hi @user692942 unfortunately no, the ASMX is delivered by another company and I have no way to access the SQL or the ASMX code. The documentation for the service is - in my opinon - poor - I will post the documentation in a few minutes, even though its not much, its all I have. – Stig Kølbæk Jun 19 '21 at 08:54
  • It seems to me reading those steps you need to first call the login request which will login you in and provide back in the response the session key you need to make the other calls. – user692942 Jun 19 '21 at 10:17
  • It looks like you're trying to wrap up the calls to Login() and GetCurrentCallStats3() into a single SOAP request. I don't think you can do that, they probably need to be separate SOAP requests. Has the service owner provided you with a WSDL (Web Service Description Language) file? – AlwaysLearning Jun 19 '21 at 10:18
  • Hi @AlwaysLearning .. I have just checked, and yes there is a WDSL file linked at the ASMX link .. it is 1600 + lines long so I do not think it would be appropriate to post it here!? – Stig Kølbæk Jun 19 '21 at 10:31
  • No, but you should use `wsdl.exe` or equivalent to generate C# client classes from it and use that to access the web service instead of trying to manually build SOAP requests inside .asp web pages. – AlwaysLearning Jun 19 '21 at 10:32
  • Oookay .. I will reasearch on using `wsdl.exe`.. C# I have not worked with before – Stig Kølbæk Jun 19 '21 at 10:36
  • 1
    @AlwaysLearning Classic ASP is not ASP.Net, you’re talking about using `wsdl.exe` to generate a client stub for an ASP.Net Web Application, which this is not. – user692942 Jun 19 '21 at 11:49
  • I think I might have been able to provide the session ID by adding `"" & Session.SessionID & "" &_ ` this removes the error .. at the moment I am strucling with getting `Response.Write oXmlHTTP.getElementsByTagName("NewCasesSince").text` to work, since it gives me error `Object doesn't support this property or method: 'getElementsByTagName'` so I think I will leave this post as is and concentrate on this issue. – Stig Kølbæk Jun 19 '21 at 12:03
  • @StigKølbæk honestly, it’s an XML response you need to parse it as XML. There’s [plenty of existing answers about parsing XML responses](https://stackoverflow.com/a/19982320/692942) in Classic ASP. – user692942 Jun 19 '21 at 12:08
  • 1
    You might find [this](https://stackoverflow.com/a/1079369/692942) and [this](https://stackoverflow.com/q/3905194/692942) helpful. – user692942 Jun 19 '21 at 12:18
  • Thank you @user692942 I will look into this :-) – Stig Kølbæk Jun 19 '21 at 12:20

1 Answers1

0

Create a web service reference from visual studio which will create you a class definition from the URL for calling the web service? Research service reference. This would help you send and retrieve the data you may need. Or Even try SOAPUI which is free and allows you to setup a test client for the web service so you can see how the data is delivered and coming back and the data you are missing. https://www.soapui.org/

deka81
  • 11
  • 4
  • This is great advice for working with a ASP.Net Web Application, but apart from SoapUI not very useful for Classic ASP. – user692942 Jun 20 '21 at 12:35
  • It is quite useful for Classic ASP, the code may not port over to Classic ASP but the generated code will give them an idea on how to structure their own code. SoapUI cannot be used in Classic ASP either but it is useful in seeing the actual web client xml request and response. Wsdl.exe could also be used to create a helpful example. They have no documentation so a working example would help. – deka81 Jun 22 '21 at 11:49
  • The error is: Procedure or function 'stp_ws_GetWebServiceSessionBySessionID' expects parameter '@WebServiceSessionID', which was not supplied Meaning when you called the function, you didn't supply the variable it wanted, in this case that Session ID you are looking for there. deka81 explained a bit on how to get that variable, so now all you need to do is hook that into the function. Problem is you posted some non asp code, soap it seems, so I am just going to have to make things up as an example. Make the function: <% function YourFunction(WebServiceSessionID) %> – easleyfixed Jun 22 '21 at 21:39
  • But for my comment to work we would have to set WebServiceSessionID = what it really is first, and that is the question. If it was something inherent in ASP Classic I could offer advice, but never used that one, but reminds me of custom ones you can make yourself using Session variables to store connections and user logins and what not by unique id. Citation - check over here for asp functions https://www.w3schools.com/ASp/asp_procedures.asp EDIT -- I just noticed the @ symbol on that variable ... is this pooling MySQL data perhaps? – easleyfixed Jun 22 '21 at 21:42