Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ builder 6 and web service

237 views
Skip to first unread message

mg

unread,
Jul 2, 2008, 9:20:34 AM7/2/08
to
Hi,
I've a problem using webservice in my client application.

My program use webservice linked by "WSDL Import" command.

WebService has a function "AddNewPhoto(const TByteDynArray photoStream)"
that transfer an image (stream of byte) from local pc to
web.

For some reason i receive an error that i can't intercept (using
try..catch); probabily caused by a timeout (the image is not big, less
than 1 MByte).

How i can catch this error or increase time before timeout error?

Thanks

Jean-Marie Babet

unread,
Jul 3, 2008, 4:06:31 PM7/3/08
to
Hello Mg,

I'm not sure if the CBuilder 6 version of the component exposed the timeout
properties back then. Basically we use WinInet for the HTTP transport and
the latter has APIs to set the timeout. You may need to change your copy of
SOAPHTTPTrans.pas directly to add this functionality and then build with
that .pas file or with an .obj created from that .pas. The logic must be
added to THTTPReqResp.Send as follows:


Request := nil;
try
Request := HttpOpenRequest(FInetConnect, 'POST', PChar(FURLSite), nil,
nil, Pointer(AcceptTypes), Flags, Integer(Self));
Check(not Assigned(Request));

{Here's the code added for timeout support }
if _ConnectTimeout > 0 then
Check(not InternetSetOption(Request, INTERNET_OPTION_CONNECT_TIMEOUT,
Pointer(@_ConnectTimeout), SizeOf(_ConnectTimeout)));
if _SendTimeout > 0 then
Check(not InternetSetOption(Request, INTERNET_OPTION_SEND_TIMEOUT,
Pointer(@_SendTimeout), SizeOf(_SendTimeout)));
if _ReceiveTimeout > 0 then
Check(not InternetSetOption(Request, INTERNET_OPTION_RECEIVE_TIMEOUT,
Pointer(@_ReceiveTimeout), SizeOf(_ReceiveTimeout)));
{End of code added for timeout support }

{ SOAPAction header }
ActionHeader:= GetSOAPActionHeader;
HttpAddRequestHeaders(Request, PChar(ActionHeader),
Length(ActionHeader), HTTP_ADDREQ_FLAG_ADD);


In later versions _ConnectTimeout, _SendTimeout and _ReceiveTimeout are
fields of the class [with the leading '_' as 'F']. In your case you can have
them as global variables that you can set as needed.

Cheers,

Bruneau


max

unread,
Jul 4, 2008, 10:44:19 AM7/4/08
to
Thanks a lot.

I've modified has you say, but some question.
[1]
You said "...and then build with that .pas file or with an .obj created from that .pas...". What means? I must include that .pas in my project and then build all, or what?
[2]
You said "...In your case you can have them as global variables that you can set as needed...". What means? I must set these variables in file SOAPHTTPTrans.pas before build my project or where?

Jean-Marie Babet

unread,
Jul 13, 2008, 3:36:05 PM7/13/08
to
Hello,

> I've modified has you say, but some question.
> [1]
> You said "...and then build with that .pas file or with an .obj created
from that .pas...". What means? I must include that .pas in my project and
then build all, or what?


Yes, you can add the .pas file to your project. This is the fastest
approach. However, if you have lots of projects, it might be easier to
rebuild the .hpp and .obj file after you've applied the change, then insert
the .obj in the .lib. The latter will be useful in cases where you have the
libraries checked in and you want to update everyone.


> [2]
> You said "...In your case you can have them as global variables that you
can set as needed...". What means? I must set these variables in file
SOAPHTTPTrans.pas before build my project or where?

Yes, I was suggesting that you declare the 3 variables [_xxxxTimeout] as
global variables in the interface section of SOAPHTTPTrans.pas. When you
rebuild the file, SOAPHTTPTrans.hpp will contain these 3 variables as
extern. That way your C++ code can set them to something > 0 so the calls to
WinInet are executed at runtime.


Feel free to email me a copy of you SOAPHTTPTrans.pas and I'll be happy to
modify the file to illustrate. I can probably find a copy of CBuilder6
around and rebuild the .hpp and .obj for you too.

Cheers,

Bruneau

PS: I can be reached at bbabet at codegear dot net.


0 new messages