Consume WCF Service Wizard generates port ... - MSDN Blogs

Document Sample
Consume WCF Service Wizard generates port ... - MSDN Blogs Powered By Docstoc
					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
                         <BtsActionMapping> <Operation Name=”Operation1” Action=”Action1”/>
                           </BtsActionMapping

       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:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <system.serviceModel>
   <services>
    <service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
     <!-- this endpoint is exposed at the base address provided by host: http://localhost/servicemodelsamples/service.svc -->
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1" contract="Microsoft.ServiceModel.Samples.ICalculator"
/>
     <!-- the mex endpoint is exposed at http://localhost/servicemodelsamples/CalculatorService/service.svc/mex -->
     <endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange" />
    </service>
   </services>
   <behaviors>
    <serviceBehaviors>
     <behavior name="CalculatorServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
     </behavior>
    </serviceBehaviors>
   </behaviors>
 </system.serviceModel>
</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:00</Timestamp>
  <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.svc</Address>
        <TransportType Name="WCF-WSHttp" Capabilities="899" ConfigurationClsid="2b219014-ba04-
4b70-a66b-a8c418b109fd" />
        <TransportTypeData>&lt;CustomProps&gt;
  &lt;MaxReceivedMessageSize vt="3"&gt;65536&lt;/MaxReceivedMessageSize&gt;
  &lt;MessageEncoding vt="8"&gt;Text&lt;/MessageEncoding&gt;
  &lt;TextEncoding vt="8"&gt;utf-8&lt;/TextEncoding&gt;
  &lt;EnableTransaction vt="11"&gt;0&lt;/EnableTransaction&gt;
  &lt;SecurityMode vt="8"&gt;Message&lt;/SecurityMode&gt;
  &lt;MessageClientCredentialType vt="8"&gt;Windows&lt;/MessageClientCredentialType&gt;
  &lt;AlgorithmSuite vt="8"&gt;Basic256&lt;/AlgorithmSuite&gt;
  &lt;NegotiateServiceCredential vt="11"&gt;-1&lt;/NegotiateServiceCredential&gt;
  &lt;EstablishSecurityContext vt="11"&gt;-1&lt;/EstablishSecurityContext&gt;
  &lt;TransportClientCredentialType vt="8"&gt;Windows&lt;/TransportClientCredentialType&gt;
  &lt;UseSSO vt="11"&gt;0&lt;/UseSSO&gt;
  &lt;ProxyToUse vt="8"&gt;Default&lt;/ProxyToUse&gt;
  &lt;StaticAction vt="8"&gt;&amp;lt;BtsActionMapping
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;
  &amp;lt;Operation Name="Add" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add"
/&amp;gt;
  &amp;lt;Operation Name="Subtract"
Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract" /&amp;gt;
  &amp;lt;Operation Name="Multiply"
Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply" /&amp;gt;
  &amp;lt;Operation Name="Divide"
Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide" /&amp;gt;
&amp;lt;/BtsActionMapping&amp;gt;&lt;/StaticAction&gt;
  &lt;InboundBodyLocation vt="8"&gt;UseBodyElement&lt;/InboundBodyLocation&gt;
  &lt;InboundNodeEncoding vt="8"&gt;Xml&lt;/InboundNodeEncoding&gt;
  &lt;OutboundBodyLocation vt="8"&gt;UseBodyElement&lt;/OutboundBodyLocation&gt;
  &lt;OutboundXmlTemplate vt="8"&gt;&amp;lt;bts-msg-body
xmlns="http://www.microsoft.com/schemas/bts2007"
encoding="xml"/&amp;gt;&lt;/OutboundXmlTemplate&gt;
  &lt;PropagateFaultMessage vt="11"&gt;-1&lt;/PropagateFaultMessage&gt;
  &lt;OpenTimeout vt="8"&gt;00:01:00&lt;/OpenTimeout&gt;
  &lt;SendTimeout vt="8"&gt;00:01:00&lt;/SendTimeout&gt;
  &lt;CloseTimeout vt="8"&gt;00:01:00&lt;/CloseTimeout&gt;
  &lt;Identity vt="8"&gt;&amp;lt;identity&amp;gt;
  &amp;lt;userPrincipalName value="SONUA5\ASPNET" /&amp;gt;
&amp;lt;/identity&amp;gt;&lt;/Identity&gt;
&lt;/CustomProps&gt;</TransportTypeData>
        <RetryCount>3</RetryCount>
        <RetryInterval>5</RetryInterval>
        <ServiceWindowEnabled>false</ServiceWindowEnabled>
        <FromTime>2000-01-01T00:00:00</FromTime>
        <ToTime>2000-01-01T23:59:59</ToTime>
        <Primary>true</Primary>
        <OrderedDelivery>false</OrderedDelivery>
        <DeliveryNotification>1</DeliveryNotification>
        <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>0</Tracking>
      <Filter />
      <OrderedDelivery>false</OrderedDelivery>
      <Priority>5</Priority>
      <StopSendingOnFailure>false</StopSendingOnFailure>
      <RouteFailedMessage>false</RouteFailedMessage>
      <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:00</Timestamp>
  <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.svc</Address>
        <TransportType Name="WCF-Custom" Capabilities="907" ConfigurationClsid="af081f69-38ca-
4d5b-87df-f0344b12557a" />
        <TransportTypeData>&lt;CustomProps&gt;
  &lt;BindingType vt="8"&gt;wsHttpBinding&lt;/BindingType&gt;
  &lt;BindingConfiguration vt="8"&gt;&amp;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"&amp;gt;&amp;lt;readerQuotas
maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" /&amp;gt;&amp;lt;reliableSession ordered="true"
inactivityTimeout="00:10:00" enabled="false" /&amp;gt;&amp;lt;security
mode="Message"&amp;gt;&amp;lt;transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" /&amp;gt;&amp;lt;message clientCredentialType="Windows"
negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"
/&amp;gt;&amp;lt;/security&amp;gt;&amp;lt;/binding&amp;gt;&lt;/BindingConfiguration&gt;
  &lt;StaticAction vt="8"&gt;&amp;lt;BtsActionMapping
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;
  &amp;lt;Operation Name="Add" Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add"
/&amp;gt;
  &amp;lt;Operation Name="Subtract"
Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract" /&amp;gt;
  &amp;lt;Operation Name="Multiply"
Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply" /&amp;gt;
  &amp;lt;Operation Name="Divide"
Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide" /&amp;gt;
&amp;lt;/BtsActionMapping&amp;gt;&lt;/StaticAction&gt;
  &lt;UseSSO vt="11"&gt;0&lt;/UseSSO&gt;
  &lt;InboundBodyLocation vt="8"&gt;UseBodyElement&lt;/InboundBodyLocation&gt;
  &lt;InboundNodeEncoding vt="8"&gt;Xml&lt;/InboundNodeEncoding&gt;
  &lt;OutboundBodyLocation vt="8"&gt;UseBodyElement&lt;/OutboundBodyLocation&gt;
  &lt;OutboundXmlTemplate vt="8"&gt;&amp;lt;bts-msg-body
xmlns="http://www.microsoft.com/schemas/bts2007"
encoding="xml"/&amp;gt;&lt;/OutboundXmlTemplate&gt;
  &lt;PropagateFaultMessage vt="11"&gt;-1&lt;/PropagateFaultMessage&gt;
  &lt;Identity vt="8"&gt;&amp;lt;identity&amp;gt;
  &amp;lt;userPrincipalName value="SONUA5\ASPNET" /&amp;gt;
&amp;lt;/identity&amp;gt;&lt;/Identity&gt;
&lt;/CustomProps&gt;</TransportTypeData>
        <RetryCount>3</RetryCount>
        <RetryInterval>5</RetryInterval>
        <ServiceWindowEnabled>false</ServiceWindowEnabled>
        <FromTime>2000-01-01T00:00:00</FromTime>
        <ToTime>2000-01-01T23:59:59</ToTime>
        <Primary>true</Primary>
        <OrderedDelivery>false</OrderedDelivery>
        <DeliveryNotification>1</DeliveryNotification>
        <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>0</Tracking>
      <Filter />
      <OrderedDelivery>false</OrderedDelivery>
      <Priority>5</Priority>
      <StopSendingOnFailure>false</StopSendingOnFailure>
      <RouteFailedMessage>false</RouteFailedMessage>
      <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.
Select the first binding file and click on Open. Repeat the process for the other binding file as well. The
following two ports should be created in the BizTalk Administration Console. One port type will use the
transport type WCF-WSHttp and the other port type will use the transport type WCF-Custom.




The following table shows the difference between the two WCF adapters.

           WCF-WSHttp Transport Type                   WCF-Custom Transport Type with WsHttpBinding

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:11/12/2012
language:Unknown
pages:14
About Good!!!NICE!!! The best document database!