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 May 27th, 2008, 09:49 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not sure, just get Invalid Format erro. To debug you can install a tool such as Fiddler and examine the request when the test form is used as that uses post.

--

Joe (Microsoft MVP - XML)
 
Old May 27th, 2008, 10:04 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Let me install it from

http://www.fiddlertool.com/Fiddler2/version.asp

 
Old May 27th, 2008, 11:21 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Here is the Code I am using :

Code:
<%
Option Explicit

Dim url
url = "http://apps.doublepositive.com/Suppliers/WebServices/InsertLeads.asmx/InsertLead"

Private Function InsertLead(SupplierId, SupplierPassword, FirstName, LastName, EmailAddress, CoAppFirstName, CoAppLastName, Address, City, State, PostalCode, HomePhone, WorkPhone, WorkPhoneExt, CurrentEmployer, YearsThere, Income, BestCallTime, OriginalLeadDate, ExternalLeadID, IPAddress, ExtraFields)
  Dim queryString
  queryString = "SupplierID=" & SupplierId
  queryString = queryString & "&SupplierPassword=" & SupplierPassword
  queryString = queryString & "&FirstName=" & FirstName
  queryString = queryString & "&LastName=" & LastName
  queryString = queryString & "&EmailAddress=" & EmailAddress
  queryString = queryString & "&CoAppFirstName=" & CoAppFirstName
  queryString = queryString & "&CoAppLastName=" & CoAppLastName
  queryString = queryString & "&Address=" & Address
  queryString = queryString & "&City=" & City
  queryString = queryString & "&State=" & State
  queryString = queryString & "&PostalCode=" & PostalCode
  queryString = queryString & "&HomePhone=" & HomePhone
  queryString = queryString & "&WorkPhone=" & WorkPhone
  queryString = queryString & "&WorkPhoneExt=" & WorkPhoneExt
  queryString = queryString & "&CurrentEmployer=" & CurrentEmployer
  queryString = queryString & "&YearsThere=" & YearsThere
  queryString = queryString & "&Income=" & Income
  queryString = queryString & "&BestCallTime=" & BestCallTime
  queryString = queryString & "&OriginalLeadDate=" & OriginalLeadDate
  queryString = queryString & "&ExternalLeadID=" & ExternalLeadID 
  queryString = queryString & "&IPAddress=" & IPAddress
  queryString = queryString & "&ExtraFields=" & ExtraFields
  Dim httpReq
  Set httpReq = CreateObject("msxml2.serverxmlhttp.4.0")
  httpReq.Open "GET", url & "?" & queryString, false
  httpReq.Send
  Response.write queryString
  Set InsertLead = httpReq
End Function

Public Sub Main()
  Dim req
  Set req = InsertLead("22526", "iopuat4n", "Joe", "Bloggs","[email protected]", "Fred", "Smith", "123 High Street", "Springfield", "WA", "12345", "1231234399", "1231234399", "123", "ACME", "3", "", "", "5/26/2008", "324324", "", "DebtAmount=100000")
  Response.write req.ResponseText
End Sub

Call Main()

%>

If I remove this line "Response.write queryString", it displays me the XML output , else it displays me the

Quote:
quote:
SupplierID=22521&SupplierPassword=iopuat4n&FirstNa me=Joe&LastName=Bloggs&EmailAddress=joebloggs@some where.com&CoAppFirstName=Fred&CoAppLastName=Smith& Address=123 High Street&City=Springfield&State=WA&PostalCode=12345& HomePhone=1231234399&WorkPhone=1231234399&WorkPhon eExt=123&CurrentEmployer=ACME&YearsThere=3&Income= &BestCallTime=&OriginalLeadDate=5/26/2008&ExternalLeadID=324324&IPAddress=&ExtraFields= DebtAmount=100000 Success Rejected - Duplicate from same vendor 13563335 false
Thing to note ?



 
Old May 27th, 2008, 11:28 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

May be I have to use :

Response.write "<input type=hidden value="& queryString & ">" & "<br><br><br>"



 
Old May 27th, 2008, 11:28 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

So that's working. If however you use httpReq.Open "POST", url, False and then httpReq.Send queryString it fails with a server error. What you need to do is to run the test form whilst running Fiddler and see what form the request takes and what headers are sent as it works from there.

--

Joe (Microsoft MVP - XML)
 
Old May 27th, 2008, 11:41 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Just trying and fidling around with that software to understand it
:-)

 
Old May 27th, 2008, 01:32 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Code:
<ErrorName>Lead Import Error.</ErrorName>
I want to pull out everything which appears between <ErrorName> and
</ErrorName>.

How to do it in asp/vbscript ?

I tried regex but how to


 
Quote:
quote:
Quote:

My entire string looks like this :



st="<?xml version="1.0" encoding="utf-8" ?> - <returnMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.abcsite.com/"> <ErrorName>Success</ErrorName> <ErrorDescription>Approved - Ready to be assigned to Order</ErrorDescription> <LeadID>13498919</LeadID> <ClientAvailable>true</ClientAvailable> </returnMessage>"



From above line or string, I want to Extract all which appears between

<ErrorName> and </ErrorName>.

I tried

<ErrorName\b[^>asdsad</ErrorName>

and it works... but how to from that string ?
 
Old May 27th, 2008, 03:55 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am so glad that finally problem got resolve.

I was trying to solve this for the last 25-30 days , tried all other forums but alas...

Thanks a lot to all members who real took out time and helped me in resoving this.

Salute !



 
Old May 28th, 2008, 03:18 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You don't use regex, you load the XML into an msxml2.domdocument.x.0 (replace x with the latest version on your server, hopefully 6) and use XPath to retrieve. I suggest you start a new thread for this if you're struggling as this is really a different issue, and one which in this case really to do with XML.

--

Joe (Microsoft MVP - XML)
 
Old May 28th, 2008, 04:52 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please find the below code I am using and it actually returns me what I was looking for.

Code:
<%

Dim url
url = "http://apps.doublepositive.com/Suppliers/WebServices/InsertLeads.asmx/InsertLead"

Private Function InsertLead(SupplierId, SupplierPassword, FirstName, LastName, EmailAddress, CoAppFirstName, CoAppLastName, Address, City, State, PostalCode, HomePhone, WorkPhone, WorkPhoneExt, CurrentEmployer, YearsThere, Income, BestCallTime, OriginalLeadDate, ExternalLeadID, IPAddress, ExtraFields)
  Dim queryString
  queryString = "SupplierID=" & SupplierId
  queryString = queryString & "&SupplierPassword=" & SupplierPassword
  queryString = queryString & "&FirstName=" & FirstName
  queryString = queryString & "&LastName=" & LastName
  queryString = queryString & "&EmailAddress=" & EmailAddress
  queryString = queryString & "&CoAppFirstName=" & CoAppFirstName
  queryString = queryString & "&CoAppLastName=" & CoAppLastName
  queryString = queryString & "&Address=" & Address
  queryString = queryString & "&City=" & City
  queryString = queryString & "&State=" & State
  queryString = queryString & "&PostalCode=" & PostalCode
  queryString = queryString & "&HomePhone=" & HomePhone
  queryString = queryString & "&WorkPhone=" & WorkPhone
  queryString = queryString & "&WorkPhoneExt=" & WorkPhoneExt
  queryString = queryString & "&CurrentEmployer=" & CurrentEmployer
  queryString = queryString & "&YearsThere=" & YearsThere
  queryString = queryString & "&Income=" & Income
  queryString = queryString & "&BestCallTime=" & BestCallTime
  queryString = queryString & "&OriginalLeadDate=" & OriginalLeadDate
  queryString = queryString & "&ExternalLeadID=" & ExternalLeadID 
  queryString = queryString & "&IPAddress=" & IPAddress
  queryString = queryString & "&ExtraFields=" & ExtraFields
  Dim httpReq
  Set httpReq = CreateObject("msxml2.serverxmlhttp.4.0")
  httpReq.Open "GET", url & "?" & queryString, false
  httpReq.Send
  Response.write "<input type=hidden value="& queryString & ">" & "<br><br><br>"
  Set InsertLead = httpReq
End Function

Public Sub Main()
   Dim req
   Set req = InsertLead(Request.form("SupplierID"), Request.form("SupplierPassword"), Request.form("FirstName"), Request.form("LastName"),"", "", "", "", Request.form("City"), Request.form("State"), "",Request.form("HomePhone"), Request.form("HomePhone"), "", "", "", "", "", Request.form("OriginalLeadDate"), Request.form("ExternalLeadID"), "", "DebtAmount=10000")
   'Response.write "<b>" & req.ResponseText & ""
   StringToSearch = req.ResponseText
   'Response.write StringToSearch
   Set RegularExpressionObject = New RegExp

  With RegularExpressionObject
      .Pattern = "<ErrorDescription\b[^>]*>(.*?)</ErrorDescription>"
    .IgnoreCase = True
    .Global = True
  End With
  Set expressionmatch = RegularExpressionObject.Execute(StringToSearch)
  If expressionmatch.Count > 0 Then
      For Each expressionmatched in expressionmatch
          Response.Write "<br><B>Lead Status : " & expressionmatched.Value & "<BR>"
        QCRemarks= expressionmatched.Value
      Next
 End If

  With RegularExpressionObject
      .Pattern = "<LeadID\b[^>]*>(.*?)</LeadID>"
    .IgnoreCase = True
    .Global = True
  End With
  Set expressionmatch = RegularExpressionObject.Execute(StringToSearch)
  If expressionmatch.Count > 0 Then
      For Each expressionmatched in expressionmatch
          Response.Write "<br><B>Lead ID : " & expressionmatched.Value & "<BR>"
        ELeadID= expressionmatched.Value
      Next
 End If

Set adCn = Server.CreateObject("ADODB.Connection")
db= server.mappath("/access_db/ULC_mort.mdb")
session("connStr") = "DBQ=" & db & ";Driver={Microsoft Access Driver (*.mdb)}"
adCn.open session("connStr")
sSql=" Update Mortgage set ExternalLeadID='" & ELeadID & "', QCRemarks='" & QCRemarks & "' where InternalLeadID='" & Request.form("ExternalLeadID") & "'"
'Response.write sSql
adCn.Execute sSql
adCn.Close
Set adCn=Nothing

  With RegularExpressionObject
      .Pattern = "<ClientAvailable\b[^>]*>(.*?)</ClientAvailable>"
    .IgnoreCase = True
    .Global = True
  End With
  Set expressionmatch = RegularExpressionObject.Execute(StringToSearch)
  If expressionmatch.Count > 0 Then
      For Each expressionmatched in expressionmatch
        Response.Write "<br><B>Client Available(Should be True) : " & expressionmatched.Value & "<BR>"
      Next
 End If

Set RegularExpressionObject = nothing

Response.write "<br><br><br><div align=center>Please call up 406-XXX-XXXX and <br> when verifier asks for the LeadID, say - Lead ID is " & ELeadID & "<br> and then verifier will confirm the name.Make sure that Customer doesnt hang up when you are giving the LeadID.</div>"

End Sub

Call Main()

%>
Once again, thanks a lot to all members who helped me till the end of this problem.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I load this xml to a dataset? chepla C# 2005 1 August 11th, 2008 08:51 AM
load XML issue AbrarNazeer XML 5 March 13th, 2008 09:43 AM
Load Xml From String ffbalota J2EE 0 January 24th, 2004 06:30 PM
Load Xml From String ffbalota JSP Basics 0 January 24th, 2004 06:29 PM
Load Xml From String ffbalota Apache Tomcat 0 January 24th, 2004 06:28 PM





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