Solved

calling a Java Web Service from ASP Classic

Posted on 2009-04-07
14
1,871 Views
Last Modified: 2013-11-23
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

0
Comment
Question by:Jetter88
  • 6
  • 6
14 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
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
 

Author Comment

by:Jetter88
Comment Utility
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
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
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
 

Author Comment

by:Jetter88
Comment Utility
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
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
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
 

Author Comment

by:Jetter88
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:Jetter88
Comment Utility
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
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
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
 

Author Comment

by:Jetter88
Comment Utility
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
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
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
 

Author Comment

by:Jetter88
Comment Utility
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
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
Comment Utility
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now