troubleshooting Question

Accessing a web service from FoxPro code (no WSDL is available)

Avatar of cj4331
cj4331 asked on
12 Comments1 Solution1032 ViewsLast Modified:
I am trying to access the US Postal Service Web Tools address correction service.  If you want to learn more about this service visit  I can do this in VB using the code below.  I have been unable to figure out how to do this in VFP 8 (employer requires use of version 8).  Every example in VFP I see uses a WSDL file but none is available from USPS.  There simply has to be a way to send a url across the web and get a response (an xml file string) in a way that is similar to what I can do in VB.  I really need the code to put in the VFP button written for me, and help understanding it.  I've read enough articles on the web now.  I need an example.

Dim URL As String
        Dim webReq As Net.HttpWebRequest
        Dim webResp As Net.HttpWebResponse
        Dim respStr As String

            URL = "<AddressValidateRequest%" & _
            "20USERID=""myid""><Address ID=""0""><Address1></Address1>" & _
            "<Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State>" & _

            webReq = Net.HttpWebRequest.Create(URL)

            webResp = webReq.GetResponse

            respStr = New IO.StreamReader(webResp.GetResponseStream).ReadToEnd
        Catch ex As Exception
            MessageBox.Show("ex.Message = " & ex.Message)
        End Try

        TextBox1.Text = respStr

NOTE:  I can not actually post my id as I'm not allowed to share it per their usage policy but you can get one free if you need to.  I just put "myid" in my URL where the id goes.

As for my experience I'm a pro at dos style programming in Visual Foxpro and I can do quite a bit in VB nowdays but I've never really caught on to the lingo used today so talk of things like wrappers goes right over my head.  I hope someone here can help.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros