Here is our C# Client
Please configure the service endpoint correctly in the app.config before attempting to use the client.
<MetaSoftClientCS.Properties.Settings>
<setting name="MetaSoftClientCS_MetaSoftSevice_MetasoftTVAService"
serializeAs="String">
<value>http: </setting>
</MetaSoftClientCS.Properties.Settings>
TestClient class
Add in the imports:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MetaSoftClientCS.MetaSoftService;
Define the namespace and constructs:
namespace MetaSoftClientCS
{
public partial class TestClient : Form
{
MetasoftTVAService obj = new MetasoftTVAService();
get_Data_ResultType res1 = new get_Data_ResultType();
public TestClient()
{
InitializeComponent();
}
GetData Method
Make the getData method and initiate the necessary objects:
get_DataType getDataType = new get_DataType();
get_DataTypeQueryConstraints queryConstraints = new get_DataTypeQueryConstraints();
PredicateBagType predicateBagType = new PredicateBagType();
BinaryPredicateType binaryPredicateType = new BinaryPredicateType();
Define the query:
System.Xml.XmlQualifiedName qname = new System.Xml.XmlQualifiedName("Title");
binaryPredicateType.fieldID = qname;
binaryPredicateType.fieldValue = "H";
binaryPredicateType.test = BinaryPredicateTestType.contains;
BinaryPredicateType[] binaryPredicateTypes = new BinaryPredicateType[1];
binaryPredicateTypes[0] = binaryPredicateType;
predicateBagType.Items = binaryPredicateTypes;
queryConstraints.Item = predicateBagType;
getDataType.QueryConstraints = queryConstraints;
RequestedTablesTypeTable requestTable = new RequestedTablesTypeTable();
requestTable.type = RequestedTablesTypeTableType.ProgramInformationTable;
RequestedTablesTypeTable[] requestTables = new RequestedTablesTypeTable[1];
requestTables[0] = requestTable;
getDataType.RequestedTables = requestTables;
Make the request:
res1 = obj.getData(getDataType);
Now, we get the result and data:
TVAMainType tva = res1.TVAMain;
if (tva != null)
{
Array prgInfos = res1.TVAMain.ProgramDescription.ProgramInformationTable.ProgramInformation;
foreach (object BasicDescription in prgInfos)
{
{
Console.WriteLine("{0}", BasicDescription);
}
}
}
It should all come together like this:
private void bnGetData_Click(object sender, EventArgs e)
{
get_DataType getDataType = new get_DataType();
get_DataTypeQueryConstraints queryConstraints = new get_DataTypeQueryConstraints();
PredicateBagType predicateBagType = new PredicateBagType();
BinaryPredicateType binaryPredicateType = new BinaryPredicateType();
System.Xml.XmlQualifiedName qname = new System.Xml.XmlQualifiedName("Title");
binaryPredicateType.fieldID = qname;
binaryPredicateType.fieldValue = "H";
binaryPredicateType.test = BinaryPredicateTestType.contains;
BinaryPredicateType[] binaryPredicateTypes = new BinaryPredicateType[1];
binaryPredicateTypes[0] = binaryPredicateType;
predicateBagType.Items = binaryPredicateTypes;
queryConstraints.Item = predicateBagType;
getDataType.QueryConstraints = queryConstraints;
RequestedTablesTypeTable requestTable = new RequestedTablesTypeTable();
requestTable.type = RequestedTablesTypeTableType.ProgramInformationTable;
RequestedTablesTypeTable[] requestTables = new RequestedTablesTypeTable[1];
requestTables[0] = requestTable;
getDataType.RequestedTables = requestTables;
res1 = obj.getData(getDataType);
lblDisplay.Text = "Get Data Operation has completed successfully. . ";
TVAMainType tva = res1.TVAMain;
if (tva != null)
{
Array prgInfos = res1.TVAMain.ProgramDescription.ProgramInformationTable.ProgramInformation;
foreach (object BasicDescription in prgInfos)
{
{
Console.WriteLine("{0}", BasicDescription);
}
}
}
}
SubmitData Method
Make the consructs and an object to hold the resource data:
private void bnSubmitData_Click(object sender, EventArgs e)
{
string[] res = new string[1];
Initiate the necessary objects to construct your TVAMain Extended Object:
ExtendedTVAMainType mainType = new ExtendedTVAMainType();
ProgramDescriptionType prgDesc = new ProgramDescriptionType();
ProgramInformationTableType prgInfoTable = new ProgramInformationTableType();
Put in the content service provider's name, program ID (CRID if there is one, if not leave blank and one will be assigned):
prgInfoTable.metadataOriginIDRef = "BBC";
ProgramInformationType prgInfo = new ProgramInformationType();
prgInfo.programId = "crid:;
Create a Title object and Array:
TitleType title = new TitleType();
title.Value = "Pop Songs";
TitleType[] titles = new TitleType[1];
titles[0] = title;
Make a synopsis object and Array:
SynopsisType synopsisType = new SynopsisType();
synopsisType.Value = "Music";
synopsisType.length = SynopsisLengthType.@short;
SynopsisType[] synopsisTypes = new SynopsisType[1];
synopsisTypes[0] = synopsisType;
Create a term object and Genre object and fill them in:
TermNameType termNameType1 = new TermNameType();
termNameType1.Value = "Non-Fiction/Information";
GenreType genreType = new GenreType();
genreType.href = "urn:tva:metadata:cs:ContentCS:2005:3.8";
genreType.Name = termNameType;
genreType.type = GenreTypeType.main;
GenreType[] genreTypes = new GenreType[1];
genreTypes[0] = genreType;
Create a BasicContentDescrption object and fill in the info:
BasicContentDescriptionType basicContent = new BasicContentDescriptionType();
basicContent.Title = titles;
basicContent.Synopsis = synopsisTypes;
basicContent.Genre = genreTypes;
Put in the necessary attributes (optional):
AVAttributesType AVAttributesType = new AVAttributesType();
AVAttributesType.FileSize = 3;
AudioAttributesType1 AudioAttributesType = new AudioAttributesType1();
AudioAttributesType.NumOfChannels = 34;
AVAttributesType.AudioAttributes = audioAttributesTypes;
prgInfo.AVAttributes = AVAttributesType;
Put all the data in the correct objects:
prgInfo.BasicDescription = basicContent;
prgInfoTable.ProgramInformation = prgInfos;
prgDesc.ProgramInformationTable = prgInfoTable;
mainType.ProgramDescription = prgDesc;
Submit the data:
res = obj.submitData(mainType);
Here is the method with two entries:
private void bnSubmitData_Click(object sender, EventArgs e)
{
string[] res = new string[1];
ExtendedTVAMainType mainType = new ExtendedTVAMainType();
ProgramDescriptionType prgDesc = new ProgramDescriptionType();
ProgramInformationTableType prgInfoTable = new ProgramInformationTableType();
prgInfoTable.metadataOriginIDRef = "BBC";
ProgramInformationType prgInfo = new ProgramInformationType();
prgInfo.programId = "crid:;
BasicContentDescriptionType basicContent = new BasicContentDescriptionType();
ProgramInformationTableType prgInfoTable1 = new ProgramInformationTableType();
prgInfoTable1.metadataOriginIDRef = "YAHOO";
ProgramInformationType prgInfo1 = new ProgramInformationType();
prgInfo1.programId = "crid:;
BasicContentDescriptionType basicContent1 = new BasicContentDescriptionType();
TitleType title = new TitleType();
title.Value = "Pop Songs";
TitleType[] titles = new TitleType[1];
titles[0] = title;
TitleType title1 = new TitleType();
title1.Value = "Melody Songs";
TitleType[] titles1 = new TitleType[1];
titles1[0] = title;
SynopsisType synopsisType = new SynopsisType();
synopsisType.Value = "Music";
synopsisType.length = SynopsisLengthType.@short;
SynopsisType[] synopsisTypes = new SynopsisType[1];
synopsisTypes[0] = synopsisType;
SynopsisType synopsisType1 = new SynopsisType();
synopsisType1.Value = "Pop Music";
synopsisType1.length = SynopsisLengthType.@short;
SynopsisType[] synopsisTypes1 = new SynopsisType[1];
synopsisTypes1[0] = synopsisType;
TermNameType termNameType = new TermNameType();
termNameType.Value = "Leisure/Hobby/Lifestyle";
TermNameType termNameType1 = new TermNameType();
termNameType1.Value = "Non-Fiction/Information";
GenreType genreType = new GenreType();
genreType.href = "urn:tva:metadata:cs:ContentCS:2005:3.8";
genreType.Name = termNameType;
genreType.type = GenreTypeType.main;
GenreType genreType1 = new GenreType();
genreType1.href = "urn:tva:metadata:cs:ContentCS:2005:3.1";
genreType1.Name = termNameType1;
genreType1.type = GenreTypeType.main;
GenreType[] genreTypes = new GenreType[1];
genreTypes[0] = genreType;
GenreType[] genreTypes1 = new GenreType[1];
genreTypes1[0] = genreType1;
basicContent.Title = titles;
basicContent.Synopsis = synopsisTypes;
basicContent.Genre = genreTypes;
basicContent1.Title = titles1;
basicContent1.Synopsis = synopsisTypes1;
basicContent1.Genre = genreTypes1;
AVAttributesType AVAttributesType = new AVAttributesType();
AVAttributesType.FileSize = 3;
AudioAttributesType1 AudioAttributesType = new AudioAttributesType1();
AudioAttributesType.NumOfChannels = 34;
AudioAttributesType1[] audioAttributesTypes = new AudioAttributesType1[1];
audioAttributesTypes[0] = AudioAttributesType;
AVAttributesType.AudioAttributes = audioAttributesTypes;
prgInfo.AVAttributes = AVAttributesType;
prgInfo.BasicDescription = basicContent;
prgInfo1.BasicDescription = basicContent1;
ProgramInformationType[] prgInfos = new ProgramInformationType[2];
prgInfos[0] = prgInfo;
prgInfos[1] = prgInfo1;
prgInfoTable.ProgramInformation = prgInfos;
prgDesc.ProgramInformationTable = prgInfoTable;
mainType.ProgramDescription = prgDesc;
res = obj.submitData(mainType);
lblDisplay.Text = res[0];
}