Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1009
  • Last Modified:

Basic SOAP VB to ASP and Back

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
bnye
Asked:
bnye
  • 2
  • 2
1 Solution
 
lavinderCommented:
Hi

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

hope this helps!!
0
 
bnyeAuthor Commented:
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
 
lavinderCommented:
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
 
bnyeAuthor Commented:
Shweeeet. Simple fix to get me up to Version 4. I appretiate it.

Thanks again lavinder,

Ben
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now