DOCX

BizTalk-2006-R2-_2D00_-Consume-WCF-Service

By Jacob Lane,2014-04-01 14:53
9 views 0
BizTalk-2006-R2-_2D00_-Consume-WCF-Service

    Consume WCF Service Wizard generates port binding configuration files for import into BizTalk Server

    Scenario: You have already designed, implemented and hosted a WCF Service. Now, you would like to send (and get) messages to this WCF Service in a BizTalk Orchestration process. BizTalk communicates with WCF applications via BizTalk WCF Adapter, which can be configured through send and receive ports in BizTalk. This post talks about how BizTalk’s Consume WCF Wizard can be used to simplify the port

    creation process in BizTalk, especially the need of mapping the operation(s) with the SOAP Action(s) within the port to invoke the operation in WCF Service.

    [BTSR2] now includes a BizTalk WCF Adapter to provide support for WS-* and transport neutrality by letting the user choose most appropriate [WCF] binding in BizTalk Port configuration. The BizTalk WCF Adapter can be selected within a Send Port by creating a new port and then selecting a Transport Type. In Receive Port, the BizTalk WCF Adapter can be selected by creating a new Receive Location and then selecting Transport Type from the drop-down box. The Receive Location allows for hosting a non-HTTP WCF Service within BTSNtSvc.exe and can be enabled within the BizTalk Administration Console without need for publishing.

    Even though WCF-Custom is the only adapter needed, BizTalk allows other WCF adapters for most common messaging scenarios, as shown in the table below. For example, WCF-Custom can be used as WCF-WSHttp transport by selecting WCF-Custom, clicking on Configure, select Binding tab and selecting the Binding Type wsHttpBinding or customize this transport by using wsDualHttpBinding or wsFederationHttpBinding.

     Available Send Port Available Receive Port

    WCF Adapters WCF Adapters

    One-way WCF-BasicHttp WCF-BasicHttp

    WCF-Custom WCF-Custom

    WCF-NetMsmq WCF-CustomIsolated

    WCF-NetNamedPipe WCF-NetMsmq

    WCF-NetTcp WCF-NetNamedPipe

    WCF-WSHttp WCF-NetTcp

    WCF-WSHttp

Two-way WCF-BasicHttp WCF-BasicHttp

    WCF-Custom WCF-Custom

    WCF-NetNamedPipe WCF-CustomIsolated

    WCF-NetTcp WCF-NetNamedPipe

    WCF-WSHttp WCF-NetTcp

    WCF-WSHttp

    Note: Adapters built using [ASDK] are consumed within BizTalk using WCF-Custom BizTalk WCF Adapter. Once the adapter is configured, it shows up in the Binding Type drop-down box and can be selected like any other predefined WCF binding.

    The following section shows, at a very high level, how a BizTalk WCF Adapter is used within a typical BizTalk programming lifecycle.

    ; Design-Time Experience

o Create a Visual Studio BizTalk Project

    o Use Consume WCF Service Wizard (Right Click > Add > Add Generated Items > Consume

    WCF Service) to download metadata from a running service using MEX endpoint or import

    metadata using WSDL.

    ; Following files are generated as an outcome of running this wizard.

    Metadata XML Schema Files

    Orchestration BizTalk Orchestration (.odx) file

    Port Binding {ServiceName}_Custom.BindingInfo.xml Contains port

    Information configuration using WCF Custom Adapter

    Configuration

    {ServiceName}.BindingInfo.xml Contains port

    configuration using other WCF bindings as obtained from

    the MEX endpoint

    These configuration files can be imported in

    ; MEX endpoints only with these transport types are supported

    o http, https, net.pipe, net.tcp

    o Implies users CANNOT use this wizard to import metadata from MEX

    enabled services that use a custom transport channel. WCF users can

    publish and retrieve metadata over a custom binding, which may include

    transports (and schemes) other than the ones defined above.

    ; Port Binding Information Configuration Contains operation to action mapping

    strings

    ;

    

o Build the BizTalk Project

    ; Deployment-Time Experience

o Deploy the BizTalk Project

o Import the Port Binding Information XML file to auto-generate the ports in BizTalk Server

    2006 Administration Console

    ; Right click on Applications within BizTalk Group, select Import > Bindings and then

    navigate to the Visual Studio BizTalk project folder

    ; Select the Port Binding Information XML file

    ; Execution-Time Experience

    o Enlist and start the orchestration

    o Trigger the orchestration depending on your scenario e.g. dropping a file in the file drop

    for receive location to pick it up

    See the attached document for screen shots of Consume WCF Service Wizard.

In this example, let’s host a sample WCF Service in IIS using the WsHttpBinding. I have picked Calculator

    Service in TechnologySamples\Basic\Binding\WS\Http\CS\Http.sln solution installed as part of Microsoft

    Windows SDK for Windows Vista and .NET Framework 3.0.

    Design-Time Experience

    Create a new Solution and add a BizTalk Project to this solution. Right click on the BizTalk project and select Add > Add Generated Items > Consume WCF Service. Click on Consume WCF Service Visual Studio installed template.

    Select MEX endpoint or Metadata Files (WSDL and XSD) as a metadata source for obtaining metadata. I will use the MEX endpoint configured within my service’s web.config. Here is the configuration:

    

Unrelated to the topic in this post, I digress. When using [SVCUTIL]:

; If httpGetEnabled = false,

    o Use svcutil.exe http://localhost/servicemodelsamples/CalculatorService/service.svc/mex ; If httpGetEnabled = true

    o Use svcutil.exe http://localhost/servicemodelsamples/CalculatorService/service.svc?wsdl

    Enter the URI address where the service is hosted.

Click on Get button.

Click on Next button.

Click on Import button.

Select Finish. The Wizard generates the following files for my sample WCF service.

    ; CalculatorService.BindingInfo.xml

    ; CalculatorService.odx

    ; CalculatorService_Custom.BindingInfo.xml

    ; CalculatorService_microsoft_servicemodel_samples.xsd

    ; CalculatorService_schemas_microsoft_com_2003_10_Serialization.xsd

CalculatorService.BindingInfo.xml

    xml version="1.0" encoding="utf-8"?> <BindingInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Assembly="Microsoft.BizTalk.Adapter.Wcf.Consuming, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Version="3.5.1.0"> <Timestamp>2007-04-12T14:23:43.4269883-07:00Timestamp> <SendPortCollection> <SendPort Name="WcfSendPort_CalculatorService_WSHttpBinding_ICalculator" IsStatic="true" IsTwoWay="true" BindingOption="0"> <Description>service "CalculatorService" port "WSHttpBinding_ICalculator"Description> <TransmitPipeline Name="Microsoft.BizTalk.DefaultPipelines.PassThruTransmit" FullyQualifiedName="Microsoft.BizTalk.DefaultPipelines.PassThruTransmit, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Type="2" /> <PrimaryTransport> <Address>http://sonua5/servicemodelsamples/CalculatorService/service.svcAddress> <TransportType Name="WCF-WSHttp" Capabilities="899" ConfigurationClsid="2b219014-ba04-4b70-a66b-a8c418b109fd" /> <TransportTypeData><CustomProps> <MaxReceivedMessageSize vt="3">65536</MaxReceivedMessageSize> <MessageEncoding vt="8">Text</MessageEncoding> <TextEncoding vt="8">utf-8</TextEncoding> <EnableTransaction vt="11">0</EnableTransaction> <SecurityMode vt="8">Message</SecurityMode> <MessageClientCredentialType vt="8">Windows</MessageClientCredentialType> <AlgorithmSuite vt="8">Basic256</AlgorithmSuite> <NegotiateServiceCredential vt="11">-1</NegotiateServiceCredential> <EstablishSecurityContext vt="11">-1</EstablishSecurityContext> <TransportClientCredentialType vt="8">Windows</TransportClientCredentialType> <UseSSO vt="11">0</UseSSO> <ProxyToUse vt="8">Default</ProxyToUse> <StaticAction vt="8">&lt;BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;Operation Name="Add" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add" /&gt; &lt;Operation Name="Subtract" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract" /&gt; &lt;Operation Name="Multiply" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply" /&gt; &lt;Operation Name="Divide" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide" /&gt; &lt;/BtsActionMapping&gt;</StaticAction> <InboundBodyLocation vt="8">UseBodyElement</InboundBodyLocation> <InboundNodeEncoding vt="8">Xml</InboundNodeEncoding> <OutboundBodyLocation vt="8">UseBodyElement</OutboundBodyLocation>

<OutboundXmlTemplate vt="8">&lt;bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="xml"/&gt;</OutboundXmlTemplate> <PropagateFaultMessage vt="11">-1</PropagateFaultMessage> <OpenTimeout vt="8">00:01:00</OpenTimeout> <SendTimeout vt="8">00:01:00</SendTimeout> <CloseTimeout vt="8">00:01:00</CloseTimeout> <Identity vt="8">&lt;identity&gt; &lt;userPrincipalName value="SONUA5\ASPNET" /&gt; &lt;/identity&gt;</Identity> </CustomProps>TransportTypeData> <RetryCount>3RetryCount> <RetryInterval>5RetryInterval> <ServiceWindowEnabled>falseServiceWindowEnabled> <FromTime>2000-01-01T00:00:00FromTime> <ToTime>2000-01-01T23:59:59ToTime> <Primary>truePrimary> <OrderedDelivery>falseOrderedDelivery> <DeliveryNotification>1DeliveryNotification> <SendHandler xsi:nil="true" /> PrimaryTransport> <ReceivePipeline Name="Microsoft.BizTalk.DefaultPipelines.XMLReceive" FullyQualifiedName="Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Type="1" /> <ReceivePipelineData xsi:nil="true" /> <Tracking>0Tracking> <Filter /> <OrderedDelivery>falseOrderedDelivery> <Priority>5Priority> <StopSendingOnFailure>falseStopSendingOnFailure> <RouteFailedMessage>falseRouteFailedMessage> <ApplicationName xsi:nil="true" /> SendPort> SendPortCollection> BindingInfo>

CalculatorService_Custom.BindingInfo.xml

xml version="1.0" encoding="utf-8"?> <BindingInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Assembly="Microsoft.BizTalk.Adapter.Wcf.Consuming, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Version="3.5.1.0"> <Timestamp>2007-04-12T14:23:43.4269883-07:00Timestamp> <SendPortCollection> <SendPort Name="WcfSendPort_CalculatorService_WSHttpBinding_ICalculator_Custom" IsStatic="true" IsTwoWay="true" BindingOption="0"> <Description>service "CalculatorService" port "WSHttpBinding_ICalculator"Description> <TransmitPipeline Name="Microsoft.BizTalk.DefaultPipelines.PassThruTransmit" FullyQualifiedName="Microsoft.BizTalk.DefaultPipelines.PassThruTransmit, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Type="2" /> <PrimaryTransport> <Address>http://sonua5/servicemodelsamples/CalculatorService/service.svcAddress> <TransportType Name="WCF-Custom" Capabilities="907" ConfigurationClsid="af081f69-38ca-4d5b-87df-f0344b12557a" /> <TransportTypeData><CustomProps> <BindingType vt="8">wsHttpBinding</BindingType> <BindingConfiguration vt="8">&lt;binding name="WSHttpBinding_ICalculator" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt;&lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;&lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt;&lt;security mode="Message"&gt;&lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt;&lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /&gt;&lt;/security&gt;&lt;/binding&gt;</BindingConfiguration> <StaticAction vt="8">&lt;BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;Operation Name="Add" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add" /&gt; &lt;Operation Name="Subtract" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract" /&gt; &lt;Operation Name="Multiply" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply" /&gt;

     &lt;Operation Name="Divide" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide" /&gt; &lt;/BtsActionMapping&gt;</StaticAction> <UseSSO vt="11">0</UseSSO> <InboundBodyLocation vt="8">UseBodyElement</InboundBodyLocation> <InboundNodeEncoding vt="8">Xml</InboundNodeEncoding> <OutboundBodyLocation vt="8">UseBodyElement</OutboundBodyLocation> <OutboundXmlTemplate vt="8">&lt;bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="xml"/&gt;</OutboundXmlTemplate> <PropagateFaultMessage vt="11">-1</PropagateFaultMessage> <Identity vt="8">&lt;identity&gt; &lt;userPrincipalName value="SONUA5\ASPNET" /&gt; &lt;/identity&gt;</Identity> </CustomProps>TransportTypeData> <RetryCount>3RetryCount> <RetryInterval>5RetryInterval> <ServiceWindowEnabled>falseServiceWindowEnabled> <FromTime>2000-01-01T00:00:00FromTime> <ToTime>2000-01-01T23:59:59ToTime> <Primary>truePrimary> <OrderedDelivery>falseOrderedDelivery> <DeliveryNotification>1DeliveryNotification> <SendHandler xsi:nil="true" /> PrimaryTransport> <ReceivePipeline Name="Microsoft.BizTalk.DefaultPipelines.XMLReceive" FullyQualifiedName="Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Type="1" /> <ReceivePipelineData xsi:nil="true" /> <Tracking>0Tracking> <Filter /> <OrderedDelivery>falseOrderedDelivery> <Priority>5Priority> <StopSendingOnFailure>falseStopSendingOnFailure> <RouteFailedMessage>falseRouteFailedMessage> <ApplicationName xsi:nil="true" /> SendPort> SendPortCollection> BindingInfo>

    Finish the BizTalk Orchestration and use the schema messages within the orchestration.

    Create a strong key for signing the project.

    Build project.

    Deploy project in BizTalk Server.

    Deployment-Time Experience

Open BizTalk Server 2006 Administration Console

    Select a BizTalk Application. Right click, select Import > Bindings.

Navigate to the binding information files generated by the WCF Consume Service wizard.

Report this document

For any questions or suggestions please email
cust-service@docsford.com