Follow Fantora on Twitter
Fantora Word of Classified Ads and Community Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

creating a profile in commerce server 2009 pragmatically

Options
richard
Posted: Wednesday, August 17, 2011 3:38:13 AM
Rank: Advanced Member
Groups: Member

Joined: 6/9/2008
Posts: 203
Points: 621
Location: California, USA

creating a profile in commerce server 2009 pragmatically

Below are step by step instruction of how to create profile in commerce server 2009 using profile service


Create an instance of the ProfilesWebService object.

Specify the credentials needed by the Profiles Web service.

Using a string variable, construct an XML representation of the profile that you want to create.

Create an XML document from the XML string.

Convert the XML document into an XML element.

Call the CreateProfile method of the ProfilesWebService object.

If you are using the Profiles Web Service, add a reference to the Profiles Web service. Example 1 assigns the Profiles Web Service the alias profileWS. For example, this is a valid reference:

Code:
http://localost/ProfilesWebService/ProfilesWebService.asmx


To compile the code when you are using the Profiles Web service, you need to include these namespace directives:

Code:
using System.Xml;
using System.Net;


This example creates an instance of the Profiles Web service. It uses the CreateProfile method to create a new profile, passing in the XML element structure needed to pass the default required properties. The example also builds the XML element structure by first constructing an XML string so that it can be easily read for example purposes.

Code:
// Declare and set variables.
XmlDocument profileXMLDoc = new XmlDocument();
XmlElement profileXMLElement = null;
String profileXML = "";
String newGuid = "{" + Guid.NewGuid().ToString() + "}";
String password = "password";
String eMail = "someone@example.com";
String passwordQuestion = "My Question";
String passwordAnswer = "My Answer";
String accountStatus = "1";
// active

try
{
    // Create an instance of the Profiles Web reference.
    ProfilesWS.ProfilesWebService profileWS = new ProfilesWS.ProfilesWebService();

    // Pass the correct credentials to the Web service.
    profileWS.Credentials = CredentialCache.DefaultNetworkCredentials;

    // Create an XML representation of the Profile.
    profileXML += "<ProfileDocument>";
    profileXML += "  <UserObject>";
    profileXML += "    <GeneralInfo>";
    profileXML += "      <user_id>" + newGuid + "</user_id>";
    profileXML += "      <user_security_password>" + password + "</user_security_password>";
    profileXML += "      <email_address>" + eMail + "</email_address>";
    profileXML += "      <password_question>" + passwordQuestion + "</password_question>";
    profileXML += "      <password_answer>" + passwordAnswer + "</password_answer>";
    profileXML += "    </GeneralInfo>";
    profileXML += "    <AccountInfo>";
    profileXML += "      <account_status>" + accountStatus + "</account_status>";
    profileXML += "    </AccountInfo>";
    profileXML += "  </UserObject>";
    profileXML += "</ProfileDocument>";

    // Load the Profile into an XML document.
    profileXMLDoc.LoadXml(profileXML);

    // Convert the XML document to an XMLElement.
    profileXMLElement = profileXMLDoc.DocumentElement;

    // Create the Profile. The false parameter indicates that this is not created from a BizTalk adapter.
    profileWS.CreateProfile(ref profileXMLElement, false);


    // Write a message to the console when the profile is successfully created.
    Console.WriteLine("Successfully created profile");
}
catch (Exception ex)
{
    Console.WriteLine("Exception: {0}\r\nMessage: {1}", ex.GetType(), ex.ToString());
    if (ex.InnerException != null)
    {
        Console.WriteLine("\r\nInner Exception: {0}\r\nMessage: {1}", ex.InnerException.GetType(), ex.InnerException.Message);
    }
}





Users browsing this topic
Guest

 Related
how to remove 404 error
Linq query in MVC
creating a profile in commerce server 2009 pragmatically
A little confusion on ICallbackEventHandler
using AdRotator control in ASP.Net
Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ..
Commerce Server 2009 Starter Site step by step
nopCommerce ASP.NET/C# based opensource shopping cart Installation
MVC Application Structure
'System.Exception' was thrown
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Fantora Blog | Discount Shop UK | Discount Shop USA | Discount Shop Canada | Discount Boutique France | Discount Shop Deutschland | Discount Shop Italia | Descuento Shop España

Free Classified ads, Webmaster Forum & Technology Reviews | Fantora Free Classified Ads | Buy & Sell Electronics, Mobile phones & Accessories | fantora Forums Community | Buy & Sell DVD, Games and Consols | Free eBooks & Softwares | SEO & Affiliate Marketing Discussion | Programming Language Forum (.NET, ASP, PHP, SQL) | Free Classified Ads | General Stuff (Movies, Chat, Comics) | Free Online English Movies & Reviews | Free Online Hindi Movies & Reviews | Australia & New Zealand Immigration Forum | Europe immigration forum | Canada Immigration Forum | Ireland Immigration Forum | US Immigration Forum | United Kingdom Immigration Forum

Main Forum RSS : RSS

Powered by: YAF.NET
Copyright © AI Logica All rights reserved.
This page was generated in 0.181 seconds.