• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

HttpEx component - Get function reports error

I want to use ActiveExperts HttpEx component to catch answers from reverse geocoding service.
I have problem with Get function. I made the following code :

m_objHttpEx =  CoHttpEx::Create();

WideString url_txt = "http://nominatim.openstreetmap.org/reverse?format=xml&lat=54.354671&lon=18.587120&zoom=18&addressdetails=1";

WideString xxl  =  m_objHttpEx.Get(url_txt.c_bstr());

Open in new window


After execution it's appears error:

[C++ Error] ASOCKETLib_TLB.h(25091): E2188 Expression syntax

The content of this file is :

template <class T> BSTR __fastcall
TCOMIHttpExT<T>::Get(BSTR bstrUrl/*[in]*/)
{
  BSTR bstrResponse = 0;
  OLECHECK(this->Get(, (BSTR*)&bstrResponse));
  return bstrResponse;
}

Open in new window


Error is in the line : OLECHECK(this->Get(, (BSTR*)&bstrResponse));

I contacted with ActiveExperts people but they say that there no error in theirs code and problem is with BCB6 programming.
0
Leo01010101
Asked:
Leo01010101
  • 4
  • 2
1 Solution
 
George TokasCommented:
Hi again,
Looks like ActiveX and OLE component...
You may have trouble with installation of the app...
Anyway,
The error appears in the header?
If yes then looks like it is not your fault....
try this:
Add those lines to your header:
#include <NMHttp.hpp>
#include <Psock.hpp>

And in the source:
AnsiString S;
S = "your url here";
TNMHTTP *Http = new TNMHTTP(Application);
        try
        {
         Http->Get(S);
        }
        catch(...)
        {
         delete Http;
         return "";
        }
        S = Http->Body;
        delete Http;

Now S will have the reply...
It will be useful to make a check in Http->Header for the string "200" that means the reply is valid and check for the rest of the http error codes (404, 403, whatever)...

George Tokas.
0
 
George TokasCommented:
OOOPPPS...
Sorry, the code fragment was inside a class that is why return ""; is there...
You got my pont though...

George.
0
 
Leo01010101Author Commented:
Thank you very much for support. It's working. The problem for me could appear when I want to migrate with my software to latest version of C++ Builder where TNMHTTP component will be not available.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
George TokasCommented:
Yes that is true...
But there are the commercial components from netmasters you can use...
Also I am thinking to create similar components based on Indy code with modifications for non blocking support...
Done that for a time replacement some years back...
Time to do the same and for those I think...

George.

P.S. Don't forget HTTP error handling... Also be sure that the PC is connected to the network. This can be implemented by reading the local IP. A not connected PC has ALWAYS 127.0.0.1.
0
 
Leo01010101Author Commented:
I didn't know netmasters components. I have to find it. Year ago I bought license for ActiveExperts ActiveSockets components. But I have problems as I show today with BCB6 implementation.
0
 
George TokasCommented:
People from TeamB and especially Remy Lebau (Gambit47) for long time stated that netmasters components are full of bugs.
In my experience they are working almost fine.
Remy is a friend and author also on the magazine I am publishing articles and VERY good.
We have some differences though on socket configuration and using, I am fan of non blocking and he is a fan of thread blocking...
Anyway netmasters is a company and since BCB6 their components (a version of) was present on BCB tool palette. After 2006 version we have to buy them.

George.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now