Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using soap 3.0 with vb6 2

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
I have been trying to find a "simple" example of using soap from a vb6 program...all the ones i have found do not work or are complicated..appreciate if someone could point me to a suitable example... preferably using my own machine (localhost ) as the server..
I am not real keen on going to vb.net at this stage, looks a bit daunting!!!!

Have downloaded soap 3.0 and installed...

Appreciate any help.

Kennedymr2
 
BobRodes , Thanks for the link, i will have a look at the tutorial tomorrow, and let you know how i go...

Not an easy thing to come to grips with... but i suppose when i work it out, it will be simple ????

Much appreciated Kennedymr2
 
BobRodes,

Have tried the sample, but i believe it is using soap v1
The latest seems to be soap 3.0, which i have downloaded and installed..

The line i am having a problem with is

dblTax = objReturn.selectSingleNode(strQuery).Text

I would guess that the following is my problem...?????

"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">"

"""""""""""""

'Query the return envelope
strQuery = _
"SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
dblTax = objReturn.selectSingleNode(strQuery).Text

""""""""""""""

'Create the SOAP Envelope
strEnvelope = _
"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<soap:header></soap:header>" & _
"<soap:body>" & _
"<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" & _
"<salestotal>100</salestotal>" & _
"</m:getsalestax>" & _
"</soap:body>" & _
"</soap:envelope>"
""""""""""""""""


Would appreciate any help with how this line should look in v3

Regards Kennedymr2

 
Sorry, I'm not a SOAP expert. Perhaps someone else can help?
 
Appreciate you offer to help, i realize that 'soap' is
not a popular subject...!!!!
Think i have found a vb6 soap v3 example that will do the job for me.

Many thanks


Kennedymr2
 
>I would guess that the following is my problem...?????
>"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">"
That's not the problem. The article, though dated somehow, is done just fine, only if it is more rigorously proof-read. To assure its working, something you've to observe.

[1] Religiously following the use of moniker "microsoft.xmldom" on the server.
[2] Correct all case-inconsistencies of the xml strings (request or response) including namespace prefixes and tag names.
[3] (minor-not a source of problem) The response namespace m should be written as TaxCal[red]ulator[/red] to raise less confusion and more consistent.
 
Different versions of the SOAP Toolkit also have somewhat different class signatures as well I believe. I.e. there may be a different set of classes with different methods and properties and parameter lists.
 
Thanks for the new comments and help...

I am pretty keen to get this example going, will have a closer look at 'case sensitive' text etc, and see how i go

tsuji , you seem to know a bit about soap, would appreciate if you could give a little more detail as to what you see in this code needs alteration

Regards Kennedymr2
 
This is a (quasi minimally) corrected version made to the original article.

[1] Client-side with reference to microsoft xml v3.0 type library (do not go higher).
[tt]
'client side
Sub Main
[red]'[/red]Dim objHTTP As New MSXML.XMLHTTPRequest
[blue]Dim objHTTP As New MSXML2.XMLHTTP[/blue]
Dim strEnvelope As String
Dim strReturn As String
[red]'[/red]Dim objReturn As New MSXML.DOMDocument
[blue]Dim objReturn As New MSXML2.DOMDocument[/blue]
Dim dblTax As Double
Dim strQuery As String

'Create the SOAP Envelope
strEnvelope = _
"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<soap:header></soap:header>" & _
"<soap:body>" & _
"<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" & _
"<salestotal>100</salestotal>" & _
"</m:getsalestax>" & _
"</soap:body>" & _
"</soap:envelope>"

'Set up to post to our local server
[green]objHTTP.open "post", " False[/green]

'Set a standard SOAP/ XML header for the content-type
objHTTP.setRequestHeader "Content-Type", "text/xml"

'Set a header for the method to be called
objHTTP.setRequestHeader "SOAPMethodName", _
"urn:myserver/soap:TaxCalculator#GetSalesTax"

'Make the SOAP call
objHTTP.send strEnvelope

'Get the return envelope
strReturn = objHTTP.responseText

'Load the return envelope into a DOM
objReturn.loadXML strReturn

'Query the return envelope
[red]'[/red]strQuery = _
[red]'[/red]"SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
[blue]strQuery = _
"soap:envelope/soap:body/m:getsalestaxresponse/salestax"[/blue]
dblTax = objReturn.selectSingleNode(strQuery).Text

Debug.Print dblTax
End Sub
[/tt]
[2] Server-side soap.asp
[tt]
Set objReq = Server.CreateObject("Microsoft.XMLDOM")

'Load the request into XML DOM
objReq.Load Request

'Query the DOM for the input parameter
[red]'[/red]strQuery = "SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal"
[blue]strQuery = "soap:envelope/soap:body/m:getsalestax/salestotal"[/blue]
varSalesTotal = objReq.SelectSingleNode(strQuery).Text

'Calculate the sales tax
varSalesTax = varSalesTotal * 0.04

'Prepare the return envelope
strTmp = _
"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<soap:header></soap:header>" & _
"<soap:body>" & _
"<m:getsalestaxresponse xmlns:m=""urn:myserver/soap:TaxCalc[green]ulator[/green]"">" & _
"<salestax>" & varSalesTax & "</salestax>" & _
"</m:getsalestaxresponse>" & _
"</soap:body>" & _
"</soap:envelope>"

'Write the return envelope
Response.Write strTmp
[/tt]
 
tsuji ,

Really appreciate the time you have offered..

Have copied and pasted all the code but i still get an error.......

am using msxml3.dll, thats alli had in references..

runtime error '91':
object variable or with block variable not set

Do not want to bother you with this if you are busy ??? will understand...


Regards Kennedymr2
 
>runtime error '91':
>object variable or with block variable not set
at which line???
 
tsuji ,

Guess what, i have been out for a few hours and turned my computer back on,
retried your solution, and it has worked...!!!!!

Sorry to have sent the other post and bothed you, i have no idea how this would happen..????

Anyhow, many thanks for you detailed help, much appreciated..its all working ok now..
I now have a better understanding of how soap works..which will get me going on a more complicated project.


Regards Kennedymr2
 
I knew someone would be able to do it. :) Thanks tsuji, I've archived this and given you a star.

By the way kennedymr2, see faq222-6008 for reasons not to use the "Dim As New" syntax.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top