BizTalk 2006 R2 – consume an .ASMX webservice using WCF-BasicHttp adapter

|  Posted: May 31, 2007  |  Categories: BizTalk Server

Normally when we need to consume a .asmx web service in BizTalk 2004/2006 (NOT R2) inside an orchestration, we add a web reference, which will create all the multi-part message and web port type required to consume the orchestration. You construct the orchestration and¬†configure the SOAP adapter in the send port to consume the web service. I suppose that’s the normal route any BizTalk developer will take when you are put under a circumstance to consume an .asmx webservice using WCF-BasicHttp adapter.

But when you are going to use the WCF-BasicHttp adapter, Add Web Reference is not going to work, and we need to take advantage of the hidden Consume WCF Service wizard, which comes as part of BizTalk 2006 R2. The wizard will generate required schemas, multi-part messages, orchestration port types, and also binding files for both basicHttp and custom binding. I’ll put the steps here to consume a basic .asmx webservice in BizTalk 2006 R2 with WCF-BasicHttp adapter.

The sample webservice we are going to use contains a very simple webmethod as shown below.

[WebMethod]
public string ConcatName(string firstName, string lastName)
{
return firstName + ” ” + lastName;
}

The below walk-through is based on the sample webservice, which comes as part of the download.

    1. Create a blank BizTalk Project
    2. Right-Click on the project and select Add->Add Generated Items->Consume WCF Service
    3. Select the option “Metadata file (WSDL and XSD)“, Click “Next”

biztalk wcf service consuming wizard

    1. Open an instance of a browser and navigate to your “.asmx?WSDL” file and save it somewhere in your harddrive (Example: c:Service.wsdl).
    2. Click on the “Add” button (next step in the wizard after the one shown above), browse to the .WSDL file you saved in Step 4, Click “Next” (Accept defaults), Click “Import” and then Click “Finish” to complete the wizard.
    3. Once you click “Finish” the following files will be added to your project (File name will depend on the name of the .WSDL file you selected)
      Service.BindingInfo.xml
      Service.odx
      Service_Custom.BindingInfo.xml
      Service.tempuri_org.xsd
    4. Open the Service.odx file, inside the orchestration view create 2 messages as shown below
      WSRequest – Multi-part Message Type – ConsumeWebService.ConcatNameSoapIn
      WSResponse – Multi-part Message Type – ConsumeWebService.ConcatNameSoapOut
    5. Right-Click on the orchestration “Port Surface“, Click “Next”, In the port properties page Click “Next”, In the “Select a Port Type” page select “Use an existing Port Type” and select “ConsumeWebService.ServiceSoap“, In port binding page select “I’ll be sending a request and receiving a response.” for port direction and “Specify later” for port binding. Click “Next” and then “Finish”.
    6. Construct an orchestration as shown in the below figure
      Receive_1 -> Activate=true, Message= WSRequest
      Send_1 -> Message = WSRequest
      Receive_2 -> Message = WSResponse
      Send_2 -> Message = WSResponse

biztalk send/receive ports

  1. I created a FILE Receive and FILE Send (Specify Now) port binding for port_2 and port_3
  2. Assign a key file to the project and set the “Application Name” to “ConsumeWebService“. Build and Deploy the project.
    Open BizTalk Administration Console, Right-Click on the application and select “Import Binding“. Browse to the auto generated binding file “Service.BindingInfo.xml” and select it.
  3. Bind your Orchestration to the correct ports and host. For the .asmx webservice logical port, select the auto generated “WcfSendPort_Service_ServiceSoap“. (Start the application)
  4. Create a sample message by right-clicking on “Service_tempuri_org.xsd” file and clicking “Generate Instance“. Drop the message in the folder you configured for port_2 in the orchestration, you should see the output result in folder you configured for port_3 in your orchestration.

Download the sample here

Nandri!

Saravana

Author: Saravana Kumar

Saravana Kumar is the Founder and CTO of BizTalk360, an enterprise software that acts as an all-in-one solution for better administration, operation, support and monitoring of Microsoft BizTalk Server environments.

  • Cristian

    Awesome, thank you very much!!

    • Guido Junior

      what is the SOLUTION to the username token issue

  • Guest

    Hi Mr. Saravana:

    I have the following problem:

    I did all that you have written here, but the diference is, the web service im trying to call, need a header for the authentification, i dont know how to add that header, because when i call that web service i get an error SBL-EAI-05162 (this error comes from Siebel)

    http://schemas.xmlsoap.org/ws/2002/07/secext

    *********
    ******

    • Guido Junior

      HELP !!! what is the SOLUTION to the username token issue

  • Josh Mendoza

    Hi Mr. Saravana.

    I have the following problem:

    I did all that you have written here, but the difference is, the web service I am trying to call, need a header for the authentication, I don’t know how to add that header, because when I call that web service i get an error SBL-EAI-05162 (this error comes from Siebel). They told me (people from Siebel) that I should to join the next xml code to my Schema.

    http://schemas.xmlsoap.org/ws/2002/07/secext

    *******
    ******

  • Guido Junior

    hi guys, so what is the SOLUTION to the username token issue described below

One Platform Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

One Platform - Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

One Platform - Operations, Monitoring and Analytics Software
ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

Back to Top