不将新地址与现有配置文件关联,而是作为新地址插入 [英] Not associate the new address to the existing profile but inserts as a new address

查看:55
本文介绍了不将新地址与现有配置文件关联,而是作为新地址插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在尝试从访问数据库中获取用户信息并将其转储到商业服务器userobject和地址表中。要完成此任务,我创建了一个Windows应用程序,该应用程序又调用配置文件Web服务。


我使用CS 2009配置文件Web服务创建用户信息,然后尝试为现有用户插入新地址。

问题是:我能够成功地在用户对象表中插入用户信息,在地址表中插入地址信息。但是,在UserObject表和Adress表之间没有发生关联,即UserObject - > u_addresses字段未按地址更新 - > u_address_id字段值。


以下是我尝试使用的代码,但它不会将新地址与现有配置文件相关联,而是作为新地址插入。


私人无效CreateXMLProfile(字符串userid,字符串名字,串姓氏,串EMAILID,串passwd中,串securityQ,串securityA,串directMailOpt,串expressChkOut,串accountStatus)
  &NBSP ;     {
            //声明变量。
           字符串xmlData ="" ;;
          
            XmlDocument profileXMLDoc = new XmlDocument();


            //创建用户个人资料的XML表示。
            xmlData + = @"< ProfileDocument>" ;;            xmlData + = @"   < UserObject>英寸;
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; xmlData + = @"< GeneralInfo>" ;;            xmlData + = @"< user_id>" + userID +"< / user_id>" ;;            xmlData + = @"< first_name>" + firstName +"< / first_name>" ;;            xmlData + = @"< last_name>" + lastName +"< / last_name>" ;;            xmlData + = @"< email_address>" + emailID +"< / email_address>" ;;            xmlData + = @"< user_security_password>" + passwd +"< / user_security_password>" ;;            xmlData + = @"< password_question>" + securityQ +"< / password_question>" ;;            xmlData + = @"< password_answer>" + securityA +"< / password_answer>" ;;            xmlData + = @"< direct_mail_opt_out>" + directMailOpt +"< / direct_mail_opt_out>" ;;            xmlData + = @"< express_checkout>" + expressChkOut +"< / express_checkout>" ;;            xmlData + = @"< / GeneralInfo>" ;;            xmlData + = @"       < AccountInfo>英寸;
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; xmlData + = @"           < ACCOUNT_STATUS>" + accountStatus +"< / account_status>" ;;            xmlData + = @"       < / AccountInfo>英寸;
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; xmlData + = @"< / UserObject>" ;;


            xmlData + = @"< / ProfileDocument>" ;;


            //访问配置文件Web服务。
            ProfileManagementContext ctxtWS = ProfileManagementContext.Create(QUOT; HTTP://localhost/DefaultSite_ProfilesWebService/ProfilesWebService.asmx ");


            //将XML字符串加载到XML文档中。
            profileXMLDoc.LoadXml(XMLDATA);


&NBSP;


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; //创建XML配置文件,将XMLDocument转换为XMLElement。
            ctxtWS.CreateProfile(profileXMLDoc.DocumentElement);


             XmlDocument profileXMLDoc1 = new XmlDocument();
           字符串xmlData1 ="" ;;
            xmlData1 + = @"< ProfileDocument>" ;;            xmlData1 + = @"   <地址>英寸;
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; xmlData1 + = @"< GeneralInfo>" ;;            xmlData1 + = @"< address_id>" + Guid.NewGuid()。ToString()+"< / address_id>" ;;            xmlData1 + = @"< first_name>" +"Narendra" +"< / first_name>" ;;            xmlData1 + = @"< last_name>" +"库马尔" +"< / last_name>" ;;            xmlData1 + = @"< address_name>" +"MphasiS" +"< / address_name>" ;;            xmlData1 + = @"< address_line1>" +"DLF" +"< / address_line1>" ;;            xmlData1 + = @"< city>" +"Chennai" +"< / city>" ;;            xmlData1 + = @"< region_code>" +"TN" +"< / region_code>" ;;            xmlData1 + = @"< region_name>" +"TamilNadu" +"< / region_name>" ;;            xmlData1 + = @"< postal_code>" +"523201" +"< / postal_code>" ;;            xmlData1 + = @"< country_code>" +"IN" +"< / country_code>" ;;            xmlData1 + = @"< country_name>" +"印度" +"< / country_name>" ;;            xmlData1 + = @"< / GeneralInfo>" ;;            xmlData1 + = @"< / Address>" ;;            xmlData1 + = @"< / ProfileDocument>" ;;


            //将XML字符串加载到XML文档中。
            profileXMLDoc1.LoadXml(xmlData1);


           //创建XML配置文件,将XMLDocument转换为XMLElement。
            ctxtWS.CreateProfile(profileXMLDoc1.DocumentElement);


}


请帮助我!!

解决方案


 


看看:

如何从Commerce Server站点独立创建配置文件: http:// msdn.microsoft.com/en-us/library/aa545267(CS.70).aspx

Hi All,

I am trying to fetch the user information from the access database and dump it in the commerce server userobject and address tables.To complete this task, I created a Windows application which in turn calls profile webservice.

I am creating User Information  using CS 2009 profile web service and later trying to insert new address for the exisiting user.

PROBLEM IS : I can able to insert User information in the User Object table and Address information in the Address table successfully. But, association is not happening between UserObject table and Adress table i.e UserObject -> u_addresses field is not updated by Address -> u_address_id field value.

Given below is the code that I am trying to use, but It does not associate the new address to the existing profile but inserts as a new address.

private void CreateXMLProfile(string userID,string firstName,string lastName,string emailID,string passwd,string securityQ,string securityA,string directMailOpt,string expressChkOut,string accountStatus)
        {
            // Declare variables.
            String xmlData = "";
          
            XmlDocument profileXMLDoc = new XmlDocument();

            // Create XML representation of the user profile.
            xmlData += @"<ProfileDocument>";
            xmlData += @"   <UserObject>";
            xmlData += @"<GeneralInfo>";
            xmlData += @"<user_id>" + userID + "</user_id>";
            xmlData += @"<first_name>" + firstName + "</first_name>";
            xmlData += @"<last_name>" + lastName + "</last_name>";
            xmlData += @"<email_address>" + emailID + "</email_address>";
            xmlData += @"<user_security_password>" + passwd + "</user_security_password>";
            xmlData += @"<password_question>" + securityQ + "</password_question>";
            xmlData += @"<password_answer>" + securityA + "</password_answer>";
            xmlData += @"<direct_mail_opt_out>" + directMailOpt + "</direct_mail_opt_out>";
            xmlData += @"<express_checkout>" + expressChkOut + "</express_checkout>";
            xmlData += @"</GeneralInfo>";
            xmlData += @"       <AccountInfo>";
            xmlData += @"           <account_status>" + accountStatus + "</account_status>";
            xmlData += @"       </AccountInfo>";
            xmlData += @"</UserObject>";

            xmlData += @"</ProfileDocument>";

            // Access Profiles Web service.
            ProfileManagementContext ctxtWS = ProfileManagementContext.Create("http://localhost/DefaultSite_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);

             XmlDocument profileXMLDoc1 = new XmlDocument();
            String xmlData1 = "";
            xmlData1 += @"<ProfileDocument>";
            xmlData1 += @"   <Address>";
            xmlData1 += @"<GeneralInfo>";
            xmlData1 += @"<address_id>" + Guid.NewGuid().ToString() + "</address_id>";
            xmlData1 += @"<first_name>" + "Narendra" + "</first_name>";
            xmlData1 += @"<last_name>" + "Kumar" + "</last_name>";
            xmlData1 += @"<address_name>" + "MphasiS" + "</address_name>";
            xmlData1 += @"<address_line1>" + "DLF" + "</address_line1>";
            xmlData1 += @"<city>" + "Chennai" + "</city>";
            xmlData1 += @"<region_code>" + "TN" + "</region_code>";
            xmlData1 += @"<region_name>" + "TamilNadu" + "</region_name>";
            xmlData1 += @"<postal_code>" + "523201" + "</postal_code>";
            xmlData1 += @"<country_code>" + "IN" + "</country_code>";
            xmlData1 += @"<country_name>" + "India" + "</country_name>";
            xmlData1 += @"</GeneralInfo>";
            xmlData1 += @"</Address>";
            xmlData1 += @"</ProfileDocument>";

            // Load the XML string into an XML document.
            profileXMLDoc1.LoadXml(xmlData1);

           // Create the XML Profile, converting the XMLDocument to an XMLElement.
            ctxtWS.CreateProfile(profileXMLDoc1.DocumentElement);

}

Please help me !!

解决方案

Hi,

 

Have a look at:

How to Create a Profile Independently from a Commerce Server Site : http://msdn.microsoft.com/en-us/library/aa545267(CS.70).aspx


这篇关于不将新地址与现有配置文件关联,而是作为新地址插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆