Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 186017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:34:23+00:00 2026-05-11T15:34:23+00:00

I’ve got a requirement to pass parameters as Xml to my stored procedures. I

  • 0

I’ve got a requirement to pass parameters as Xml to my stored procedures.

I have a WCF service in the middle tier that makes calls to my data layer which in turn forwards the request to the appropriate stored procedure.

The design is that the WCF service is responsible for building the Xml to pass to the Repository.

I’m just wondering whether to keep control of what parameters are contained within the Xml in the middle tier or use a Dictionary built up by the client which I then convert to Xml in the middle tier?

At the moment I’ve gone for the latter – for example:

 public TestQueryResponseMessage TestQuery(TestQueryRequestMessage message)  {         var result = Repository.ExecuteQuery('TestQuery', ParamsToXml(message.Body.Params));          return new TestQueryResponseMessage         {             Body = new TestQueryResponse             {                 TopicItems = result;             }         }     }   private string ParamsToXml(Dictionary<string, string> nvc) {         //TODO: Refactor         StringBuilder sb = new StringBuilder();          sb.Append('<params>');         foreach (KeyValuePair<string, string> param in nvc)         {             sb.Append('<param>');             sb.Append('<' + param.Key + '>');             sb.Append(param.Value);             sb.Append('</' + param.Key + '>');             sb.Append('</param>');         }         sb.Append('</params>');          return sb.ToString(); } 

However I might need to do it the first way. E.g.

public TestQueryResponseMessage TestQuery(TestQueryRequestMessage message) {        string xml = string.Format('<params><TestParameter>{0}</TestParameter></params>',message.Body.TestParameter)         var result = Repository.ExecuteQuery('TestQuery', xml);        return new TestQueryResponseMessage       {           Body = new TestQueryResponse           {                     TopicItems = result;           }       } } 

What does the hivemind recommend?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:34:24+00:00Added an answer on May 11, 2026 at 3:34 pm

    If you must use xml; then rather than passing around a dictionary, I’d use a class that represents that data, and use XmlSerializer to fetch it as xml:

    [Serializable, XmlRoot('args')] public class SomeArgs {     [XmlElement('foo')] public string Foo { get; set; }      [XmlAttribute('bar')] public int Bar { get; set; } } ... SomeArgs args = new SomeArgs { Foo = 'abc', Bar = 123 }; XmlSerializer ser = new XmlSerializer(typeof(SomeArgs)); StringWriter sw = new StringWriter(); ser.Serialize(sw, args); string xml = sw.ToString(); 

    This makes it much easier to manage which arguments apply to which queries, in an object-oriented way. It also means you don’t have to do your own xml escaping…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.