Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2006, 10:49 AM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Soap Pricing Tool in XML for Beginners

I purchase XML for Beginners and was working my way through the TRY IT OUT: GETing a SOAP Message starting on page 571 only to find that the code didn't work. I keep getting the error message below:
Line 36
Char 1
Error: Object expected
Code 0
URL http://mywebsite.com/soap/soapclient.html

I downloaded the project file for this book from this website and replaced my type in code with the download code and still I am getting the same error. The TRY IT Out for Creating an RPC Server in ASP work fine. What is the problem with theGETing SOAP Message code. I need to understand how this work is suppose to work before I can move on to the next lesson.

Any help would be appreciated.



 
Old December 8th, 2006, 12:59 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Do you have the relevant asp files running on your server and have you modified the URLs accordingly?
When do you get the error, when loading the page or after pressing Add to Cart?

--

Joe (Microsoft MVP - XML)
 
Old December 8th, 2006, 04:22 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe I get the error after changing the quantity and tabbing or clicking o the screen to invoke the updateTotal function.

Below is the HTML Code

<html>
<head>
<title>Get Tester</title>

<script language="JavaScript">
function updateTotal(){

    var qty = orderForm.qty.value;
    var unitPrice = orderForm.unitPrice.value;

    xdDoc = new ActiveXObject("MSXML.DOMDocument");

    xhHTTP = new ActiveXObject("MSXML2.XMLHTTP");
    xhHTTP.open("GET", "http://localhost/ASP/updateTotal2.aspx?quantity=" + qty + "&unitPrice=" + unitPrice, false);
    xhHTTP.send();
    xdDoc = xhHTTP.responseXML;

    alert(xdDoc.xml);

var discount, extPrice;
    discount = xdDoc.selectSingleNode("//o:discount").text + "% off";
    xtPrice = xdDoc.selectSingleNode("//o:extPrice").text;

    document.getElementById("discount").innerHTML = discount;
    orderForm.extPrice.value = extPrice;
}
</script>
</head>
<body>

<h1>SOAP Pricing Tool</h1>

<form name="orderForm" id="orderForm">

  Quantity: <input id="qty" name="qty" size="3" value="1"
                                      onChange="updateTotal();"/>
  <br />
  Item: <i>Zibka Smiles</i>, by The Polka Dot Zither Band
  <br />
  Discount: <span id="discount"></span>
  <br />
  Unit Price: <input id="unitPrice" name="unitPrice" value="12.95" size="4"/>
  <br />
  Extended Price: <input id="extPrice" name="extPrice" size="4" value="12.95"/>

</form>
</body>
</html>

Below is the ASPX code

<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"

Dim quantity, unitPrice
Dim discount, extPrice

On Error Resume Next

quantity = Request.QueryString.Item("quantity")
unitPrice = Request.QueryString.Item("unitPrice")

discount = QuantityDiscount(quantity)
extPrice = (CDbl(quantity) * CDbl(unitPrice))*(1 - (discount/100))

If Err.number <> 0 Then
   Response.Write (ErrorXML())
Else
   Response.Write (SuccessXML(discount, extPrice))
End If

Function QuantityDiscount(quantity)
    'For the sake of the example, just return a fixed amount
    QuantityDiscount = 10
End Function

Function ErrorXML()
   Dim sXML

   sXML = "<Error><Reason>Invalid numbers</Reason></Error>"

   ErrorXML = sXML
End Function

Function SuccessXML(sDiscount, sExtprice)
   Dim sXML

   sXML = "<env:Envelope xmlns:env='http://www.w3.org/2003/05/soap-envelope'>"
           + vbNewLine & "<env:Body>"
           + vbNewLine & "<o:updateTotalResponse "
           + "xmlns:o='http://www.sernaferna.com/soap/ordersystem'>"
           + vbNewLine & " <o:discount>" & discount & "</o:discount>"
           + vbNewLine & " <o:extPrice>" & extPrice & "</o:extPrice>"
           + vbNewLine & "</o:updateTotalResponse>"
           + vbNewLine & "</env:Body>"
           + vbNewLine & "</env:Envelope>"

   SuccessXML = sXML
End Function
%>



 
Old December 9th, 2006, 05:33 AM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I retry the code this morning a it worked. Thanks for everyones help. Issue closed.






Similar Threads
Thread Thread Starter Forum Replies Last Post
XML and SOAP paulzazzarino XML 6 August 23rd, 2006 10:58 AM
MS Access SOAP or XML Functionality BrianWren Access 1 May 4th, 2006 06:51 AM
beginners problems (combining xml feeds etc) bewise XSLT 0 February 7th, 2006 06:39 AM
How to: ASP, XML and SOAP hotfridge XML 0 February 18th, 2004 12:15 AM
Soap and xml bearpaws XML 2 November 16th, 2003 06:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.