By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

ATL Service Web Serice Using XML as Input and Output

P: n/a
Hi,

I am writing ATL Service application (XML Web service) in
VS.NET C++.
Are there any sample programs that accept XML as input and
XML as output
in the web service?

Thank you very much.

FS Liu

Nov 16 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi

Please clarify: do you want to load SOAP XML requests as input, and generate
SOAP XML responses as output?

--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan


"FS Liu" <fa***********@hotmail.com> wrote in message
news:1d****************************@phx.gbl...
Hi,

I am writing ATL Service application (XML Web service) in
VS.NET C++.
Are there any sample programs that accept XML as input and
XML as output
in the web service?

Thank you very much.

FS Liu

Nov 16 '05 #2

P: n/a
Thanks for your message.

The input to the web service is a set of parameters
which may change in format and the number of variables
for each call. The output variable or the returned
value of the web service is also a set of paramters
which may change in format and the number of variables
as the result of the call.

In my thinking, there are at least two ways to do this:
(1). Pass both input and output as strings in
calling the web service.
In this case, I need to know how to convert
XmlTextReader to string in a very efficient way.
Is this method OK in ATL Server application?
Do I need managed code to do this?
(2). Call web service by passing parameter such as
XmlTextReader or XmlNode type.
But unfortunately, there is too little resources from
Microsoft. Do you have some sample programs ?

Thank you very much.

FS Liu
-----Original Message-----
Hi

Please clarify: do you want to load SOAP XML requests as input, and generateSOAP XML responses as output?

--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.Please do not send email directly to this alias. It is for newsgrouppurposes only.

thanks,
bogdan


"FS Liu" <fa***********@hotmail.com> wrote in message
news:1d****************************@phx.gbl...
Hi,

I am writing ATL Service application (XML Web service) in VS.NET C++.
Are there any sample programs that accept XML as input and XML as output
in the web service?

Thank you very much.

FS Liu

.

Nov 16 '05 #3

P: n/a
Some more clearification:
As I described below, I am thinking to use XML to pass
both the input parameters and output results. I hope
to use both ADO.NET and XML classes for best performance
and development speed.

Thanks again.

FS Liu

-----Original Message-----
Thanks for your message.

The input to the web service is a set of parameters
which may change in format and the number of variables
for each call. The output variable or the returned
value of the web service is also a set of paramters
which may change in format and the number of variables
as the result of the call.

In my thinking, there are at least two ways to do this:
(1). Pass both input and output as strings in
calling the web service.
In this case, I need to know how to convert
XmlTextReader to string in a very efficient way.
Is this method OK in ATL Server application?
Do I need managed code to do this?
(2). Call web service by passing parameter such as
XmlTextReader or XmlNode type.
But unfortunately, there is too little resources from
Microsoft. Do you have some sample programs ?

Thank you very much.

FS Liu
-----Original Message-----
Hi

Please clarify: do you want to load SOAP XML requests as

input, and generate
SOAP XML responses as output?

--
--
--
This posting is provided "AS IS" with no warranties, and

confers no rights.
Please do not send email directly to this alias. It is

for newsgroup
purposes only.

thanks,
bogdan


"FS Liu" <fa***********@hotmail.com> wrote in message
news:1d****************************@phx.gbl...
Hi,

I am writing ATL Service application (XML Web service)in VS.NET C++.
Are there any sample programs that accept XML as inputand XML as output
in the web service?

Thank you very much.

FS Liu

.

.

Nov 16 '05 #4

P: n/a
In article <#D**************@TK2MSFTNGP10.phx.gbl>, "Bogdan says...

Hi

Please clarify: do you want to load SOAP XML requests as input, and generate
SOAP XML responses as output?


How about a similar question...

Should (of course I CAN) use ATL Server, VC++7.1 to produce a REST like program?
i.e. from a URL, return an XML doc, which is from my complex C++ objects, and
also be able to PUT/POST HTTP messages that end up back in my C++ program for
processing?

Simple GET example
http://myapp/address?IBM
a get on that would return the address of IBM in my database as a formatted XML
document.

Thanks
sdg

Nov 16 '05 #5

P: n/a
Are there efficient way (both performance and development
speed) to convert XPathDocument or XmlDocument to string,
or even compress them into binary string for better
internet data transfer performance?

Thanks.

FS Liu

-----Original Message-----
If the params are dynamic, as in FS Liu's example, or if you just want topass a XML doc up and return one, why not use a document style of literal?
[
request_handler(name="Default", sdl="GenBlahWSDL"),
soap_handler(
name="BlahService",
namespace="urn:BlahService",
protocol="soap",
style="document",
use="literal" // in order to use style = document, you musthave use = literal
)
]

Then your soap method can look like this:
[ soap_method ]
HRESULT Foo(BSTR foobar, BSTR* retval);

foobar will be your uploaded XML document, and retval will be your returnxml document.

hth

todd brooks


<sc****************@yahoo.com> wrote in message
news:bf*********@drn.newsguy.com...
In article <#D**************@TK2MSFTNGP10.phx.gbl>, "Bogdan says...
>
>Hi
>
>Please clarify: do you want to load SOAP XML requests
as input, and
generate >SOAP XML responses as output?
How about a similar question...

Should (of course I CAN) use ATL Server, VC++7.1 to

produce a REST likeprogram?
i.e. from a URL, return an XML doc, which is from my
complex C++ objects,and
also be able to PUT/POST HTTP messages that end up back
in my C++ programfor
processing?

Simple GET example
http://myapp/address?IBM
a get on that would return the address of IBM in my
database as aformatted XML
document.

Thanks
sdg

.

Nov 16 '05 #6

P: n/a
Hi, Bogdan,

I am writing some functions to provide data via
internet with ATL Server structure in VC++.NET.
The input to these functions has the following
feature:
* it may change in data format or/and the number
of variables.
* I am thinking to pass such a dynamic varaible
set with XML doc. The web service will parse
the input XML doc and decide what to do on
server side.
* it may be beter to compress the data before
send it to web server. If this is quite easy
to implement with .NET classes. I will do it.
The output of these functions has the following
feature:
* The results are from SQL Server 2000.
* I want to return the data with XML doc, so
as to use the data cross platform.
* it may be beter to compress the data before
send it back to client. Again, if this is quite
easy to implement with .NET classes. I will do it.
I know that one of the solutions is to implement the
input and output as string or binary string (in the
case of compressed data). But I cannot find an good
example to:
* get data in XML format from SQL Server 2000 in
ATL Server application (by using "for XML"
clause with SQL 2000);
* convert the XML doc to a string in a very
efficient way (instead of node by node by
navigating through the XML tree)
* compress the string into a binary string before
sending it back to client.
* decide a better choice between HTTP GET/POST and
ATL Server web service (I am not sure if I should
go to web service wizard project for this. But
I am sure I want to use ATL server project for
beter performance.).

Please advise.

Thank you very much.

FS Liu
-----Original Message-----
Could you please provide a few more details on the functionality of yourapp?
Looks like the HTTP Client class in ATL Server could be of help here
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.Please do not send email directly to this alias. It is for newsgrouppurposes only.

thanks,
bogdan


<sc****************@yahoo.com> wrote in message
news:bf*********@drn.newsguy.com...
In article <#D**************@TK2MSFTNGP10.phx.gbl>, "Bogdan says...
>
>Hi
>
>Please clarify: do you want to load SOAP XML requests
as input, and
generate >SOAP XML responses as output?
How about a similar question...

Should (of course I CAN) use ATL Server, VC++7.1 to

produce a REST likeprogram?
i.e. from a URL, return an XML doc, which is from my
complex C++ objects,and
also be able to PUT/POST HTTP messages that end up back
in my C++ programfor
processing?

Simple GET example
http://myapp/address?IBM
a get on that would return the address of IBM in my
database as aformatted XML
document.

Thanks
sdg

.

Nov 16 '05 #7

P: n/a
Hi,

The problems that I understand need solving are:
1. compression (in and out)
2. reading variable XML description of the parameters from the input
3. getting SQL 2000 data as XML
4. render the response as a stream

1. Compression -- I think this can be solved by using IISs compression
abilities. I think IIS comes with an ISAPI filter that allows zip
compression for in/out traffic.
If not, you could easily overwrite the ATLServer ISAPI buffer response class
to compress the content on the fly and add a custom header to the response
For the main part of the job (reading the input and generating the streamed
output) -- one way to go is to modify the ATL Server SOAP support framework.
It is possible to completely override the SOAP input parameter parsing (and
get control by using your custom SAX handler instead of ATLS's one). Also,
it is possible to write directly to the response stream and override the
SOAP response serialization mechanism. If you think you really need to do
this and override the SOAP support, please let me know, the rest of this
messsage is about a different solution)

However, the SOAP support is intended to help in RPC/COM like invocations of
SOAP methods (with IDL support for structs, in/out parameters and basic
types).
Your application seems to have a more specialized function: get some POSTed
XML input which contains a query description (or so) , execute the query and
stream the XML from SQL Server as response.
You could just not use the ATLS SOAP support, but create a regular
(non-soap) web application and parse yourself the input XML (which may or
may not be strictly respecting the SOAP format).
Once you parse the input parameters, you can build your query and execute it
against SQL Server. The 'FOR XML AUTO' response from SQL Server can be
fetched as an IStream interface through OLEDB and, as you read from that
stream, you can render data back to the caller (by writing it to the
m_HttpResponse buffer).
The code should look like below (connecting to Northwind,

#define CONNECTION_STRING L"Provider=SQLOLEDB.1; Integrated Security=SSPI;
Data Source=localhost; Initial Catalog=Northwind"
#define CHECK_ERROR(x) (hr=x; if (!SUCCEEDED(hr))goto err;)

HRESULT hr;
CDataSource dataSrc;
CSession session;
CCommand<CNoAccessor, CStreamRowset> cmd;

CHECK_ERROR(dataSrc.OpenFromInitializationString(C ONNECTION_STRING));
CHECK_ERROR(session.Open(dataSrc));

CHECK_ERROR(cmd.Open(session, "SELECT * from Customers FOR XML AUTO"));

CHAR buff[1024 + 1];
ULONG cbRead = 1024;
do
{
CHECK_ERROR(cmd.m_spStream->Read( buff, 1024, &cbRead));
buff[cbRead] = '\0';
m_HttpResponse.Write(buff);
}while( cbRead == 1024 );
err:
return SomeError;
This way, the XML data coming from the SQL Server is directly streamed to
the HTTP response without loading it into intermediary XML classes (either
unmanaged DOM or .Net)
So, if you decide to go with this second approach (regular web application
instead of using the SOAP support), you 'll get:
- good performance for writing the query result as XML back to the caller,
without using intermediate classes and without intermediate copy operations
- good database connection performance (ATL Server has a mechanism to cache
database connections)
- ability to expose a SOAP -like behavior for the clients (without actually
using the ATL Server SOAP support) -- you will have to parse the input and
make sure it looks like <soap:Envelope... etc
Also, to implement SOAP you will have to wrap the response from the SQL
Server in a <soap:Envelope><soap:Body> set of tags
- ability to switch with minimal effort to a HTTP GET behavior (you'll just
need to get the parameters from the QueryString collection instead opf
parsing a POSTed input XML document)

Besides, you don't need to modify the ATLS SOAP framework
Please let me know if this works for you and if you would like a small
working sample of this

Optimization suggestion:
- the SQL Server connection should be cached in the ISAPI DLL (the ATLS
wizard allows you to create a database connection cache in the ISAPI dll)
- if you decide to have POST-ed XML as input (instead of HTTP GET or POST
parameters), you could use the per-thread ISAXXMLReader that available in
ISAPI DLLs
- you might want to change the default buffer size for the HTTP Response
depending on the values you use when reading from the CStreamRowset in the
code above
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan
Hi, Bogdan,

I am writing some functions to provide data via
internet with ATL Server structure in VC++.NET.
The input to these functions has the following
feature:
* it may change in data format or/and the number
of variables.
* I am thinking to pass such a dynamic varaible
set with XML doc. The web service will parse
the input XML doc and decide what to do on
server side.
* it may be beter to compress the data before
send it to web server. If this is quite easy
to implement with .NET classes. I will do it.
The output of these functions has the following
feature:
* The results are from SQL Server 2000.
* I want to return the data with XML doc, so
as to use the data cross platform.
* it may be beter to compress the data before
send it back to client. Again, if this is quite
easy to implement with .NET classes. I will do it.
I know that one of the solutions is to implement the
input and output as string or binary string (in the
case of compressed data). But I cannot find an good
example to:
* get data in XML format from SQL Server 2000 in
ATL Server application (by using "for XML"
clause with SQL 2000);
* convert the XML doc to a string in a very
efficient way (instead of node by node by
navigating through the XML tree)
* compress the string into a binary string before
sending it back to client.
* decide a better choice between HTTP GET/POST and
ATL Server web service (I am not sure if I should
go to web service wizard project for this. But
I am sure I want to use ATL server project for
beter performance.).

Please advise.

Thank you very much.

FS Liu



Nov 16 '05 #8

P: n/a
Hi, bogdan,

Your message is very helpful in showing me the direction
and some details. I don't have an immediate feeling of
the difference in the performance of the two methods you
described. Could you please show me how to override
SOAP support? I will also try the second approach by
myself to see what the performance difference between
the two methods looks like.
Thank you very much.

FS Liu

-----Original Message-----
Hi,

The problems that I understand need solving are:
1. compression (in and out)
2. reading variable XML description of the parameters from the input3. getting SQL 2000 data as XML
4. render the response as a stream

1. Compression -- I think this can be solved by using IISs compressionabilities. I think IIS comes with an ISAPI filter that allows zipcompression for in/out traffic.
If not, you could easily overwrite the ATLServer ISAPI buffer response classto compress the content on the fly and add a custom header to the response

For the main part of the job (reading the input and generating the streamedoutput) -- one way to go is to modify the ATL Server SOAP support framework.It is possible to completely override the SOAP input parameter parsing (andget control by using your custom SAX handler instead of ATLS's one). Also,it is possible to write directly to the response stream and override theSOAP response serialization mechanism. If you think you really need to dothis and override the SOAP support, please let me know, the rest of thismesssage is about a different solution)

However, the SOAP support is intended to help in RPC/COM like invocations ofSOAP methods (with IDL support for structs, in/out parameters and basictypes).
Your application seems to have a more specialized function: get some POSTedXML input which contains a query description (or so) , execute the query andstream the XML from SQL Server as response.
You could just not use the ATLS SOAP support, but create a regular(non-soap) web application and parse yourself the input XML (which may ormay not be strictly respecting the SOAP format).
Once you parse the input parameters, you can build your query and execute itagainst SQL Server. The 'FOR XML AUTO' response from SQL Server can befetched as an IStream interface through OLEDB and, as you read from thatstream, you can render data back to the caller (by writing it to them_HttpResponse buffer).
The code should look like below (connecting to Northwind,

#define CONNECTION_STRING L"Provider=SQLOLEDB.1; Integrated Security=SSPI;Data Source=localhost; Initial Catalog=Northwind"
#define CHECK_ERROR(x) (hr=x; if (!SUCCEEDED(hr))goto err;)
HRESULT hr;
CDataSource dataSrc;
CSession session;
CCommand<CNoAccessor, CStreamRowset> cmd;

CHECK_ERROR(dataSrc.OpenFromInitializationString (CONNECTION_STRING)); CHECK_ERROR(session.Open(dataSrc));

CHECK_ERROR(cmd.Open(session, "SELECT * from Customers FOR XML AUTO"));
CHAR buff[1024 + 1];
ULONG cbRead = 1024;
do
{
CHECK_ERROR(cmd.m_spStream->Read( buff, 1024, &cbRead)); buff[cbRead] = '\0';
m_HttpResponse.Write(buff);
}while( cbRead == 1024 );
err:
return SomeError;
This way, the XML data coming from the SQL Server is directly streamed tothe HTTP response without loading it into intermediary XML classes (eitherunmanaged DOM or .Net)
So, if you decide to go with this second approach (regular web applicationinstead of using the SOAP support), you 'll get:
- good performance for writing the query result as XML back to the caller,without using intermediate classes and without intermediate copy operations- good database connection performance (ATL Server has a mechanism to cachedatabase connections)
- ability to expose a SOAP -like behavior for the clients (without actuallyusing the ATL Server SOAP support) -- you will have to parse the input andmake sure it looks like <soap:Envelope... etc
Also, to implement SOAP you will have to wrap the response from the SQLServer in a <soap:Envelope><soap:Body> set of tags
- ability to switch with minimal effort to a HTTP GET behavior (you'll justneed to get the parameters from the QueryString collection instead opfparsing a POSTed input XML document)

Besides, you don't need to modify the ATLS SOAP framework
Please let me know if this works for you and if you would like a smallworking sample of this

Optimization suggestion:
- the SQL Server connection should be cached in the ISAPI DLL (the ATLSwizard allows you to create a database connection cache in the ISAPI dll)- if you decide to have POST-ed XML as input (instead of HTTP GET or POSTparameters), you could use the per-thread ISAXXMLReader that available inISAPI DLLs
- you might want to change the default buffer size for the HTTP Responsedepending on the values you use when reading from the CStreamRowset in thecode above
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.Please do not send email directly to this alias. It is for newsgrouppurposes only.

thanks,
bogdan
Hi, Bogdan,

I am writing some functions to provide data via
internet with ATL Server structure in VC++.NET.
The input to these functions has the following
feature:
* it may change in data format or/and the number
of variables.
* I am thinking to pass such a dynamic varaible
set with XML doc. The web service will parse
the input XML doc and decide what to do on
server side.
* it may be beter to compress the data before
send it to web server. If this is quite easy
to implement with .NET classes. I will do it.
The output of these functions has the following
feature:
* The results are from SQL Server 2000.
* I want to return the data with XML doc, so
as to use the data cross platform.
* it may be beter to compress the data before
send it back to client. Again, if this is quite
easy to implement with .NET classes. I will do it.
I know that one of the solutions is to implement the
input and output as string or binary string (in the
case of compressed data). But I cannot find an good
example to:
* get data in XML format from SQL Server 2000 in
ATL Server application (by using "for XML"
clause with SQL 2000);
* convert the XML doc to a string in a very
efficient way (instead of node by node by
navigating through the XML tree)
* compress the string into a binary string before
sending it back to client.
* decide a better choice between HTTP GET/POST and
ATL Server web service (I am not sure if I should
go to web service wizard project for this. But
I am sure I want to use ATL server project for
beter performance.).

Please advise.

Thank you very much.

FS Liu



.

Nov 16 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.