[mapguide-dev] Re:

alucas at srtec.com alucas at srtec.com
Fri Apr 21 16:49:38 EDT 2006


Hi Alain,

I'm analyzing the sources for understanding its internal architecture. If
I use the high level web-api, I don't understand nothing. On the other
hand, if I want to connect from a remote desktop application to the
server, I think that a HTTP connection is not the best choice.

Thanks.

> Antonio,
>
>
>
> I wouldn't recommend using directly TCP/IP to communicate with the
> MapGuide server. You will have to format the TCP/IP stream in a way that
> conforms to MapGuide's application protocol, and there's no guarantee it
> won't change, breaking your application if it does. Why reimplementing
> something that the web-tier provides for you and lets you use at a higher
> level in a very simple way?  From a .NET application it's very easy to
> communicate with the MapGuide server. There are only 4 steps:
>
>
>
> 1)       Initialize the web tier:
>
>
>
> MapGuideAPI.MgInitializeWebTier(@"c:\someplace\webconfig.ini");
>
>
>
> 2)       Open a connection with the server (here logging as admin just for
> the example)
>
>
>
>         MgUserInformation user = new MgUserInformation("Administrator",
> "admin");
>
>         MgSiteConnection site = new MgSiteConnection();
>
>         site.Open(user);
>
>
>
> 3)       Get the service that handles the API you want to call. If you
> want a map rendered that's rendering service
>
>
>
>       MgRenderingService renderingSrvc =
> site.CreateService(MgServiceType.RenderingService) as
> MgRenderingService;
>
>
>
> 4)       Call the API in the server:
>
>
>
> MgByteReader mapBytes = renderingSrvc.RenderMap(map, null, "PNG");
>
>
>
> As you know now all these classes are defined in MapGuideDotNetApi.dll so
> all you need to do is add a reference to that DLL in your project.
>
>
>
> Alain
>
>   _____
>
> From: "Antonio Lucas Rodríguez (sr&tec)" [mailto:alucas at srtec.com]
> Sent: Friday, April 21, 2006 3:16 AM
> To: Traian Stanev; dev at mapguide.osgeo.org
> Subject: [mapguide-dev] Re:
>
>
>
> Traian Stanev wrote:
>
> OK I understand what you are trying to do. If you want to use TCP/IP you
> should look at the library that the web extensions use to communicate
> with the server. All the server APIs are actually also implemented in
> that library as "proxy" APIs that use TCP to forward the calls to the
> server and then read the results. May be instead of writing code from
> scratch, you can use or modify that code. The nice thing about it is
> that the compilation process for the web extensions automatically
> generates a .Net wrapper for the proxy APIs, which you should just be
> able to add a reference to from C# and use it to communicate with the
> server via TCP/IP.
>
> The .Net API wrappers get installed with the ASP web extensions (it's
> MapGuideDotNetApi.dll), but you can also open the web extensions
> solution to look at the C++ code that gets published to the .Net
> wrapper, or even compile your own API wrappers.
>
> Looking at the code itself... in the Service project, under the Services
> folder you can see how the server APIs are also implemented as Proxy
> objects that basically do the API call to the server via TCP. For
> example look at ProxyRenderingService.cpp, at the function
> MgProxyRenderingService::RenderMap. This is the proxy for the
> MgServerRenderingService::RenderMap call. You will see how all it does
> is issue a command with the correct arguments. Then if you dig into
> ExecuteCommand you will see how the arguments get serialized to a stream
> and written to the server port. The result is then read from the port.
>
> Traian
>
>
>
> -----Original Message-----
> From: alucas at srtec.com [mailto:alucas at srtec.com]
> Sent: Wednesday, April 19, 2006 5:38 PM
> To: Traian Stanev
> Subject:
>
> Hello Traian,
>
> First of all, thank you very match for your attention. So, your mail has
> been very useful for me. I'm planning create a test application that
> connect via TCP/IP to the mgserver service from a test c# or c++
> application for example to get a PNG from the repository.
> So, what are the necessary steps to follow? Any sample code would be
> very
> useful for me...
>
> Thanks in advance.
>
>
> Antonio Lucas
>
> Software Engineer
> SER&TEC S.L
> Phone: +34 96 395 95 13
> www.srtec.com
> Valencia (Spain)
>
>
>
>
>
>
>
> Thanks Traian,
>
> It's very useful for me. It's a pity that this things are not documented.
> I've build WebTier.sln, it generates the following dll's:
>
> ACE.dll
> MapguideDotNetApi.dll
> MapguideJavaApi.dll
> MapguideUnmanagedApi.dll
> MgCommon.dll
> MgCoordinateSystem.dll
> MgHttpHandler.dll
> MgMdfModel.dll
> MgMdfParser.dll
> MgWebApp.dll
> PhpMapguideApi.dll
> Proj.dll
> xerces-c_2_7.dll
>
> Ok, then I create one simple c# windows form application and add a
> reference to /release/MapGuideDotNetApi.dll. Well, I have the DotNetApi
> reference, the question is how can I connect via TCP/IP with the server
> that runs mapguide? What are the necessary steps?
>
> Thanks.
>
>
>
>
>
> --
>
>   _____
>
> Antonio Lucas
>
> Software Engineer
>
> alucas at srtec.com <mailto:alucas at srtec.com>
>
> www.srtec.com <http://www.srtec.com>
>
>  963·959·513
>
> Fax 963·731·756
>
>
>
>
>
>
>
>
>
> avda. Ausias March 79 - 1
> 46013 Valencia
>
>
>
>


Antonio Lucas

Software Engineer
SER&TEC S.L
Phone: +34 96 395 95 13
www.srtec.com
Valencia (Spain)






More information about the Mapguide_dev mailing list