I don't know how to use xsd message when i consume the service

Topics: General Discussion Forum
Jul 19, 2009 at 10:50 AM
Edited Jul 19, 2009 at 10:51 AM

I use WSSF pattern , i used the tutorial , but when i consume the service the return type " responseMessage ( xsd ) " contain property of PartLevel, so how to get the return value

Jul 19, 2009 at 2:43 PM

Sorry but I not sure about your question. Are you asking for the return type of PartLevel?

Can you describe further the proxy class and types that you are using?




Jul 19, 2009 at 3:04 PM
Edited Jul 19, 2009 at 3:09 PM

good afternoon Mr.Hernan,
i am sorry because i don't have big knowledge in factory , that i am try to learn :) .
i don't know how to use the xsd message (with partLevel class ). and if i want to return datatable , how can i use xsd message.

this is the class i consume the service on it .

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.IO;
using System.Xml;
using System.Text;
using WCFNews.MessageContracts;

namespace WCFNews.ServiceImplementation
public partial class NewsService:NewsServiceBase
int maxNoNews = 10;
string newsPage = "newsDetails.aspx";
string setTarget = "_parent";

public override WCFNews.MessageContracts.ResponseNews AddNewsRequirement(WCFNews.MessageContracts.RequestNews request)

string webName =request.NewsRequirment.WebName;
string newsDate = request.NewsRequirment.NewsDate;
string newsTitle = request.NewsRequirment.NewsTitle;
string newsText = request.NewsRequirment.NewsText;

XmlDocument doc = new XmlDocument();

string path = webName;
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
int count = doc.GetElementsByTagName("div").Count;
if (count < maxNoNews)
XmlElement xeDiv = doc.CreateElement("div");

XmlAttribute idDiv = doc.CreateAttribute("ID");
idDiv.Value = (count + 1).ToString();

XmlAttribute classDiv = doc.CreateAttribute("Class");
classDiv.Value = "message";

XmlElement d = doc.CreateElement("dd");
d.InnerText = newsDate;

XmlElement br = doc.CreateElement("br");

XmlElement a = doc.CreateElement("a");

XmlAttribute href = doc.CreateAttribute("href");
href.Value = newsPage;

XmlAttribute target = doc.CreateAttribute("target");
target.Value = setTarget;

a.InnerText = newsTitle;

XmlElement Text = doc.CreateElement("NewsText");
Text.InnerText = newsText;


doc.DocumentElement.InsertAfter(xeDiv, doc.DocumentElement.LastChild);

XmlNodeList nodeList = doc.GetElementsByTagName("News");

FileStream xmlFS = new FileStream(path, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);


WCFNews.BusinessEntities.ItemLevel itemLevel = new WCFNews.BusinessEntities.ItemLevel();

ResponseNews response = new ResponseNews();
WCFNews.DataContracts.PartLevel partLevel = TranslateBetweenItemLevelAndPartLevel.TranslateItemLevelToPartLevel(itemLevel);

return response;


catch(Exception ex)

return null;




thank you for helping.


Jul 19, 2009 at 6:08 PM

Hi Karim,

As I see you are building an XML and at the end of the operation you call the translator and return the partLevel element (the latter seem to have no relationship with the previous XML manipulation).

Regarding the XsdMessage element, is basically a "proxy" artifact that reference an XSD schema type (not a DataContract element). In your particular case, the  "WCFNews.DataContracts.PartLevel" seem to be a DataContract element so you won't use a XsdMessage element there. 

Back to your scenario, I assume that you want to create an XML document with the data from the request parameter. If that the case, then you may use the translator to set your business entity class and serialize that class (using XML Serializer) to your file so you don;t need to do all the cost and error prone XML document operations.

Then you simply get your partLevel DataContract populated from whatever business operation you have and you are done. Let me know if I missed something (or missed the point completly :-)



Jul 26, 2009 at 10:55 AM

Hi Mr. Hernan.

that's so kind of you for assisted me, that's exactly what i mean for this article.

now it's working find , and i understood it :)