I'm trying to use a dataset returned from a web service in an unmanaged C++
(MFC) client. The dataset is returned as a BSTR, and I'm having trouble
reading the BSTR into an XML document for processing. The data looks correct
in the BSTR. Can anyone help point me in the right direction on this? 4 6816
> I'm trying to use a dataset returned from a web service in an unmanaged C++ (MFC) client. The dataset is returned as a BSTR, and I'm having trouble reading the BSTR into an XML document for processing. The data looks correct in the BSTR. Can anyone help point me in the right direction on this?
If you start from the premise that Web services are designed for software
integration and interoperabilit y that should be vendor, language, platform
and transport neutral, then exposing a DataSet as XML through a Web service
is not a great idea. It only works so long as both endpoints are the same
platform, namely .NET. Sure there are any number of Web services examples
that show a DataSet being sent between services endpoints, but that should
be in no way considered a best practice from a service-orientation
standpoint. You are seeing this platform disconnect, and there never will be
a good solution for consuming a DataSet from a platform that is not .NET.
Moreover, a DataSet is a pretty heavy-weight object to be passing around. It
is really designed for making a round trip with disconnected data: it
supports changing the data while it is disconnected and then reconnecting
and having data resynchronize back up. That takes a fair bit of plumbing in
the DataSet, such as encapsulating multiple tables, relationships, etc.,
providing schema for the data in the document, and maintaining diffgrams of
data as it is changed in the DataSet. All that capability comes at a price,
such as much larger SOAP messages on the wire. I think in the vast majority
of cases where DataSets are shown in Web services examples, they are not
being used to make roundtrip changes in disconnected relational data, they
are merely the container for more or less flat data in one direction. In
such situations you are much better off creating your own light-weight
business- or domain-specific objects, or, if you are using SQL Server,
executing SELECT statements with the FOR XML specification. Not only will
they result in smaller messages on the wire, they will be consumable from
platforms other than .NET.
Cheers,
Stuart Celarier, Fern Creek
Thank you Stuart!
I was starting to come to the same conclusion myself. I've started looking
at using an XmlDataDocument as the return type for my data. I'm not sure if
that's a better solution than using my own structures. Any thoughts? One
article I read prefererred the XmlDataDocument approach, because it used less
memory on the server...
Gordon
"Stuart Celarier" wrote: I'm trying to use a dataset returned from a web service in an unmanaged C++ (MFC) client. The dataset is returned as a BSTR, and I'm having trouble reading the BSTR into an XML document for processing. The data looks correct in the BSTR. Can anyone help point me in the right direction on this?
If you start from the premise that Web services are designed for software integration and interoperabilit y that should be vendor, language, platform and transport neutral, then exposing a DataSet as XML through a Web service is not a great idea. It only works so long as both endpoints are the same platform, namely .NET. Sure there are any number of Web services examples that show a DataSet being sent between services endpoints, but that should be in no way considered a best practice from a service-orientation standpoint. You are seeing this platform disconnect, and there never will be a good solution for consuming a DataSet from a platform that is not .NET.
Moreover, a DataSet is a pretty heavy-weight object to be passing around. It is really designed for making a round trip with disconnected data: it supports changing the data while it is disconnected and then reconnecting and having data resynchronize back up. That takes a fair bit of plumbing in the DataSet, such as encapsulating multiple tables, relationships, etc., providing schema for the data in the document, and maintaining diffgrams of data as it is changed in the DataSet. All that capability comes at a price, such as much larger SOAP messages on the wire. I think in the vast majority of cases where DataSets are shown in Web services examples, they are not being used to make roundtrip changes in disconnected relational data, they are merely the container for more or less flat data in one direction. In such situations you are much better off creating your own light-weight business- or domain-specific objects, or, if you are using SQL Server, executing SELECT statements with the FOR XML specification. Not only will they result in smaller messages on the wire, they will be consumable from platforms other than .NET.
Cheers, Stuart Celarier, Fern Creek
Gordon wrote: ... I've started looking at using an XmlDataDocument as the return type [of a WebMethod] for my data. I'm not sure if that's a better solution than using my own structures. Any thoughts?
Go ahead and try to create a WebMethod that returns
System.Xml.XmlD ataDocument like this:
[WebMethod]
public XmlDataDocument GetXmlDataDocum ent()
{
return new XmlDataDocument ();
}
Compile and run. You get back this:
Server Error in '[...]' Application
Cannot serialize type System.Xml.XmlD ataDocument. Please consider using
XmlDocument, XmlElement or XmlNode instead.
So that's not very promising. : ) Let's back up and look at the
architecture. There are four different concepts that should be kept
distinct. From the backend working forwards, there is the data source (e.g.,
database), a data access layer (e.g., ADO.NET), your business entities, and
finally a service interface that exposes entity services. These are
illustrated in Figure 1 in [1]. The service interface is explored in depth
here [2].
One way to approach service interface design is referred to as
contract-first [3]. This parallels the best practice of COM components to
design the the interface first and do it in the interface language. In other
words, approach this problem from how you'd like to consume the service, not
how you intend to implement the service.
Cheers,
Stuart Celarier, Fern Creek
[1] http://msdn.microsoft.com/library/en...redSvcsApp.asp
[2] http://msdn.microsoft.com/library/en...eInterface.asp
[3] http://weblogs.asp.net/cweyer/archiv.../21/39070.aspx
One article I read prefererred the XmlDataDocument approach, because it used less memory on the server...
Gordon
"Stuart Celarier" wrote:
> I'm trying to use a dataset returned from a web service in an unmanaged > C++ > (MFC) client. The dataset is returned as a BSTR, and I'm having > trouble > reading the BSTR into an XML document for processing. The data looks > correct > in the BSTR. Can anyone help point me in the right direction on this?
If you start from the premise that Web services are designed for software integration and interoperabilit y that should be vendor, language, platform and transport neutral, then exposing a DataSet as XML through a Web service is not a great idea. It only works so long as both endpoints are the same platform, namely .NET. Sure there are any number of Web services examples that show a DataSet being sent between services endpoints, but that should be in no way considered a best practice from a service-orientation standpoint. You are seeing this platform disconnect, and there never will be a good solution for consuming a DataSet from a platform that is not .NET.
Moreover, a DataSet is a pretty heavy-weight object to be passing around. It is really designed for making a round trip with disconnected data: it supports changing the data while it is disconnected and then reconnecting and having data resynchronize back up. That takes a fair bit of plumbing in the DataSet, such as encapsulating multiple tables, relationships, etc., providing schema for the data in the document, and maintaining diffgrams of data as it is changed in the DataSet. All that capability comes at a price, such as much larger SOAP messages on the wire. I think in the vast majority of cases where DataSets are shown in Web services examples, they are not being used to make roundtrip changes in disconnected relational data, they are merely the container for more or less flat data in one direction. In such situations you are much better off creating your own light-weight business- or domain-specific objects, or, if you are using SQL Server, executing SELECT statements with the FOR XML specification. Not only will they result in smaller messages on the wire, they will be consumable from platforms other than .NET.
Cheers, Stuart Celarier, Fern Creek
Stuart,
Sorry it has taken so long for me to respond. I vey much appreciate your
thoughtful response. You've given me a lot of useful information to digest.
Now, I've got a lot of work to do!
Gordon
"Stuart Celarier" wrote: Gordon wrote: ... I've started looking at using an XmlDataDocument as the return type [of a WebMethod] for my data. I'm not sure if that's a better solution than using my own structures. Any thoughts?
Go ahead and try to create a WebMethod that returns System.Xml.XmlD ataDocument like this:
[WebMethod] public XmlDataDocument GetXmlDataDocum ent() { return new XmlDataDocument (); }
Compile and run. You get back this:
Server Error in '[...]' Application Cannot serialize type System.Xml.XmlD ataDocument. Please consider using XmlDocument, XmlElement or XmlNode instead.
So that's not very promising. : ) Let's back up and look at the architecture. There are four different concepts that should be kept distinct. From the backend working forwards, there is the data source (e.g., database), a data access layer (e.g., ADO.NET), your business entities, and finally a service interface that exposes entity services. These are illustrated in Figure 1 in [1]. The service interface is explored in depth here [2].
One way to approach service interface design is referred to as contract-first [3]. This parallels the best practice of COM components to design the the interface first and do it in the interface language. In other words, approach this problem from how you'd like to consume the service, not how you intend to implement the service.
Cheers, Stuart Celarier, Fern Creek
[1] http://msdn.microsoft.com/library/en...redSvcsApp.asp [2] http://msdn.microsoft.com/library/en...eInterface.asp [3] http://weblogs.asp.net/cweyer/archiv.../21/39070.aspx
One article I read prefererred the XmlDataDocument approach, because it used less memory on the server...
Gordon
"Stuart Celarier" wrote:
> I'm trying to use a dataset returned from a web service in an unmanaged > C++ > (MFC) client. The dataset is returned as a BSTR, and I'm having > trouble > reading the BSTR into an XML document for processing. The data looks > correct > in the BSTR. Can anyone help point me in the right direction on this?
If you start from the premise that Web services are designed for software integration and interoperabilit y that should be vendor, language, platform and transport neutral, then exposing a DataSet as XML through a Web service is not a great idea. It only works so long as both endpoints are the same platform, namely .NET. Sure there are any number of Web services examples that show a DataSet being sent between services endpoints, but that should be in no way considered a best practice from a service-orientation standpoint. You are seeing this platform disconnect, and there never will be a good solution for consuming a DataSet from a platform that is not .NET.
Moreover, a DataSet is a pretty heavy-weight object to be passing around. It is really designed for making a round trip with disconnected data: it supports changing the data while it is disconnected and then reconnecting and having data resynchronize back up. That takes a fair bit of plumbing in the DataSet, such as encapsulating multiple tables, relationships, etc., providing schema for the data in the document, and maintaining diffgrams of data as it is changed in the DataSet. All that capability comes at a price, such as much larger SOAP messages on the wire. I think in the vast majority of cases where DataSets are shown in Web services examples, they are not being used to make roundtrip changes in disconnected relational data, they are merely the container for more or less flat data in one direction. In such situations you are much better off creating your own light-weight business- or domain-specific objects, or, if you are using SQL Server, executing SELECT statements with the FOR XML specification. Not only will they result in smaller messages on the wire, they will be consumable from platforms other than .NET.
Cheers, Stuart Celarier, Fern Creek This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Frank Lopez |
last post by:
Does anyone know if Microsoft generated a whitepaper on this topic?
Does anyone know what the solution is? (meaning, eliminate the leak
problem -- I am seeing three memory leaks from dllmodul.cpp(102)
similar to what is mentioned below)...
I am calling MFC as part of unmanaged code used by the managed code.
+--------
|
by: |
last post by:
I am stuck in a situation and I do believe that this should work, but it
doesn't.
I have a unmanaged dll, that uses MFC. This works great.
Now I recompile the unmanaged dll so it contains mixed mode
managed/unmanaged code, but only use unmanaged code, but this gives a error
the moment I want to display a MFC dialog box: Something like unreferenced
object,... during runtime.
|
by: William F. Kinsley |
last post by:
I am thinking of porting an existing MFC application to MC++ and I have
created a simple MFC application to test the environment. My sample MFC
application is compilied with the /clr switch. I added a basic WinForm
class(via the wizard). In my MFC WinApp class I have a menu message handler
to display the standard About Dialog. In the message handler I create, show
and close the window. Everything appears to be working fine until I close...
|
by: Sparhawk |
last post by:
Hi,
my company is going to migrate a large VC++ application to .NET to
make use of Windows Forms (the old class library is not updated any
more). We are not planning to migrate the rest of the code which works
well.
I understand the basic concept: our code is unmanaged, Windows Forms
is Managed and Unmanaged may not call Managed code. I read about
Wrappers, PInvoke, Runtime Callable Wrappers for COM and about It just
|
by: JoeProgrammer |
last post by:
A couple of questions re. managed vs. unmanaged code.
1. I know this depends on the app, but how much faster is unmanaged code
vs. managed code? Is there an average figure for this?
2. Is it as simple as using a #pragma to convert from unmanaged to managed?
And if so, can I simply change my existing code to managed with the #pragma
wherever I want to eliminate transitions, or are there issues with this?
--
JoeProgrammer
I'm good. ...
| |
by: nicolas.hilaire |
last post by:
Hi all,
i'm not totally clear with some concepts about managed and unmanaged
code.
I'm asking myself some questions :
- i've a MFC app, i want to use the framework dotnet by switching to
/clr compilation mode. Is my app in CLR, or only the call to the
|
by: Amit Dedhia |
last post by:
Hi All
I have a VC++ 2005 MFC application with all classes defined as
unmanaged classes. I want to write my application data in xml format.
Since ADO.NET has buit in functions available for this, I want to use
it. Is it possible to call Managed class functions from Unmanaged
class? How to do it?
I did something like this.
I declared a managed class (in C++ CLI) called as MyManagedClass whose
|
by: Arne Adams |
last post by:
Hi,
I try to use a C# Dialog in a legacy MFC application.
The problem seems to boil down to the following:
from an unmanaged console application I can call any function of the managed
bridge - if I try to do the same from my mfc application the application
won't start
'SeaMain.exe': 'E:\WINDOWS\system32\mscoree.dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\system32\msvcr71d.dll' geladen, Symbole geladen.
|
by: Klaus |
last post by:
Hi,
I have an existing VC 6 MFC application which communicates asynchronly with
a VC 2005 managed code dll.
I use an unmanaged base class with virtual functions to access methods in
the MFC application.
Furthermore, I use a pointer to an unmanaged function to jump back into the
managed dll.
The managed part is basically a remoting enhancement which asynchronly
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |