Archived Forum Post

Index of archived forum posts

Question:

Using Chilkat with FoxPro and FedEx

Feb 10 '13 at 10:02

Hi all.

I'm sort of new at this and a bit lost. What I am trying to do is to get shipping rate information from FedEx. Here is the code I have so far. Can someone help please? Line numbers are added for reference. I have download and installed the activex control.

<% 1. strXML=alltrim(FILETOSTR("fedex.xml")) && Load in XML file. 2. loHTTP = CreateObject('Chilkat.XML') 3. loReq = CreateObject('Chilkat.HttpRequest') &&ERROR - Class definition CHILKAT.HTTPREQUEST is not found. 4. loResp = loHttp.PostUrlEncoded("https://gateway.fedex.com:443/xml",strXML) 5. IF (loResp = NULL ) THEN 6. ? loHttp.LastErrorText 7. QUIT 8. ENDIF 9. loXml2 = loXml.GetChildWithTag("RequestHeader") 10. loXml3 = loXml2.GetChildWithTag("AccountNumber") 11. response.write(loXml3.Content) %>

When I run this I get the following error: Error #: 1733 Message: Class definition CHILKAT.HTTPREQUEST is not found. Program: c:inetpubx-laserfedex.fxp Line #: 3 Line: loReq = CreateObject('Chilkat.HttpRequest')

Along with this I also need to get the response from FedEx. Can anyone help please?

Joe


Answer

Sorry, I posted again because I saw that my original post above was concatenated. I hope this is more helpful.

<%
1. strXML=alltrim(FILETOSTR("fedex.xml")) && Load in XML file.
2. loHTTP = CreateObject('Chilkat.XML')
3. loReq = CreateObject('Chilkat.HttpRequest') &&ERROR - Class definition CHILKAT.HTTPREQUEST is not found.
4. loResp = loHttp.PostUrlEncoded("https://gateway.fedex.com:443/xml",strXML)
5. IF (loResp = NULL ) THEN
6.    ? loHttp.LastErrorText
7.    QUIT
8. ENDIF
9. loXml2 = loXml.GetChildWithTag("RequestHeader")
10. loXml3 = loXml2.GetChildWithTag("AccountNumber")
11. response.write(loXml3.Content) %>

When I run this I get the following error:

Error #: 1733 Message: Class definition CHILKAT.HTTPREQUEST is not found. Program: fedex.fxp Line #: 3 Line: loReq = CreateObject('Chilkat.HttpRequest')

Along with this I also need to get the response from FedEx. Can anyone help please?


Answer

You have the wrong CLSIDs for the Chilkat objects.

HTTP Request should be: CreateObject('ChilkatHttp.ChilkatHttpRequest')
XML Should be: CreateObject('ChilkatXml.ChilkatXml')

In fact, I'm surprised you didn't get an error on line 2.

Also, it seems that you are setting your loHTTP variable to a ChilkatXML object, but then calling methods as if it were a ChilkatHttp object. Are you sure line #2 shouldn't have been:

loHTTP = CreateObject('ChilkatHttp.ChilkatHttp')

?

Lastly, you can get the response content by using loResp.Body after you've tested for NULL in your example code.