On Wed, 16 Mar 2005 13:12:48 -0800, JH <baiy
...@gmail.com> wrote:
> Hello all,
> I am geting "500 Internal Server Error" when using API with XML.
> Anybody have similar experience? I appreciate any help. Here is my
> code for request (with login credentials removed):
> ** URL for the web service
> lcUrl =
> "https://adwords.google.com/api/adwords/v2/TrafficEstimatorService"
> ** create a placeholder for the return message
> loReturn = CREATEOBJECT("Line")
> loReturn.AddProperty("FullMessage", null)
> loReturn.AddProperty("Message", null)
> loReturn.AddProperty("lError", .F.)
> loReturn.AddProperty("ErrorMessage", null)
> *** Build the SOAP:Envelope
> lcEnvelope = ""
> lcEnvelope = lcEnvelope + [<?xml version="1.0"?>]
> lcEnvelope = lcEnvelope + [<soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns="https://adwords.google.com/api/adwords/v2">]
> lcEnvelope = lcEnvelope + [<soap:Header>]
> lcEnvelope = lcEnvelope + [<email>myemail</email>]
> lcEnvelope = lcEnvelope + [<password>mypassword</password>]
> lcEnvelope = lcEnvelope + [<token>mytoken</token>]
> lcEnvelope = lcEnvelope + [</soap:Header>]
> lcEnvelope = lcEnvelope + [<soap:Body>]
> lcEnvelope = lcEnvelope + [<estimateKeywordList>]
> lcEnvelope = lcEnvelope + [<keywordRequests>]
> lcEnvelope = lcEnvelope + [<type>Broad</type>]
> lcEnvelope = lcEnvelope + [<text>hello</text>]
> lcEnvelope = lcEnvelope + [<maxCpc>50000</maxCpc>]
> lcEnvelope = lcEnvelope + [</keywordRequests>]
> lcEnvelope = lcEnvelope + [</estimateKeywordList>]
> lcEnvelope = lcEnvelope + [</soap:Body>]
> lcEnvelope = lcEnvelope + [</soap:Envelope>]
> ** show the message sent to the server
> STRTOFILE(lcEnvelope, "xmlsend.xml")
> *** Create the XMLHttp request object
> loHTTP = CREATE("Microsoft.XMLHTTP")
> * Add request headers
> loHTTP.Open("POST", lcURL, .T.)
> loHTTP.setRequestHeader("Content-Type:", "text/xml")
> loHTTP.setRequestHeader("SOAPAction:", "TrafficEstimatorService")
> loHTTP.Send(lcEnvelope)
> Sleep(5000)
> loReturn.Message = ""
> loReturn.FullMessage = ""
> IF loHTTP.Status <> 200
> loReturn.lError = .T.
> loReturn.ErrorMessage = TRANSFORM(loHTTP.Status) + " : " +
> loHTTP.StatusText
> loReturn.FullMessage = "<RETURN>" + TRANSFORM(loHttp.status) +
> "</RETURN>"
> loReturn.Message = ""
> ELSE
> loReturn.FullMessage = loHTTP.responseXML.XML
> loReturn.Message = loReturn.FullMessage
> ENDIF
> ENDIF
> loHTTP = .NULL.
> ** show the message returned from the server
> STRTOFILE(loReturn.FullMessage, "xmlreceive.xml")
> RETURN