?
Solved

Basic SOAP VB to ASP and Back

Posted on 2003-03-05
4
Medium Priority
?
1,004 Views
Last Modified: 2011-10-03
I am running a simple SOAP example that I see everywhere on the web. The example should pass a parameter to an ASP page which in turn responds. There are only  parts to the example. The VB part is as follows:


Sub Main()
  Dim objhttp As New MSXML.XMLhttpRequest
  Dim strEnvelope As String
  Dim strReturn As String
  Dim objReturn As New MSXML.DOMDocument
  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:http://www.assetmarketingsystems.net/bnye/UpdateApplication:TaxCalculator"">" & _
    "<salestotal>100</salestotal>" & _
    "</m:getsalestax>" & _
    "</soap:body>" & _
    "</soap:envelope>"
 
  'Set up to post to our local server
  objhttp.open "post", "http://www.assetmarketingsystems.net/bnye/UpdateApplication.asp", False
 
  '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
  strQuery = _
    "SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
  dblTax = objReturn.selectSingleNode(strQuery).Text
 
  Debug.Print dblTax
End Sub


The ASP page is as follows:


<%
Dim strQuery
Dim varSalesTax
Dim varSalesTotal
Dim strTemp
Dim objReq

'Server.CreateObject("Microsoft.XMLDOM")
Set objReq = Server.CreateObject("MSXML2.DOMDocument.4.0")

'Load the request into XML DOM
objReq.Load Request


'Query the DOM for the input parameter
strQuery = "SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal"

varSalesTotal = objReq.SelectSingleNode(strQuery).Text

'Calculate the sales tax
varSalesTax = varSalesTotal * 0.04

'Prepare the return envelope
strTmp = ""
strTmp = strTmp + "<SOAP:Envelope xmlns:SOAP=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<SOAP:Header></SOAP:Header>" & _
"<SOAP:Body>" & _
"<m:GetSalesTaxResponse xmlns:m=""urn:http://www.assetmarketingsystems.net/bnye/UpdateApplication:TaxCalc"">" & _
"<SalesTax>" & varSalesTax & "</SalesTax>" & _
"</m:GetSalesTaxResponse>" & _
"</SOAP:Body>" & _
"</SOAP:Envelope>"

'Write the return envelope
Response.Write strTmp

%>


If someone could give me a hint I would appreciate it. It does not appear to be a firewall. I am not understanding how the xmlns works. The response error is as follows:


Reference to undeclared namespace prefix: 'SOAP'.


Thanks for your help,

Ben


0
Comment
Question by:bnye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:lavinder
ID: 8078280
Hi

 try this link:
http://www.vbip.com/xml/

hope this helps!!
0
 

Author Comment

by:bnye
ID: 8081521
Thank you -

That is one of the locations where I originally got this example. Notice the striking similarity:) I was able to get my example to work by not changing anything from the example. In my try I switched to the MSXML4.dll. This appeared not to work.

Apparently I'm just not that good at following instructions.

Thanks for the reply.

Ben
0
 
LVL 7

Accepted Solution

by:
lavinder earned 200 total points
ID: 8086248
hi ben

 If you are using MSXML DOM parser v4.0, use this

 Dim objHTTP As New MSXML2.XMLHTTP40
 .
 .
 Dim objReturn As New MSXML2.DOMDocument

 instead of

 Dim objhttp As New MSXML.XMLhttpRequest
 .
 .
 Dim objReturn As New MSXML.DOMDocument

 same applies to asp code also and then try running.

cheers!!

 
0
 

Author Comment

by:bnye
ID: 8090590
Shweeeet. Simple fix to get me up to Version 4. I appretiate it.

Thanks again lavinder,

Ben
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

801 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