Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
There are many ways to create a profile in Commerce Server 2007. One way is to create a profile based on an XML representation of the user profile. Creating a profile instance from an XML document is a simple process. You construct the XML representation of a profile and pass it to the CreateProfile method of a ProfileManagementContext instance.
To create a profile instance by using XML
Create a subroutine called CreateXMLProfile.
Declare a string to store the XML representation of the profile.
Declare a GUID to store and generate the profile key.
Create an XML representation of the profile.
Create a ProfileManagementContext object.
Load the XML string into an XML document.
Create the profile by calling the CreateProfile method of the ProfileManagementContext instance.
Example
The following code example creates a subroutine called CreateXMLProfile, which creates a profile by using an XML representation of the profile.
private void CreateXMLProfile()
{
// Declare variables.
String xmlData = "";
String myGUID = Guid.NewGuid().ToString();
XmlDocument profileXMLDoc = new XmlDocument();
// Create XML representation of the user profile.
xmlData += @"<ProfileDocument>";
xmlData += @" <UserObject>";
xmlData += @"<GeneralInfo>";
xmlData += @"<user_id>" + myGUID + "</user_id>";
xmlData += @" <user_security_password>myPassword</user_security_password>";
xmlData += @" <password_question>myQuestion</password_question>";
xmlData += @" <password_answer>myAnswer</password_answer>";
xmlData += @"<email_address>someone@microsoft.com</email_address>";
xmlData += @"<direct_mail_opt_out>0</direct_mail_opt_out>";
xmlData += @"<express_checkout>0</express_checkout>";
xmlData += @"</GeneralInfo>";
xmlData += @" <AccountInfo>";
xmlData += @" <account_status>1</account_status>";
xmlData += @" </AccountInfo>";
xmlData += @"</UserObject>";
xmlData += @"</ProfileDocument>";
// Access Profiles Web service.
ProfileManagementContext ctxtWS = ProfileManagementContext.Create("https://localhost/ProfilesWebService/ProfilesWebService.asmx");
// Load the XML string into an XML document.
profileXMLDoc.LoadXml(xmlData);
// Create the XML Profile, converting the XMLDocument to an XMLElement.
ctxtWS.CreateProfile(profileXMLDoc.DocumentElement);
}
Compiling the Code
To compile the code, you must include the following namespace directives:
using Microsoft.CommerceServer.Profiles;
using System.Xml;
See Also
Other Resources
How to Create an Instance of a Profile
How to Access an Instance of a Profile