XML and SOAP

I am in the process of developing an ASP.net database project based on a Win32 prototype. I've been able to write a service application that  uses BDP to connect to an Access database and client app which invokes the service, both passing parameters successfully. It was relatively painless.

I'm a bit confused on where to start with this SOAP and XML thingy. I see the XML and SOAP code in the browser when I test the service, so I know D2005 is creating it for me.  If all I needed to do was pass parameters and get results I would be fine. But some calls would be very complex, like where I get a list of objects from a database via  a server call and later update the database based on object properties. Seems to me these shoud be XML documents instead of complex parameter lists. Note that I have no data controls in my client app.

What is the general approach? Somehow I need to define a set of XML documents which will be my query and responses between my client and server. THen I need a mechanism to pass them back and forth. I've read some general info on XML and it looks pretty simple. But I've not seem much on how to define the schema. Please start me off in the right direction with SOAP/XML schema creation, doc exchange and parsing.
LVL 1
doug_stephensAsked:
Who is Participating?
 
BlackTigerXCommented:
you can also return complex types, as long as those derive from TRemotable... at least that's how it was in Delphi 6-7, but now that I think about it, with .NET you don't have to worry about this at all, you could return a DataSet, or whatever else, .NET takes care of all that for you

unless, of course, your client was not a .NET application, then you would have to translate the results
0
 
BlackTigerXCommented:
you don't have to worry about the XML at all, for binary data transfer you can use DynByteArray, just a bunch of bytes, and you can return that from a SOAP function call
0
 
doug_stephensAuthor Commented:
I've pretty much come to the same conclusion. When does one really need to define or know SOAP and XML protocols then?

To pass complex objects, I've tried sharing the same class definition unit between my client and the web service apps but I always get a runtime error that the two classes are not compatible. My classes are based on TObject. They need to derive from TRemotable I suppose. I'll try that.

Also I notice that there is no persistance of web service properties between calls, right? Global variables?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
doug_stephensAuthor Commented:
There does not appear to be a TRemoteable in D2005. Looks like I need to create something called a TRemoteDateModule to define my remotable classes.
0
 
doug_stephensAuthor Commented:
But I do not have a RemoteDataModule component anywhere. The Help.pdf says it is to be found in Delphi / ActiveX but I only have 2 components there: ActiveXLibrary and TypeLibrary.
0
 
doug_stephensAuthor Commented:
I started out today in a great mood, thinking I was going to put this thing to bed this week. After all, I had a web service application that could access my database and a .net client that could send and receive data via simple function calls. Seemed very close to what I wanted. Which is a distributed database application, without data components on the client.

I"m sinking now that I am trying to support more complex data exchange.  Either my brain is getting numb or there is a great deal of conflicting or overlapping information in the Borland documentation and various community papers I have read.  Not sure if I am supposed to create a web service application with BDP connections or a SOAP server application with ADO connections.

It's gonna be a long weekend I can see :) Ah well, my lovely wife is away. Guess I can stay up to 4am a few times with no great losses.
0
 
BlackTigerXCommented:
I think you better focus on getting this done the .NET way, more than the Borland way, look in C# forums for how to do complex types in web services, it shouldn't be much different in Delphi, we can even help translate code

I'll see if I can get some simple web service with complex data types for you
0
 
doug_stephensAuthor Commented:
>> I think you better focus on getting this done the .NET way, more than the Borland way,
I think that may indeed be at the root of my problem. The Borland way does not seem to be coherently presented in their product or documentation. I've been reading lots of .net and Ms stuff which goes on about SOAP, XMP and various approaches and considerations for the architecture of multi-tiered applications. But Borland seems to focus more on proprietary technologies and components like Borland Data Providers. I actually kind of like the specific sections of the Borland docs, but they don't tie together. One parts talks on about method A. But when you are trying to build something else, you have to use method B. Or when you read a .net article it talks about method C.

A lot of the Delphi stuff I see on this forum and elsewhere talks more about Delphi 6-8 approaches which are not necessarily supported or advised in D2005 or the current .net implementations.

The IDE and complier hides the SOAP/XML infrastructure. Which is nice maybe. I don't need to see how the electrons flow.  It seems to me that in the interest of platform and language independence, you would want to have your interfaces defined by a generic and common specification like XML. I don't understand how data remoting with some specialized Borland component makes that the case. I thought I would be making an XML schema to represent the application objects I need to exchange, with methods like LoadFromXML and WriteToXML.

Isn't this like, the number one thing people want to implement today? Why is it so hard to figure out? OTOH, I'm a bit new to this .net world and have only spent 2 weeks with D2005 so far. I've had a lot of success and made good progress, despite my frustration.
0
 
DeerBearCommented:
Hi Doug.

Here's my take.

XML and SOAP are needed when you want to make available a *COMMON PROTOCOL* to be used across different machines.
Now, this means that you can very well use an XML file to transport your data back and forth, but do you need it?
SOAP is known to be fairly bloated(and that's inevitable, since the amount of informations needed isn't trivial) because of the ethereogenity of the possible client targets.

When you're talking of similar machines, there're a few ways that you might prefer: using a BinaryFormatter and compressing binary data to transfer. When the objects are large, this can be a good solution, since you compress and decompress on the fly.

After all, we should also discuss if you're using an appropriate class design, which itself plays a heavy role in all the game.

These are all issues you have to consider, imho.

HTH,

Andrew
0
 
doug_stephensAuthor Commented:
>> ethereogenity
That word alone should be worth 250 points.

In my case, all the clients are Windows machines running on the same corporate network.
This is an internal use only application.
Data volumes are small per transaction, I would guess less than 2k in most instances. I guess that
depends on the bloat factor of your protocol. Less than one transaction per 10 seconds.

>> we should also discuss if you're using an appropriate class design
And what would that be? I've designed the classes based on the real world usage of the information.
No considerations for data remoting or multi-tiered design.
Database I/O is pretty much encapsulated in a few parameterized methods.
0
 
DeerBearCommented:
Uhm... first of all your comment that "That word alone should be worth 250 points."... did I spell it wrong or it doesn't exist at all? English is not my primary language, thus my Italian might have slipped through.

As to the second comment, I wasn't thinking about database encapsulation, but on data structuring and information duplication(that is, a well thought out hierarchy will help in that the "bloat" will be strongly reduced).

Since your data volumes are not huge and you have a good connection, maybe SOAP would be the most straightforward(and less trouble-making), because you can for example have a server application using SOAP and dotNET and client ones using Delphi6/7/2005 on the Win32 side(so not to drain resources on less powerful hardware and/or not very stable O.Ses

Another alternative I'd look to is http://www.remobjects.com - very powerful and well regarded by many Delphi developers.

Cheers,

Andrew
0
 
doug_stephensAuthor Commented:
ethereogenity - not sure if it is proper English, or if so, what it means, but it sure looks good!
Perhaps you mean homogeneity - the fact that things (clients) are similar? Anyways, just a joke.
0
 
DeerBearCommented:
Oh no, I meant it in the exact contrary :-)

Cheers,

Andrew
0
 
doug_stephensAuthor Commented:
I'm trying to write a SOAP Application Server now, instead of an ASP.net service app, based on an article on remoting I read. When you add a SOAP Interface to that,  you get an unit with a class descending from TRemotable which is definitely what I want. I think. You also get an interface object based on IInterface which I guess you need. Not sure how those 2 are related exactly. Anyway, this all looks promising but I can't run the project.

When you create a new SOAP App Server, asks if you want to create (a) ISAPI/NSAPI DLL (b) CGI stand alone exe or (c) web app debugger exe. I was a bit confused and chose the DLL. But when I tried to run, it wants the name of the host executable. Huh? I thought this ran under IIS.  I tried option (c) the CGI - it ran but I don't know what it did. A little command prompt window showed for a second and was gone. Lastly I tried the web app debugger, but that gives a compiler error: [Fatal Error] Project1.dpr(11): F1026 File not found: 'IndySockTransport.dcu'. Does a SOAP Application Server run under something else I need to create?

I then tried adding a SOAP Interface to an ASP.net service app project, but that does not compile either: [Fatal Error] Unit1.pas(5): F1026 File not found: 'InvokeRegistry.dcuil' (required for TRemotable).

I was quite happy with my ASP.net service application but I can't seem to add remotable objects to it.
0
 
DeerBearCommented:
ISAPIs and CGIs are run by IIS, right, but you need to copy them in IIS's folders, then call them through the browser(or client components) using this URL:

http://127.0.0.1/Scripts/MyDllName.dll/SOAP

I have a very small C/S demo showing the basics, if you want I can paste in this thread.

Cheers,

Andrew
0
 
doug_stephensAuthor Commented:
Andrew, I'd love to see some D2005 code which implements a TRemotable descendant in a web service app allowing exchange of complex objects with a .net client. Or any client for that matter.
0
 
doug_stephensAuthor Commented:
I now have a working SOAP Server application, with a SOAP Service module, which has defined a TRemotable class. I can effectively exchange the remotable object with a Win32 client.

My big problem was that I didn't know how to test the ISAPI DLL I created - not really a Delphi or .net problem at all. To run my DLL I simply needed to have Execute permission on the virtual directory. When I compile my DLL, D2005 says "Running". I start up an IE session and open something like http://localhost/SOAPServer/SOAPServer.dll which gives me a nice "Service Info" page and access to WSDL. I would like to be able to test from here too, like I can with my ASP service, which I haven't quite figured out.

To test, I exit the above DLL project in D2005, open up my Win32 client project and run it. Works great. However when I want to modify my DLL, I need to stop IIS and restart it otherwise I can't re-create the DLL. Guess IIS is holding on to it. To release the DLL, I first stop the WWW Publishing service, then stop the IIS Admin service. Then I compile, then I restart the service, then I run my client app.

Some specific questions now:

1. Is there an easier way to test my DLL? I think creating a CGI exe is the way. But regardless, how can I debug the calls? Is there an easier way to recompile the DLL? OTOH, is there a harder way? I've also read about just killing the dllhost processes from TaskMgr.

2. I am a bit unclear how remotable objects are shared between the client and server. They are defined in the interface module of the server app. However, I put in some public functions, but these do not seem available to my client. (Yes, I refreshed the the web service reference.) The only things available are published properties. How can I get my client to recognize the public methods?
0
 
doug_stephensAuthor Commented:
I'm going to close this question, points to btx. Still seem to be having some problems accessing remotable object properties but I will start a new question. Also with debugging a CGI.exe.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.