More - Post Command Problem looks like a RunRev problem?

Dave dave at looktowindward.com
Tue Nov 18 08:39:04 EST 2008


Hi Mark,

I've tried it using a file, and with the code below, the command gets  
sent but shell doesn't return.

The there is one function that wraps the "post" command, here it is  
along with the :

constant kUseRunRevPostCommand="false"

function LibSoapPostCommand  
theHTTPHeader,theSOAPEnvelope,theSoapURL, at theSoapReply, at theSoapResponse
   local myShellCommand
   local myCommandLineResponse
   local myShellResult
   local myFilePathName

     get StackLogStringWithTime(cr & cr &  
"---------------------------------------------------------------" &  
cr & cr)
     get StackLogStringWithTime("theSoapURL:" && theSoapURL)
     get StackLogStringWithTime("theSOAPEnvelope:" && theSOAPEnvelope)

  if kUseRunRevPostCommand = true then
     try
       set the httpheaders to theHTTPHeader
       --libUrlSetSSLVerification false

       --
       --  Post the Data
       --
       post theSOAPEnvelope to url theSoapURL

       --
       -- Catch Time-Out Errors
       --
     catch myError
       put the result into theSoapResponse
       put it into theSoapReply
       get StackLogStringWithTime("TIME-OUT - theSoapResponse:" &&  
theSoapResponse)
       get StackLogStringWithTime("theSoapReply:" && theSoapReply)
       return empty
     end try

     --
     --  Retreive Results
     --
     put the result into theSoapResponse
     put it into theSoapReply
     get StackLogStringWithTime("theSoapResponse:" && theSoapResponse)
     get StackLogStringWithTime("theSoapReply:" && theSoapReply)

   else
     breakpoint
     put UtilStackGetTempFolderPathName() & "CURLTemp.txt" into  
myFilePathName
     put theSOAPEnvelope into url("file:" & myFilePathName)

     put "curl -s" into myShellCommand
     repeat for each line myHeaderLine in theHTTPHeader
       put " -H '" & myHeaderLine & "' " after myShellCommand
     end repeat

     put "-d @" & myFilePathName && theSoapURL after myShellCommand
     put shell(myShellCommand) into myCommandLineResponse
     put the result into myShellResult

     put myCommandLineResponse into theSoapResponse
     put myShellResult into theSoapReply

     get StackLogStringWithTime("theSoapResponse:" && theSoapResponse)
     get StackLogStringWithTime("theSoapReply:" && theSoapReply)

     delete file myFilePathName
   end if

   return empty
end LibSoapPostCommand

------------------------------------------------------
This is the contents of the temp file:
------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ccn2="http://schemas.datacontract.org/2004/07/ 
ServiceContracts.Data"
xmlns:ccn3="http://schemas.microsoft.com/2003/10/Serialization/Arrays"
xmlns:i0="http://bam.com/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>

</SOAP-ENV:Header>
<SOAP-ENV:Body>
<DbPing xmlns="http://bam.com/">
</DbPing>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

------------------------------------------------------

This is the Shell Command:

curl -s -H 'Accept: text/xml'  -H 'Accept: multipart/*'  -H 'Content- 
length: 689'  -H 'Content-Type: text/xml; charset=utf-8'  -H  
'SOAPAction: "http://bandyaboutmusic.com/GenX/IAccountService/ 
DbPing"' -d @/Documents/Programming/RunRevBase/Projects/GenX/RunTime/ 
Temp/CURLTemp.txt http://britservices.genxdev.com/Account.svc?wsdl

When I run this from RunRev the shell() function never returns, the  
same happens if I run it from the command line.

Thanks a lot
Dave

On 17 Nov 2008, at 16:32, Mark Smith wrote:

> Sorry, I should have said, the library requires 2.9.
>
> How big is the data you're sending? I've had trouble putting large  
> amounts of data on the command line (maybe a limitation of rev's  
> 'shell' call, or something else). I was suggesting this mainly as a  
> way fo see if it gave you any indication of what the problem might  
> be, whether or not it would be useful in 'production'.
> Anyway, you could certainly try passing the soap envelope on the  
> command line (does writing it to a file really slow it down all  
> that much?).
> Anyway, you'll need to url encode the data, so something like
>
> put "curl -s" into tCurlStr
>
> repeat for each line L in myHttpHeaders -- if you're only setting  
> one header, you don't need a repeat, of course.
>   put " -H" && "'" & L & "'" after tCurlStr
> end repeat
>
> put " -d" && "-" && quote & urlencode(mySoapEnvelope) & quote &&  
> tUrl after tCurlStr
> put shell(tCurlStr) into tResponse
>
> I think libUrl only ever puts errors into the result. What the  
> shell call returns will be either the returned data, or an error  
> (though the result may contain something if there was an error in  
> the shell call itself).
>
> Also, I've just realised that if you do need to write to a  
> tempfile, the line should be:
> put " -d" && "@" & tFile && tUrl after tCurlStr
>
>
> Best,
>
> Mark
>
> On 17 Nov 2008, at 16:10, Dave wrote:
>
>> Hi,
>>
>> Thanks for this. I looked at your library and found that it won't  
>> run under RunRev 2.8.1.472 which is what I am using.
>>
>> Writing to a file will slow it down, do I *have* to use a file? If  
>> not, how would I format the command?
>>
>> Also there are two return variables using the post command and I  
>> need to return both:
>>
>> post mySoapEnvelope to url mySoapURL
>> put it into myReply
>> put the result into myResult
>>
>> How can I do this using the shell command?
>>
>> Would it be worth replacing the internet library from the latest  
>> version of RunRev? Will this work? Are they compatible?
>>
>> All the Best
>> Dave
>>
>> On 17 Nov 2008, at 15:21, Mark Smith wrote:
>>
>>> Dave, you'll need something like this:
>>>
>>> put the tempname into tFile
>>> put mySoapEnvelope into url("file:" & tFile) -- this is so we  
>>> don't pass a load of data on the command line
>>> put "curl -s" into tCurlStr
>>>
>>> repeat for each line L in myHttpHeaders -- if you're only setting  
>>> one header, you don't need a repeat, of course.
>>>   put " -H" && "'" & L & "'" after tCurlStr
>>> end repeat
>>>
>>> put " -d" && tFile && tUrl after tCurlStr
>>> put shell(tCurlStr) into tResponse
>>> delete file tFile -- cleanup
>>>
>>>
>>> If you want to see the whole exchange including headers and  
>>> everything, then replace "-s" with "-v" in the third line.
>>>
>>> Alternatively, you could try my library (http:// 
>>> futsoft.futilism.com/revolutionstuff.html),
>>> in which case it would be
>>>
>>> put curl.new() into tCurl
>>> curl.setUrl tCurl, tUrl
>>> curl.setHeaders  tCurl, myHttpHeaders
>>> curl.setPostData tCurl, mySoapEnvelope
>>> put curl.runTilDone(tCurl) into tResponse
>>>
>>>
>>> Best,
>>>
>>> Mark
>>>
>>>
>>> On 17 Nov 2008, at 14:40, Dave wrote:
>>>
>>>> Hi Mark,
>>>>
>>>> I can't figure out the correct format for the "curl" command, or  
>>>> how to call it from RunRev.
>>>>
>>>> Given that the current post command looks like this:
>>>>
>>>> set the httpHeaders to myHTTPHeader
>>>> post mySoapEnvelope to url mySoapURL
>>>> put it into myReply
>>>> put the result into myResult
>>>>
>>>> How would I do this using curl? The function to send the command  
>>>> is called from all over the place so I would have to change it  
>>>> in the low level function, if so then the above is the only data  
>>>> I can get at and I have to return myReply and myResult in the  
>>>> same format as the post command would use.
>>>>
>>>> Is this possible using curl?
>>>>
>>>> Thanks a lot
>>>> All the Best
>>>> Dave
>>>>
>>>> On 17 Nov 2008, at 12:00, Mark Smith wrote:
>>>>
>>>>> Dave, I wonder if it would be worth trying to do the post using  
>>>>> curl (or some other tool) to see if the problem still occurs?
>>>>>
>>>>> Also, have you looked at what actual bytes the truncated  
>>>>> response ends with ie. is the server sending back something weird?
>>>>>
>>>>> Best,
>>>>>
>>>>> Mark
>>>>>
>>>>> On 17 Nov 2008, at 11:29, Dave wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> Please see below for the history of this problem. Since then I  
>>>>>> have some more information:
>>>>>>
>>>>>> I installed WireShark and recreated the problem. When I look  
>>>>>> at the captured information, it looks as if the response is  
>>>>>> being sent and received by server/client ok. It shows a number  
>>>>>> of TCP packets (TCP Segment of a reassembled PDU) and then one  
>>>>>> block that shows as HTTP/XML. When I select this block it  
>>>>>> shows the packet reassembled as 23782 bytes. However when the  
>>>>>> error occurs, the response return by the RunRev post command  
>>>>>> only shows the first 2736 bytes, e.g. the rest of the  
>>>>>> reassembled block is truncated. I have the dumps as text files  
>>>>>> but they are too big to post here.
>>>>>>
>>>>>> When I looked up the post command in RunRev it says it is part  
>>>>>> of the internet library, however I can't find any source code  
>>>>>> for this. Is it available? I'd like to add some trace  
>>>>>> information so I can see if this library is being passed the  
>>>>>> whole block and if so why is it going wrong on this block.
>>>>>>
>>>>>> Is there another way to do this in RunRev? e.g. A alternative  
>>>>>> to the "post" command?
>>>>>>
>>>>>> Any ideas or suggestions on how to fix or even get a handle of  
>>>>>> this problem would be greatly appreciated.
>>>>>>
>>>>>> All the Best
>>>>>> Dave
>>>>>>
>>>>>> ------
>>>>>>
>>>>>> I read records from a database, format them, and add them to a  
>>>>>> block of data. There is a blocking factor variable, it is set  
>>>>>> to 200, so I read 200 records from the database, block them  
>>>>>> into one big block and send it to the server via a "post"  
>>>>>> command. The Server then sends a response which can be  
>>>>>> variable in length, the response is in XML format. This  
>>>>>> process works well 99% of the time, but sometimes, (and this  
>>>>>> can be reproduced if the right data (or the wrong data in this  
>>>>>> case!) is present in the database). When this happens the  
>>>>>> response from the server is truncated in the middle of an XML  
>>>>>> node. As far as I can tell the difference is that by chance, a  
>>>>>> group of 200 records has caused the response to be over a  
>>>>>> certain size.
>>>>>>
>>>>>> If I set the BlockingFactor to 50, the problem goes away, but  
>>>>>> this causes a major slowdown.
>>>>>>
>>>>>> ------
>>>>>>
>>>>>> It is sending one block at a time, each block contains N  
>>>>>> records. There are around 10,500 records in the database.
>>>>>>
>>>>>> Each record has an XML node in the reply, depending on the  
>>>>>> content of the record sent, it will return different data of  
>>>>>> variable size. It appears if the block returned is greater  
>>>>>> than a certain size, it is truncated.
>>>>>>
>>>>>> Basically the process is:
>>>>>>
>>>>>> repeat for all Records in Database
>>>>>> Read Record From Database
>>>>>> Encode as XML
>>>>>> Add to end of SendDataBlock
>>>>>>
>>>>>> if the number of records in SendDataBloack >  
>>>>>> SendBlockingFactor then
>>>>>>   post SendDataBlock
>>>>>>   get response
>>>>>>   process response
>>>>>>   put empty into SendDataBlock
>>>>>> end if
>>>>>>
>>>>>> end repeat
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> use-revolution mailing list
>>>>>> use-revolution at lists.runrev.com
>>>>>> Please visit this url to subscribe, unsubscribe and manage  
>>>>>> your subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>>>
>>>>> _______________________________________________
>>>>> use-revolution mailing list
>>>>> use-revolution at lists.runrev.com
>>>>> Please visit this url to subscribe, unsubscribe and manage your  
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>>
>>>>
>>>> _______________________________________________
>>>> use-revolution mailing list
>>>> use-revolution at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your  
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your  
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list