调用REST API以使用Biztalk WCF-WebHttp适配器获取CSV数据 [英] Calling REST API to fetch CSV data using Biztalk WCF-WebHttp adapter

查看:218
本文介绍了调用REST API以使用Biztalk WCF-WebHttp适配器获取CSV数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从rest API获取一些.csv数据,将其映射到XML并将其存储在SQL Server中.

I need to get some .csv data from a rest API, map it to XML and store it in an SQL server.

从CSV到XML的映射已经完成,并且已设置SQL Server并准备好接收包含数据的XML文档.

The CSV to XML maps have already been completed and the SQL server is setup and ready to receive the XML documents containing the data.

我正在使用的REST API是公共的,因此不需要凭据.

The REST API I am consuming is a public one, so no credentials needed.

以下是带有包含标头的.csv数据的示例:

Here is an example of the .csv data with the included header:

sekvensnummer,tidspunkt,operation,id,kommunekode,kode,oprettet,ændret,navn,adresseringsnavn,navngivenvej_id
48354673,2018-01-14T02:08:38.432Z,insert,,0306,2901,,,Hedvigsvej,Hedvigsvej,
48352674,2018-01-14T02:08:38.432Z,insert,,0201,1187,,,Bøgeholm Alle,Bøgeholm Alle,
48252675,2018-01-14T02:08:38.432Z,insert,,0225,0938,,,Stoustrædet,Stoustrædet,
48357676,2018-01-14T02:08:38.432Z,insert,,0265,0937,,,Stouvænget,Stouvænget,
48352687,2018-01-14T02:08:38.432Z,insert,,0265,0936,,,Dyssevænget,Dyssevænget,

我将其映射到XML文档,格式如下:

I am mapping this to an XML document, in this format:

<ns0:Vejstykke xmlns:ns0="http://Company.Vejregister.Schemas.Vejstykke_XML">
    <Data>
        <sekvensnummer>48352273</sekvensnummer>
        <tidspunkt>2018-01-14T02:08:38.432Z</tidspunkt>
        <operation>insert</operation>
        <id/>
        <kommunekode>0376</kommunekode>
        <vejkode>2901</vejkode>
        <oprettet/>
        <ændret/>
        <navn>Hedvigsvej</navn>
        <vejnavn>Hedvigsvej</vejnavn>
        <navngivenvej_id/>
    </Data>

我知道我需要使用WCF-WebHttp适配器来获取csv数据.我需要每天调用一次API,以获取最新数据.

I am aware that I need to use the WCF-WebHttp adapter to GET the csv data. I need to call the API once a day to fetch the most recent data.

在WCF-WebHttp适配器的配置中,我需要为数据输入一个URI.现在,我已经使用:

In the configuration for the WCF-WebHttp adapter, I need to input an URI to the data. For now I have used:

/http://dawa.aws.dk/adresser?kommunekode=0326&format=csv

在HTTP方法和URL映射中,我编写了:GET

In the HTTP method and URL mapping I have written: GET

接收端口设置为使用CSV到XML的映射作为入站映射.

The receive port is set to use the CSV to XML map as an inbound map.

但是没有数据被拾取.

But no data is being picked up.

我在事件日志中没有收到任何警告或错误.

I am receiving no warnings or errors in the event log.

何时触发URI的GET请求?有没有办法我可以手动调用它?

When is the GET request to the URI triggered? Is there a way I can call it manually?

如果您需要更多信息,请告诉我.

Let me know if you need more information.

推荐答案

要调用API,您必须触发它,在您的方案中BizTalk必须触发它.

In order to call the API you have to trigger it, in your scenario BizTalk has to trigger it.

请按照以下步骤进行触发

Please follow the below steps to trigger it

  1. 创建一个接收端口/接收位置,将其命名为API Scheduler或一个友好名称,该名称使用WCF-SQL并配置为 mssql://servername//BizTalkMgmtDb?InboundId=putyouridentifier

  1. Create a Receive Port / Receive location name it as API scheduler or a friendly name, which uses the WCF-SQL and configuration as mssql://servername//BizTalkMgmtDb?InboundId=putyouridentifier

为您的案例设置轮询间隔的绑定时间为24小时(1天)

Set the binding for polling interval in your case 24 hours(1 day)

示例轮询语句:

  1. 现在使用您配置的WCF-WebHTTP适配器创建一个双向发送端口,并使用GET方法并将过滤器放置为BTS.Receiveportname == CreatedReceivePort并通过发送管道传递,接收的数据将是您的管道.

现在,您应该能够轻松获取相应的数据.

Now you should be able to fetch the corresponding data easily.

这篇关于调用REST API以使用Biztalk WCF-WebHttp适配器获取CSV数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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