calling a Java Web Service from ASP Classic

hi...
I'm a newbie to web services.
I've researched and created a simple Java web service (HelloWorld) in JDeveloper. I deployed it locally on my computer and can invoke it using Internet Explorer (I can see the xml via the wsdl too)

Now... we currently have a Classic ASP application that needs to connect to it. I am running a development version of the application locally to. So everything in local right now.

Unfortnately I do not know how to connect to the Java Web Service. Below is the ASP page code trying to connect to the web service but I get an error.
"Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'getHelloWorld'"

Thanks in advance!

<html>
<head>
<title>CONSUME WEBSERVICE</title>
</head>
<body>
<%
//Only to process a Post Request
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    Dim oSOAP
    'Create an object of Soap Client
    Set oSOAP = Server.CreateObject("MSSOAP.SoapClient")
    oSOAP.ClientProperty("ServerHTTPRequest") = True
    'Initaialize the Web Service
    oSOAP.mssoapinit("http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl")
    'Invoke the Web Service
    Response.write(oSOAP.getHelloWorld("Test"))
End If
%>
<FORM method=POST name="form1">
Testing a connection to a Java Web Service.<BR>
Name: 
<INPUT type="text" name="CC">
<BR><BR>
<INPUT type="submit" value="submit" name="submit">
</form>
</body>
</html>

Open in new window

Jetter88Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
David H.H.LeeConnect With a Mentor Commented:
Hi Jetter88,
>>..I don't exactly know how "".item(0).text " part work officially?
-myXmlDoc.getElementsByTagName("Name").item(0).text meant this is first item of records that contain under "Name" tag.
You may refer this for more details for XML returned for web services that consumed:
http://www.aspfree.com/c/a/ASP/Consuming-a-WSDL-Webservice-from-ASP/

>>I  also don't know the function work behind GetQuote and I just send a "Stock Symbol" and the results come back
Ok, it seem like consume third-party services and the manipulation process should be embedded.

>>..I can call invoke the web service via a browser using:
http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl
Is this services build by your side? Can you zip all your testing code and i try to perform the testing under my local environment.

Lastly, I'm not sure if you're rushing this testing for commercial use or some sort of personal testing purpose. You can request other users to assist in this thread if required in case i'm not able to revert to you in time-manner.

0
 
David H.H.LeeCommented:
Hi Jetter88,
Make sure consumed "getHelloWorld" function return the value correctly. Please post the mentioned function here for further investigation if required. I suspect some wrong argument being passed/processed in the function that invoked.

More details:
http://www.dotnetjunkies.ddj.com/Tutorial/99CA4563-FBD4-411F-A9C6-FF9E8A0E664F.dcik


0
 
Jetter88Author Commented:
hi x_com:
sorry... i didn't see your response at the bottom and thank you for responding.
I have the same link you send to follow. There is the HTTP Get and SOAP methods I can use.
1. I can get the HTTP GET page working correctly (when calling the external web service)
2. I can't get the SOAP page to work (when calling my internal web service "HelloWorld")

The web service is written in Java (JDeveloper) and deployed internally.
ASP page code I used: (snippet1)
Web service: (snippet2)

When I simply use:http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl in the browser, can invoke the method.

Not sure what could be worng?
Thanks again
snippet1:
<%
Response.Write consumeWebService() 
Function consumeWebService() 
    Dim soapClient
    Set soapClient = Server.CreateObject("MSSOAP.SoapClient") 
    soapClient.ClientProperty("ServerHTTPRequest") = True 
'    soapClient.mssoapinit "http://localhost/WebService1/Service1.asmx?wsdl" 
    soapClient.mssoapinit "http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl"
    consumeWebService = soapClient.getHelloWorld("Test") 
End Function
%>
 
snippet2:
public String getHelloWorld(String name)
{
      return "Hello " + name;
}

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
David H.H.LeeCommented:
Hi Jetter88,
>>2. I can't get the SOAP page to work (when calling my internal web service "HelloWorld")
Can you post the detailed errors here?
0
 
Jetter88Author Commented:
hi x_com:
i appreciate your help.
The error I get when trying to run the soap.asp page is:
Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'soapClient.getHelloWorld'
/tcrslocal/tcrs/soap.asp, line 17

Line 17 is: consumeWebService = soapClient.getHelloWorld("Test")

Also... how can I debug this properly? When the error happens I get a "Visual Studio Just In Time Debugger"... the error is: "An unhandled exception ('Unhandled Exception') occurred in dllhost.exe [1820].



0
 
David H.H.LeeCommented:
Hi Jetter88,
Sorry for overlook this thread.
Try convert to string type using Cstr() function before pass to java function.
eg:
consumeWebService = cStr(soapClient.getHelloWorld(cStr("Test")))



0
 
Jetter88Author Commented:
Hi x_com:
I use the CStr() command like you mentioned and still get the same error:
Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'soapClient.getHelloWorld'
/tcrslocal/tcrs/soap.asp, line 17

I've tried a number of different ways and other scenarios, but nothing seems to work properly. It doesn't fail at this line, so does that atleast mean I'm hiting the service?  but failing at the procedure?   soapClient.mssoapinit "http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl"

Thanks
0
 
Jetter88Author Commented:
Hi x_com:
just a thought and i will experiment with it. I changed:
    Set soapClient = Server.CreateObject("MSSOAP.SoapClient")  to:
    Set soapClient = Server.CreateObject("MSSOAP.SoapClient30") first

I read about options for the mssoapinit and adding parameters.
soapClient.mssoapinit "http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl","???","???"

I'm not sure what to put in the parameter area though? Am i going down the wrong route?
0
 
David H.H.LeeCommented:
Hi Jetter88,
Sorry for the late reply. Perhaps you can find how it work under this MSDN article:
http://msdn.microsoft.com/en-us/library/ms997641.aspx
0
 
Jetter88Author Commented:
hi x_com:
sorry for the late reply... been away.

I've tryng multiple ideas and searched website after website.
I am currently trying to get a simple ASP to connect to a webservice on the web. (changing the plan for now)
1. I can connect and get results from a simple webservice such as "Hello World" (http://almighty.pri.univie.ac.at/~mangler/helloService?wsdl)
The result is easy to display using a response.write command on the ASP page (snippet 1)

2. 1. I can connect and get results from a simple webservice such as "Hello World" (http://www.webservicex.com/stockquote.asmx?wsdl)
The result is easy to display using a response.write command on the ASP page (snippet 2)
BUT I don't know the code to parse thru the result. Would you know the correct code in ASP?
I think its with:     Set myXmlDoc = Server.CreateObject("MSXML.DOMDocument")
but I'm struggling getting it to work.

Thanks again

snippet 1:
<html>
<head>
<title>Local ASP page to Ext WS (SOAP)</title>
</head>
<body>
<%
//Only to process a Post Request
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    Dim oSOAP
    
    'Create an object of Soap Client
    Set oSOAP = Server.CreateObject("MSSOAP.SoapClient")
    oSOAP.ClientProperty("ServerHTTPRequest") = True
    'Initaialize the Web Service
    oSOAP.mssoapinit("http://almighty.pri.univie.ac.at/~mangler/helloService?wsdl")
    'Invoke the Web Service
    Response.write(oSOAP.sayHelloTo(Request.Form("helloName")))
    
End If
%>
<FORM method=POST name="form1">
Testing a connection to a Web Service.<BR>
HELLO WORLD!<br>
Please enter a name: 
<INPUT type="text" name="helloName">
<BR><BR>
<INPUT type="submit" value="submit" name="submit">
</form>
</body>
</html>
 
 
snippet 2:
<html>
<head>
<title>Local ASP page to Ext WS (Stock)</title>
</head>
<body>
<%
//Only to process a Post Request
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    Dim oSOAP
    'Create an object of Soap Client
    Set oSOAP = Server.CreateObject("MSSOAP.SoapClient")
    oSOAP.ClientProperty("ServerHTTPRequest") = True
    'Initaialize the Web Service
    oSOAP.mssoapinit("http://www.webservicex.com/stockquote.asmx?wsdl")
    'oSOAP.mssoapinit("http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl")
    'Invoke the Web Service
    Response.write(oSOAP.GetQuote(Request.Form("symbol")))
End If
%>
<FORM method=POST name="form1">
Testing a connection to a Web Service.<BR>
STOCK QUOTE!<br>
Please enter a symbol: 
<INPUT type="text" name="symbol">
<BR><BR>
<INPUT type="submit" value="submit" name="submit">
<br>
web service works, but is VERY slow or down sometimes.
</form>
</body>
</html>
 
result:
ECA45.594/29/200910:11am+1.2245.4145.8445.1836592934.211B44.37+2.75%34.00 - 99.367.9065.61ENCANA CORP

Open in new window

0
 
David H.H.LeeCommented:
Hi Jetter88,
>>2.... BUT I don't know the code to parse thru the result. Would you know the correct code in ASP?
I think its with:     Set myXmlDoc = Server.CreateObject("MSXML.DOMDocument")
I can see the result returned on screen after input the symbol. But, i'm not sure how this function work behind - "GetQuote".
I've entered "Haha" as my test data. The returned data is
HAHA0.00N/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/A - N/AN/AN/AHAHA

I'm not sure this requested:
>>..I don't know the code to parse thru the result
Can you elaborate further details on this?

0
 
Jetter88Author Commented:
Hi again...
I was successful in parsing through the result from the GetQuote web service at
http://www.webservicex.com/stockquote.asmx?wsdl with the following code in snippet 1.
I don't exactly know how "".item(0).text " part work officially? do you?
I also don't know the function work behind GetQuote and I just send a "Stock Symbol" and the results come back. Use actual stock sybols for results such as MSFT, ECA, YHOO

I've gone back to trying to call a java webservice and keep getting a error:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'getHelloWorld'

I can call invoke the web service via a browser using:
http://localhost/JavaWebServiceRoot/GetDatesWSSoapHttpPort?wsdl
but when in the Classic ASP page... I get the above error:
"Invalid procedure call or argument: 'getHelloWorld'"

What could be the problem?






snippet 1:
Sett myXmlDoc = Server.CreateObject("MSXML.DOMDocument")
myXmlDoc.loadxml(oSOAP.GetQuote(Request.Form("symbol")))
Response.write("NAME = " + myXmlDoc.getElementsByTagName("Name").item(0).text + "<br>")
 
snippet 2:
Set oSOAP = Server.CreateObject("MSSOAP.SoapClient")
oSOAP.ClientProperty("ServerHTTPRequest") = True
'Initaialize the Web Service
oSOAP.mssoapinit("http://localhost:8888/HelloWebService/HelloWorldWSSoapHttpPort?wsdl")
'Invoke the Web Service
Response.write(oSOAP.getHelloWorld("Test"))

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.