新聞中心
SQL Server 2008 R2的主數(shù)據(jù)服務(wù)(Master Data Services,簡(jiǎn)稱(chēng)MDS)可以調(diào)用應(yīng)用程序接口API來(lái)創(chuàng)建Model,本文我們就介紹了這一創(chuàng)建的過(guò)程,需要說(shuō)明的是首先需要啟用MDS當(dāng)中的Web Service服務(wù),啟動(dòng)方法可以參考這篇文章:如何啟用Master Data Services的Web服務(wù)。接下來(lái)我們就開(kāi)始介紹這一過(guò)程。

創(chuàng)新互聯(lián)公司是一家專(zhuān)業(yè)提供拉薩企業(yè)網(wǎng)站建設(shè),專(zhuān)注與成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、HTML5建站、小程序制作等業(yè)務(wù)。10年已為拉薩眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專(zhuān)業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。
添加服務(wù)引用
在解決方案資源管理器窗口中,右鍵單擊引用,單擊添加服務(wù)引用;在地址,輸入的 URL 的 MDS 服務(wù)將"http://
在此示例中,我將其命名為MDService;單擊高級(jí)按鈕,可以配置高級(jí)的設(shè)置;勾選Always generate message contracts(不確定中文版翻譯成什么);設(shè)置集合類(lèi)型下拉到System.Collections.ObjectModel.Collection;單擊確定返回到添加服務(wù)引用對(duì)話框。
通過(guò)API創(chuàng)建模型
- private static ServiceClient mdsProxy;
- protected void Page_Load(object sender, EventArgs e)
- {
- try
- {
- mdsProxy = CreateMdsProxy("http://devserver:8080/Service/Service.svc");
- }
- catch (Exception ex)
- {
- Response.Redirect("Error connecting:" + ex.Message);
- }
- }
- private static ServiceClient CreateMdsProxy(string mdsURL)
- {
- System.ServiceModel.EndpointAddress endptAddress = new System.ServiceModel.EndpointAddress(mdsURL);
- System.ServiceModel.WSHttpBinding wsBinding = new System.ServiceModel.WSHttpBinding();
- return new ServiceClient(wsBinding, endptAddress);
- }
- private void CreateModel(string newModelName)
- {
- MetadataCreateRequest request = new MetadataCreateRequest();
- MetadataCreateResponse response = new MetadataCreateResponse();
- request.Metadata = new Metadata();
- request.Metadata.Models = new System.Collections.ObjectModel.Collection
() { new Model() }; - request.Metadata.Models[0].Identifier = new Identifier();
- request.Metadata.Models[0].Identifier.Name = newModelName;
- response = mdsProxy.MetadataCreate(request);
- }
- protected void btnCreateModel_Click(object sender, EventArgs e)
- {
- CreateModel("TestModel");
- }
- }
注意:MDS的站點(diǎn)有緩存機(jī)制,如果你之前已經(jīng)打開(kāi)了該站點(diǎn),則刷新之后不會(huì)看到新添加的那個(gè)Model,需要關(guān)閉瀏覽器或清理緩存。
關(guān)于使用SQL Server 2008 R2的主數(shù)據(jù)服務(wù)MDS調(diào)用API創(chuàng)建Model的過(guò)程就介紹到這里了,希望本次的介紹能夠帶給您一些收獲吧!
【編輯推薦】
- 如何啟用Master Data Services的Web服務(wù)
- MySQL數(shù)據(jù)庫(kù)如何實(shí)現(xiàn)跨表更新與數(shù)據(jù)并合
- MySQL數(shù)據(jù)庫(kù)修改MySQL密碼的六種措施總結(jié)
- SQL Server數(shù)據(jù)庫(kù)如何使用存儲(chǔ)過(guò)程造批量數(shù)據(jù)
- 如何將SQL Server 2008的數(shù)據(jù)復(fù)制到MySQL數(shù)據(jù)庫(kù)
網(wǎng)站標(biāo)題:使用SQLServer2008R2的主數(shù)據(jù)服務(wù)調(diào)用API創(chuàng)建Model
網(wǎng)頁(yè)URL:http://m.fisionsoft.com.cn/article/cojigop.html


咨詢
建站咨詢
