Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / April 2007



Tip: Looking for answers? Try searching our database.

I'm well-versed in VB6, but not XML or Java...need a little help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent White - 27 Apr 2007 21:14 GMT
I am trying to write an application that will eventually be made as a
Subroutine in another VB6 application.

We have a Java intranet server that serves HTTP requests such as
GetNextOrderNumber, which is supposed to retrieve an order number for
the program to use and advance the next order number by one.  Within
the application that uses this, it works great.

However, I'm having to interface to the Servlet that was programmed by
someone else outside the company.  I would like to call this
procedure, so I got the Request XML format that it needs to work:

<Request>
     <type>getNextSalesOrderNumber</type>
</Request>

I saved this to a file known as Request.xml.  I then made some code
using examples from the internet:

Sub Main()
   Dim xmlhttp As New MSXML2.XMLHTTP40
   Dim objdom As New MSXML2.DOMDocument40
   objdom.Load "C:\request.xml"
   xmlhttp.open "POST", "http://jomar-new:85/xssqlbd/ObjServer"
   xmlhttp.send objdom

   Debug.Print xmlhttp.responseText 'Get response generated by the
server
End Sub

When I run the program, I get nothing in the Debug window, and this
error pops up in the log file:

[2007.04.27_15.48.16] [195.1.2.45] reading Object
Error :java.io.StreamCorruptedException: invalid stream header
[2007.04.27_15.48.16] [ObjServer] java.lang.NullPointerException

I know I'm missing some code, but I can't seem to find the XML header
file I need.

<?xml version="1.0" encoding="UTF-8"?>
Is the only line I have for a header.

I want to learn, but time is a little tight.  Can someone point me to
something that will tell me what I'm doing wrong?  (by the way, all IP
addresses shown are private)
Dag Sunde - 28 Apr 2007 01:10 GMT
> I am trying to write an application that will eventually be made as a
> Subroutine in another VB6 application.
[quoted text clipped - 25 lines]
> server
> End Sub

Four things...
1.)
xmlhttp.open defaults to asynchronous processing, so it is no guarantee
that the response object is ready when you reach your Debug.Print statement.

Specify syncronous processing instead:
   xmlhttp.open "POST", "http://jomar-new:85/xssqlbd/ObjServer", True

2.)
You cant send an object (the objdom) over http, you have to send the
xml-text
(objdom.xml instead)

3.)
Your servlet have some kind of value name to send the data to (i.e.
'funcName')

4.)
You need to specify the header when posting
   xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"

So to sum it up, try something like this

   Dim xmlhttp As New MSXML2.XMLHTTP40
   Dim objdom As New MSXML2.DOMDocument40
   objdom.Load "C:\request.xml"
   xmlhttp.open "POST", "http://jomar-new:85/xssqlbd/ObjServer", True

   xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
   xmlhttp.send "funcName=" & objdom.xml

   Debug.Print xmlhttp.responseText 'Get response generated...

Signature

Dag

Brent White - 28 Apr 2007 08:26 GMT
> > I am trying to write an application that will eventually be made as a
> > Subroutine in another VB6 application.
[quoted text clipped - 63 lines]
> --
> Dag
Brent White - 28 Apr 2007 08:27 GMT
> > I am trying to write an application that will eventually be made as a
> > Subroutine in another VB6 application.
[quoted text clipped - 63 lines]
> --
> Dag

(accidentally clicked Send mid-message)

I'll try that when I get back to the office Monday.  I've never done
XML interfacing before, either for Java or ASP, so this is a new
experience for me.

Thank you, Dag.
Brent White - 29 Apr 2007 05:08 GMT
Application log still shows the same error and there's no response.
Also, I get this error:  "The Data Necessary to complete this
operation is not yet avaialble".  Also, this is an Apache web server,
so I get a log in (it accepts my application log in).  How do I get
around that?

Again, sorry for my ignorance, but I've never done this kind of thing
before.

> > I am trying to write an application that will eventually be made as a
> > Subroutine in another VB6 application.
[quoted text clipped - 65 lines]
>
> - Show quoted text -
Tony Proctor - 30 Apr 2007 13:36 GMT
As well as what Dag said, the XML Load() method defaults to asynch too. Just
in case, add the following line:

Dim objdom As New MSXML2.DOMDocument40
objdom.asynch = False                ' <<----
objdom.Load "C:\request.xml"

   Tony Proctor

> > I am trying to write an application that will eventually be made as a
> > Subroutine in another VB6 application.
[quoted text clipped - 60 lines]
>
>     Debug.Print xmlhttp.responseText 'Get response generated...
Brent White - 30 Apr 2007 14:23 GMT
I'm still getting the same error in the log, and I keep getting the
message saying the data is not available yet.  Also, how do I add the
login information?

On Apr 30, 8:36 am, "Tony Proctor"
<tony_proctor@aimtechnology_NoMoreSPAM_.com> wrote:
> As well as what Dag said, the XML Load() method defaults to asynch too. Just
> in case, add the following line:
[quoted text clipped - 75 lines]
>
> - Show quoted text -
Dag Sunde - 30 Apr 2007 15:25 GMT
> I'm still getting the same error in the log, and I keep getting the
> message saying the data is not available yet.  Also, how do I add the
> login information?

At this point, I think we need to back up a little bit here:

* Can you give us the spec for the servlet you're trying to call?
 (Even better, the Java sourcecode for it)

* Do you have any samples of the usage, written in other languages?

* does the servlet accept "GET" in addition to "POST"?

Concerning the login, you can try:
"http://username:password@jomar-new:85/xssqlbd/ObjServer" as the url.

But if it is supposed to be used as a web-service, the guys that
made it should develop an authenication mechanism other that
Apache's directory access...

Signature

Dag.

Brent White - 30 Apr 2007 18:20 GMT
I wish I could, but unfortunately, I don't have access to either the
spec or the sourcecode (it's a third party servlet), so I'm flying
blind right now.  There's nothing generic that you can see I'm doing
wrong?

If not, I can probably get help from the developers.

> > I'm still getting the same error in the log, and I keep getting the
> > message saying the data is not available yet.  Also, how do I add the
[quoted text clipped - 18 lines]
> --
> Dag.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.