Last post Sep 26, 2016 03:45 AM by avt2k7
Sep 23, 2016 08:00 PM|avt2k7|LINK
I try to create WCF web service to perform above task. I am wondering that the web service whether or not taking string xml or XML file as a parameter.
I am sure that we can covert XML file to string type.
Any expertise idea or how to create best WCF to load XML file data into SQL Server table, please guide me the right direction.
Sep 24, 2016 12:01 AM|mgebhard|LINK
From a developer perspective, WCF is nothing more than instantiating a class and invoking its methods. Microsoft went to great lengths to abstract this functionality and make web service calls appears as though your invoking an instance method even though
the method actually exists on a remote server.
IMHO, passing an XML argument is redundant -but - that depends on what you're doing. Behind the curtain, everything is serialized as XML (SOAP). So, serializing XML to XML is well odd and redundant... again IMHO. There is nothing stopping you from do
this and it provides a unique opportunity to use a single method that can accept many different types. It comes with a learning curve though.
Converting XML to a string and sending the string is serializes the data 3 times. Why create such a headache and extra code?
What are you trying to do? Are you trying to store XML in an XML column within a database table or are you trying to pass an object from the client to the server?
Sep 24, 2016 03:29 AM|avt2k7|LINK
Thank for your input. I am trying to build a web service that allow my client to consume it for pass XML file such Book.xml and load its data into the SQL Server table.
For example, Book.xml
<title>XML Developer's Guide</title>
<description>An in-depth look at creating applications with XML.</description>
<description>A former architect battles corporate zombies, an evil sorceress to become queen of the world.</description>
My table named tblBook contains the column fields (author, title, genre, price, publish_date, description).
Any further help is much appreciated.
Sep 24, 2016 01:49 PM|mgebhard|LINK
Again, you should use objects as I suggested. However, if you do not want to take my advice then you'll need to convert the XML to a string, base64 encode the string, send the string to the service and decode the string.
I do not recommend sending an XML type as XML types are framework (.NET) classes. Non .NET frameworks may not understand the class structure.
How to save the data in a database is unclear has you have not provided the schema or any information regard your data layer. Anyway, you'll need to convert the string to a format that interfaces with your database table.
Sep 26, 2016 03:45 AM|avt2k7|LINK
Thanks for your theoretical way but I am looking for the sample practical implementation. After searching via google for insert records from xml to SQL server database table, I found the way to write sproc and create simple WCF web service to call stored
procedure for insert XML data into SQL server table. To test on new service, I just create an ASP.NET web application to consume the service to let the user to upload the XML file and perform insert XML data into SQL Server table.