Reputation: 61872
Background
I've been asked to create a web service that interacts with an eCommerce application. The eCommerce application in question exposes a web service interface which the documentation defines as:
The Web Service Interface (WSI) feature is an XML-based tool that functions similarly to an API, allowing developers to carry out a myriad of tasks within the application in bulk, or from remote systems, without having to make source code modifications.
Basically the WSI is an ASP.net web service that exposes one method. This method allows you to pass in an XML string that tells the application to do something.
Question
On the face of it, it appears that I'm going to be concatenating strings to create the necessary XML to send to the eCommerce application. Obviously, the idea of that makes me cringe.
Is there a better way of piecing together the necessary XML in C#?
Secondary Question (optional)
Is it just me (totally possible), or is this a down right silly way of interacting with an application?
Upvotes: 0
Views: 1588
Reputation: 2709
If you have got a database running then create stored procedures that return XML and then create a gateway/factory mechanisms to separate out the database layer from the application layer and create methods that will get the required xml from the stored procedure into the web service calls.
You can then use LINQ to XML or any other techniques to manipulate your XML.
Upvotes: 0
Reputation: 701
Dont know about the best way, but building strings and creating xml data is not hard thing to do with C#/.net.
If You can use Framework 3,5 or 4, then use XDocument to generate xmlDocs.
Upvotes: 0
Reputation: 2544
Use the Linq2XML API.
LINQ to XML provides an in-memory XML programming interface that leverages the .NET Language-Integrated Query (LINQ) Framework. LINQ to XML uses the latest .NET Framework language capabilities and is comparable to an updated, redesigned Document Object Model (DOM) XML programming interface.
See http://msdn.microsoft.com/en-us/library/bb387098.aspx
Upvotes: 0
Reputation: 29963
I'd look at Linq to XML for creating the requests, with the caveat that it may save some effort for simple and repeating operations if you have some pre-made XML (I guess just strings) for the simpler tasks that may exist. No point building up the XML dynamically every second if it is just something like
<command>GetTheTime</command>
for example...
On your second question, I agree with you but then again, I don't know the full story.
Upvotes: 2
Reputation: 28346
Use the classes from System.Xml
to produce the document.
You should start by looking at XmlDocument.
Upvotes: 0