Configure and use the HTTP adapter for the BizTalk Development Series ()

Source: Internet
Author: User

Biztalk hosts are in-process hosts and independent hosts respectively. However, since I have been using in-process hosts, my understanding of independent hosts is vague. Recently, when I was working on a BizTalk project, some systems use HTTP to publish text such as TXT. The difference between the HTTP adapter and other adapters is that its receiving adapter is hosted on an independent host (IIS. Additional configuration is required during use. Now let's take a look at the use of the HTTP receiving adapter running on an independent host and the sending adapter running on the host in the process.

 

Configure IIS for the HTTP receiving location

Biztalk hosts are divided into in-process hosts and out-of-process hosts. In-process hosts refer to the hosts of the processes in which the hosts run in BizTalk. Independent hosts refer to external processes (such as ISAPI extensions and ASP.. Net) the host of the adapter. Therefore, you must configure the IIS BizTalk receiving adapter extension before configuring the HTTP receiving location.

1. First open the IIS manager and add a new Web Service extension to the Web service extension.

2. Enter the extension name and location in the new web extension. The BizTalk extension location is generally: C: \ Program Files \ Microsoft BizTalk Server 2006 \ httpreceive \ btshttpreceive. dll. Finally, set the scaling status to allow.

3. After the settings are complete, you can view the newly added extensions in IIS Web service extensions.

 

 

Configure the receiving location

Previously, it was mentioned that the HTTP adapter runs on an independent host, so the configuration of the receiving location is a little different from that of other adapters, that is, in addition to configuration in the BizTalk application, you also need to configure on the independent host (IIS.

1. It is relatively simple to create a receiving location on IIS. You only need to create a virtual directory on IIS to direct the directory address to the directory of BizTalk HTTP extension DLL. However, there are two points to note: one is to select read and execute the running mode of the virtual directory for the sake of security, and the other is to create an independent running pool for the isolation level, the account of the running pool must exist in the BizTalk isolated hosts and iis_wpg groups. In addition, you must specify a running pool for the virtual directory.

Specify a user for the running pool

Specify a running pool for the virtual directory

At this point, you may try to access this receiving location. Because you have not configured the receiving location in BizTalk application, you will receive an HTTP 500 error during access. However, BizTalk provides friendly prompts In the event log, as shown below. If an error occurs during configuration or running, you can refer to the information to solve the problem.

The BizTalk HTTP receive adapter failed to initialize itself. Possible reasons:
1) receive location URL is not created/configured correctly.
2) receive location is not enabled.
3) HTTP receive adapter is not running under a user that has access to management and message databases.
4) isolated host instance is not created for HTTP receive adapter.

2. Configure the HTTP receiving location in BizTalk application. As shown in, you only need to configure the virtual directory address.

Test

Before testing, we need to create a sending port to receive messages from the HTTP receiving port. The HTTP receiving adapter supports get and post requests. For get testing, we can add a question mark after the URL and the data of your request.

The post method can be used to write code or borrow a third-party tool. Here, Fiddler is used. A very powerfulFreeHTTP debuger tool.

 

 

Configure the sending Port

Because the HTTP sending adapter runs on an in-process host, the configuration is simpler than the receiving Adapter. You only need to configure the target HTTP path (if security problems occur)

Test

Based on the previously created receiving location, we subscribe to messages published from the HTTP receiving adapter on the HTTP sending port. Create An ASPX page at the same time. Write the received request data to the log (a small amount of data is used for testing ).

System. Io. streamreader QR = new system. Io. streamreader (request. inputstream, system. Text. encoding. utf8 );
String uristring = QR. readtoend ();

If (! String. isnullorempty (uristring ))
{
System. Diagnostics. EventLog. writeentry ("httpdemo", "content: \ r \ n" + uristring );
}

 

After an HTTP request is published, we can view the corresponding records in the log.

 

 

Use the HTTP adapter to receive text such as TXT. 

The reason why the received text is raised is that the HTTP receiving adapter is hosted on IIS and requires the requester to actively request this path. However, some systems may publish text through HTTP. For example, a path like a http://www.cbcye.com/demo.txt. Therefore, you cannot use the HTTP receiving adapter to actively request TXT. This task falls on the sending adapter, but the sending adapter only supports the POST method. TXT text cannot be obtained through the POST method.

Therefore, you need to create a receiving proxy (ASPX page). The proxy is used to receive requests from the sending Adapter. Then, you can use the following code to obtain text data from the target path and return the data, the receiving method of the sent adapter. Note that the Code on the front-end page needs to be removed. In this way, the received TXT information can be returned as is.

System. Io. streamreader QR = new system. Io. streamreader (request. inputstream, system. Text. encoding. utf8 );
String uristring = QR. readtoend ();
If (! String. isnullorempty (uristring ))
{
System. net. httpwebrequest Req = (system. net. httpwebrequest) system. net. webrequest. Create (uristring );
Req. useragent = "Mozilla/5.0 (windows; U; Windows NT 5.2; ZH-CN; RV: 1.9.0.3) Gecko/2008092417 Firefox/3.0.3 (. net clr 3.5.21022 )";
System. net. httpwebresponse res = (system. net. httpwebresponse) Req. getresponse ();
System. Io. streamreader sr = new system. Io. streamreader (res. getresponsestream (), system. Text. encoding. utf8 );
Response. Write (Sr. readtoend ());
}

Configure and use the HTTP adapter for the BizTalk Development Series ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.