none
How to Read and Update User Profile RRS feed

  • Question

  • Please find the two scenarios:

    1. If a user profile structure has more than one phone details(as shown in the below example) and more than one user profile is created with the same structure then facing problem in reading user profile for the corresponding user.

    2. How can we update a user profile that contains blanknode and how in advance we can know whether a ndoe is simple node or a blanknode while updating?

    Senario1: Reading Profile.

    Steps Followed:

    Let’s say User Profile contains user name and phone. Phone contains PhoneNumber, PhonePrefix, PhoneCountryCode, PhoneType, etc.

    Create two profiles with two different users but with same phone details as follows.

    User1: User2:

    <rdf:RDF xmlns:csf="http://schemas.microsoft.com/connectedservices/pm#/"

    xmlns:owl="http://www.w3.org/2002/07/owl#"

    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

    <rdf:Description rdf:about="http://schemas.microsoft.com/connectedservices/pm#/dik@contoso.com">

    <csf:FirstName>Dikson</csf:FirstName>

    <csf:Phone1>

    <rdf:Description>

    <csf:PhoneType>Primary1</csf:PhoneType>

    <csf:PhonePrefix>PhonePrefix1</csf:PhonePrefix>

    <csf:PhoneNumber>PhoneNumber1</csf:PhoneNumber>

    <csf:PhoneExtension>PhoneExtension1</csf:PhoneExtension>

    <csf:phoneCountyCode> PhoneCountryCode2</csf:phoneCountyCode>

    </rdf:Description>

    </csf:Phone1>

    <csf:Phone2>

    <rdf:Description>

    <csf:PhoneType>N/A</csf:PhoneType>

    <csf:PhonePrefix> N/A</csf:PhonePrefix>

    <csf:PhoneNumber> N/A</csf:PhoneNumber>

    <csf:PhoneExtension> N/A</csf:PhoneExtension>

    <csf:phoneCountyCode> N/A</csf:phoneCountyCode>

    </rdf:Description>

    </csf:Phone2>

    <csf:Phone3>

    <rdf:Description>

    <csf:PhoneType>N/A</csf:PhoneType>

    <csf:PhonePrefix> N/A</csf:PhonePrefix>

    <csf:PhoneNumber> N/A</csf:PhoneNumber>

    <csf:PhoneExtension> N/A</csf:PhoneExtension>

    <csf:phoneCountyCode> N/A</csf:phoneCountyCode>

    </rdf:Description>

    </csf:Phone3>

    </rdf:Description>

    </rdf:RDF>

    <rdf:RDF xmlns:csf="http://schemas.microsoft.com/connectedservices/pm#/"

    xmlns:owl="http://www.w3.org/2002/07/owl#"

    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

    <rdf:Description rdf:about="http://schemas.microsoft.com/connectedservices/pm#/tom@contoso.com">

    <csf:FirstName>Tom</csf:FirstName>

    <csf:Phone1>

    <rdf:Description>

    <csf:PhoneType>Primary2</csf:PhoneType>

    <csf:PhonePrefix>PhonePrefix2</csf:PhonePrefix>

    <csf:PhoneNumber>PhoneNumber2</csf:PhoneNumber>

    <csf:PhoneExtension>PhoneExtension2</csf:PhoneExtension>

    <csf:phoneCountyCode>PhoneCountryCode2</csf:phoneCountyCode>

    </rdf:Description>

    </csf:Phone1>

    <csf:Phone2>

    <rdf:Description>

    <csf:PhoneType>N/A</csf:PhoneType>

    <csf:PhonePrefix> N/A</csf:PhonePrefix>

    <csf:PhoneNumber> N/A</csf:PhoneNumber>

    <csf:PhoneExtension> N/A</csf:PhoneExtension>

    <csf:phoneCountyCode> N/A</csf:phoneCountyCode>

    </rdf:Description>

    </csf:Phone2>

    <csf:Phone3>

    <rdf:Description>

    <csf:PhoneType>N/A</csf:PhoneType>

    <csf:PhonePrefix> N/A</csf:PhonePrefix>

    <csf:PhoneNumber> N/A</csf:PhoneNumber>

    <csf:PhoneExtension> N/A</csf:PhoneExtension>

    <csf:phoneCountyCode> N/A</csf:phoneCountyCode>

    </rdf:Description>

    </csf:Phone3>

    </rdf:Description>

    </rdf:RDF>

     

    3. Read the profile based on the rdf:about namespace (like http://schemas.microsoft.com/connectedservices/pm#/dik@contoso.com and http://schemas.microsoft.com/connectedservices/pm#/tom@contoso.com respectively) and convert the rdf format to xml using RdfGraph.toRdfXml().

    4. Create an XmlDocument and loaded the xml returned by RdfGraph.toRdfXml().

    5. Observed the InnerXml for both the users.

    OutPut for FirstUser:

    <rdf:RDF xmlns:tns1="http://schemas.microsoft.com/connectedservices/pm#/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="http://schemas.microsoft.com/connectedservices/pm#/dik@contoso.com">

    <tns1:FirstName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Dikson</tns1:FirstName>

    <tns1:Phone1 rdf:nodeID="node1" />

    <tns1:Phone2 rdf:nodeID="node2" />

    <tns1:Phone3 rdf:nodeID="node3" />

    </rdf:Description>

    <rdf:Description rdf:nodeID="node1">

    <tns1:phoneCountyCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneCountryCode2</tns1:phoneCountyCode><tns1:PhoneExtension rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneExtension1</tns1:PhoneExtension><tns1:PhoneNumber rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneNumber1</tns1:PhoneNumber><tns1:PhonePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhonePrefix1</tns1:PhonePrefix><tns1:PhoneType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Primary1</tns1:PhoneType></rdf:Description>

    <rdf:Description rdf:nodeID="node2"><tns1:phoneCountyCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:phoneCountyCode><tns1:PhoneExtension rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneExtension><tns1:PhoneNumber rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneNumber><tns1:PhonePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhonePrefix><tns1:PhoneType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneType></rdf:Description>

    <rdf:Description rdf:nodeID="node3"><tns1:phoneCountyCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:phoneCountyCode><tns1:PhoneExtension rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneExtension><tns1:PhoneNumber rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneNumber><tns1:PhonePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhonePrefix><tns1:PhoneType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneType></rdf:Description></rdf:RDF>

    Output for 2nd User:

    <rdf:RDF xmlns:tns1="http://schemas.microsoft.com/connectedservices/pm#/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="http://schemas.microsoft.com/connectedservices/pm#/tom@contoso.com">

    <tns1:FirstName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Tom</tns1:FirstName>

    <tns1:Phone1 rdf:nodeID="node1" />

    <tns1:Phone2 rdf:nodeID="node2" />

    <tns1:Phone3 rdf:nodeID="node2" />

    </rdf:Description>

    <rdf:Description rdf:nodeID="node1"><tns1:phoneCountyCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneCountryCode2</tns1:phoneCountyCode><tns1:PhoneExtension rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneExtension1</tns1:PhoneExtension><tns1:PhoneExtension rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneExtension2</tns1:PhoneExtension><tns1:PhoneNumber rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneNumber1</tns1:PhoneNumber><tns1:PhoneNumber rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhoneNumber2</tns1:PhoneNumber><tns1:PhonePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhonePrefix1</tns1:PhonePrefix><tns1:PhonePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PhonePrefix2</tns1:PhonePrefix><tns1:PhoneType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Primary1</tns1:PhoneType><tns1:PhoneType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Primary2</tns1:PhoneType></rdf:Description><rdf:Description rdf:nodeID="node2"><tns1:phoneCountyCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:phoneCountyCode><tns1:PhoneExtension rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneExtension><tns1:PhoneNumber rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneNumber><tns1:PhonePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhonePrefix><tns1:PhoneType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">N/A</tns1:PhoneType></rdf:Description></rdf:RDF>

     

    Observation:

    For the first user whoever data is inserted first, nodes are created properly and able to read all the data.

    For the second user not able to read the data properly.

    For both the user’s phone data, same key is getting created in the RDFStoreBlankNode table and not able to retrieve the respective data for a user.

    Expectation: I am expecting User2’s Phone1, Phone2, Phone3 ref:NodeID should be in the same sequence as its for User1.

    Note: Our objective is to read all the data including the data present in the BlankNode and assign them to a object.

    Find below the code snipet for reding the profile:

    string sparqlParameter=" dik@contoso.com";

    string queryForUser = @"PREFIX csf:<http://schemas.microsoft.com/connectedservices/pm#>

    Construct {<http://schemas.microsoft.com/connectedservices/pm#/" + sparqlParameter + "> ?pred ?obj}" +

    "Where {<http://schemas.microsoft.com/connectedservices/pm#/" + sparqlParameter + "> ?pred ?obj}";

    ReadProfileRequest request = new ReadProfileRequest();

    request.Query = queryForUser;

    Microsoft.ConnectedServices.Sdk.Message msg = Microsoft.ConnectedServices.Sdk.Message.CreateMessage(ProfileManagerActions.ReadProfileRequest, serviceUri, request);

    msg.Header.Security.Add(new Microsoft.ConnectedServices.Sdk.Security.Tokens.UsernameToken("PM-Service@sewinlive.com", "*********", Microsoft.ConnectedServices.Sdk.Security.Tokens.PasswordOption.SendPlainText));

    MessageSender sender = new MessageSender();

    ReadProfileResponse rpResponse = sender.SendSync<ReadProfileResponse>(msg);

    RdfGraph rgReadUser = new RdfGraph();

    string userRead = rpResponse.RdfXml.OuterXml.ToString();

    rgReadUser.Load(userRead);

    rgReadUser.ToRdfXml();

    XmlDocument xmldoc = new XmlDocument();

    xmldoc.LoadXml(rgReadUser.ToRdfXml());

     

    Scenario 2: Updating UserProfile with blanknodes

     

    1.Suppose we have structure as follows:

    <rdf:RDF xmlns:csf="http://schemas.microsoft.com/connectedservices/pm#/"

    xmlns:owl="http://www.w3.org/2002/07/owl#"

    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

    <rdf:Description rdf:about="http://schemas.microsoft.com/connectedservices/pm#/dik@contoso.com">

    <csf:FirstName>Dikson</csf:FirstName>

    <csf:Phone1>

    <rdf:Description>

    <csf:PhoneType>Primary1</csf:PhoneType>

    </rdf:Description>

    </csf:Phone1>

    </rdf:Description>

    </rdf:RDF>

    2. We create the above user profile and rows created in the RDFStore and RDFStoreBlankNode tables for nodes and blanknodes respectively.

    3. Now we want update the FirstName and PhoneType of the namespace:" http://schemas.microsoft.com/connectedservices/pm#/dik@contoso.com".

    We are able to update the FirstName with the help of DevGuide coding but not able to code that should update the blank node ie.PhoneType.

    One more thing is while updating the profile how we will know in advance that whether the node is a blanknode or a simple node.

    For Example: As we want to udpdate FirstName and PhoneType in order to update that user profile, how can we know in advance which one is a simple node and which one is blanknode.

     

    Wednesday, October 25, 2006 10:48 AM

Answers

  • Venkat - We have identified this issue with the blanknodes. Currently we are working to fix this issue. Once it is fixed will let you know.

    Thanks

    Friday, October 27, 2006 4:54 AM