动态调用Restful Services

时间:2015-07-23 12:31:08

标签: biztalk biztalk-2013

我有一个现有的业务流程,它使用以下配置调用服务。

System.Diagnostics.EventLog.WriteEntry("ABC", Message_Datasheets(FILE.ReceivedFileName));
varNewSearchDataLoadURL = System.Configuration.ConfigurationManager.AppSettings["NewSearchDataLoadURL"];
varNewXmlMsg = new System.Xml.XmlDocument(); 
varNewXmlMsg.LoadXml(@"<path>" + Message_Datasheets(FILE.ReceivedFileName) + @"</path>");
Message_NewUnZip = varNewXmlMsg;
Message_NewUnZip(HTTP.RequestTimeout) = 3600;
Port_NewJaxMiceSearch_API(Microsoft.XLANGs.BaseTypes.Address) = varNewSearchDataLoadURL + "?path=" + Message_Datasheets(FILE.ReceivedFileName);
Port_NewJaxMiceSearch_API(Microsoft.XLANGs.BaseTypes.TransportType) = "HTTP"

这里NewSearchDataLoadURL保存需要在配置文件中调用的web服务的地址。路径保存接收的文件名。所以被叫URI将是“http://new.abc.org/AbcSearchWebApi/api/search/loaddatafeed?path=\share01 \ BizTalk \ data \ out \ 20150723 “

现在我必须将其更改为使用WebHttp Adapter的Restful服务。我想跟随这里

但我不理解BtsVariablePropertyMapping因为我没有具有要升级的值的架构。我该怎么办呢。 enter image description here  任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

因此,您的目标是使用动态端口调用Rest WebService,为此,您需要执行此操作 1 - 指定您的操作类型

RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
            Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
            runspace.Open();
            var runSpaceInvoker = new RunspaceInvoke(runspace);
            runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted -Scope Process -Force");
            Pipeline pipeline = runspace.CreatePipeline();
            var appPoolName = new CommandParameter(null, command.SiteName);
            var siteName = new CommandParameter(null, command.SiteName);
            var scriptPath = ConfigurationManager.AppSettings["PowershellSscriptRootPath"];
            var websiteRootFolder = ConfigurationManager.AppSettings["PhysicalPathRoot"];
            var websitePath = websiteRootFolder + "\\" + command.SiteName + "\\";

            #region CreateWebsite

            string scriptPathForCreateWebsiteFromConfiguration = scriptPath + ConfigurationManager.AppSettings["CreateWebsiteScriptName"];
            var createWebsiteCommand = new Command(scriptPathForCreateWebsiteFromConfiguration);
            createWebsiteCommand.Parameters.Add(siteName);
            createWebsiteCommand.Parameters.Add(appPoolName);
            createWebsiteCommand.Parameters.Add(new CommandParameter(null, "80"));
            createWebsiteCommand.Parameters.Add(new CommandParameter(null, websiteRootFolder)); 
            pipeline.Commands.Add(createWebsiteCommand);

            #endregion
            pipeline.Invoke();
            runspace.Close();

2 - 创建并映射变量:
&#34; BtsVariablePropertyMapping&#34;是一种功能强大的BizTalk技术,可让您在网址中定义自定义变量,并使用其名称和命名空间将其映射到任何上下文属性 所以你必须拥有属性模式,除非它是一个BizTalk上下文属性,因此它的模式已经存在于BizTalk中

3 - 使用webservice网址初始化您的动态端口 在此步骤中,您将在动态请求响应端口

中分配Web服务URL和传输类型
 <BtsHttpUrlMapping>
  <Operation Name=’MyRestGET’ Method=’GET’ Url=’/XXXX/{EmpId}’ />
</BtsHttpUrlMapping>

你很高兴这个

答案 1 :(得分:0)

以下代码可以使用,而不使用BtsVariablePropertyMapping

System.Diagnostics.EventLog.WriteEntry("ABC",   Message_Datasheets(FILE.ReceivedFileName));
varNewSearchDataLoadURL = System.Configuration.ConfigurationManager.AppSettings["NewSearchDataLoadURL"];
varNewXmlMsg = new System.Xml.XmlDocument(); 
varNewXmlMsg.LoadXml(@"<path>" +     Message_Datasheets(FILE.ReceivedFileName) + @"</path>");
Message_NewUnZip = varNewXmlMsg;
Message_NewUnZip(WCF.HttpMethodAndUrl) = @"<BtsHttpUrlMapping><Operation Name = 'RESTGet' Method ='GET'/></BtsHttpUrlMapping>";
Port_NewSearch_API(Microsoft.XLANGs.BaseTypes.Address) = varNewSearchDataLoadURL + "?path=" +      Message_Datasheets(FILE.ReceivedFileName);
Port_NewSearch_API(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-WebHttp";
Message_NewUnZip(WCF.SuppressMessageBodyForHttpVerbs) = "GET";