这里我们首先需要启用MDS当中的Web Service服务,启动方法见《 如何启用Master Data Services的Web服务》。
- 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的站点有缓存机制,如果你之前已经打开了该站点,则刷新之后不会看到新添加的那个Model,需要关闭浏览器或清理缓存。
原文链接:http://blog.csdn.net/xuyue1987/article/details/6642449
分享文章:如何MasterDataService调用API创建Model
网页链接:http://www.shufengxianlan.com/qtweb/news1/379501.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联