How to build Biz Talk Custom Adapters Luigi
How to build Biz. Talk Custom Adapters Luigi Pampaloni Biz. Talk Solutions Architect LPYSoft Ltd
Content of the presentation • First part – Biz. Talk Interfaces to be implemented • Second part – Simple. HTTPAdapter documentation 2
Biz. Talk adapters Aspect Options Receive Transmit Adapter "code" hosted In-process – the adapter is created within Biz. Talk host process. All transmitting adapters are in-process Isolated – the receive adapter is created in an isolated host (external process i. e. w 3 wp. exe) which is not part of the Biz. Talk runtime. A classic example is an http receive adapter. The actual message is received while being in the IIS worker process boundary Port Binding Static – the target location for send/receive is preconfigured Dynamic – the target location can be determined in runtime Adapter Capabilities Asynchronous adapter – the adapter is able to send messages without holding the Biz. Talk send thread. Messages are sent on the adapter thread (relevant for transmitting adapters) Transactional adapter – support for transactional send/receive of messages Batch support – the adapter supports receiving and transmitting batch of messages Property browser – defines a list of properties and uses the std property dialog Metadata wizard – used to generate or import items (i. e. schemas) from an app Communication Direction Design-time One-way Submit Request – Response time-outs One-way Send Solicit – Response Static – The wizard provides a standard default hierarchical tree structure Dynamic – The adapter provides a custom UI 3
Adapter components • Design-time component • Run-time component – Receive adapter – Send adapter • Adapter registration 4
Design-time components • • Property browser. Adapter properties for a send or receive port, or a send or receive handler, are configured through their Properties menu by using the Biz. Talk Server Administration console. During configuration of these artifacts the adapter (transport) is selected and its properties are configured by using a property browser. Applicable properties are displayed through a schema with a set name. The adapter implements the IAdapter. Config interface to locate and load the appropriate schema to expose specific properties in the property browser. The IAdapter. Config. Validation interface is used to validate those entries and make any final modifications to the values before saving the configuration data. Add Adapter Metadata Wizard. In the case of application and database adapters, you may need to import supporting schemas that describe message types and port types that the adapter needs in the Biz. Talk project in Visual Studio. Or sometimes there is the need to consume services provided by the adapter. The Add Adapter Metadata Wizard enables you to view services that an adapter supports and import the related message types and port types into your project. This process is known as "metadata harvesting. " As an adapter developer you create an XML file describing those services and expose it to the wizard at design time through either the IStatic. Adapter. Config or IDynamic. Adapter. Config interface, with the following results: – – Static adapter. The wizard provides a standard default hierarchical tree structure with which to display the adapter's services. A static adapter is defined as an adapter that uses the standard tree user interface (UI) provided by the wizard. Use the IStatic. Adapter. Config. Get. Service. Organization and Get. Service. Description methods to allow selected services to be added to the Biz. Talk project. This is the simplest configuration option for an adapter developer, but the tradeoff is rigidity of the display format Dynamic adapter. If the basic service selection UI provided by the wizard is not flexible enough meet your UI needs you can create a custom UI that is dynamically displayed by the wizard. Use the IDynamic. Adapter. Config. Display. UI method to display the custom UI to allow selection of services to be added to a Biz. Talk project 5
IAdapter. Config • • • IAdapter. Config defines two methods, Get. Config. Schema and Get. Schema. Based on the value of the Config. Type parameter, Get. Config. Schema must return the appropriate XSD which defines the configuration properties. The schema will be validated against the Biz. Talk. Adapter. Framework. xsd Under Microsoft. Biz. Talk. Adapter. Framework namespace Two methods must be implemented: – string Get. Config. Schema (Config. Type config. Type) Get a schema representing the configuration properties of the adapter. Potentially, a receive handler, a send handler, a receive location, and a send port could all have different schemas that define different properties, in which case four different schemas would be needed • Parameters – config. Type » The target usage of the configuration specification (One of Receive. Handler, Receive. Location, Transmit. Handler, Transmit. Location) • Return Value – – A string containing the schema that represents the configuration properties (XSD) or null if the config. Type type is not supported Result Get. Schema (string uri, string namespace. Name, out string file. Location) Get the location of schema files that need to be imported into the Biz. Talk project • Parameters – – – uri » A string containing the URI uniquely identifying the schema. namespace. Name » A string containing the namespace of the schema. file. Location » A string containing the XSD schema content. • Return Value – One of the Result values: Back, Cancel, Continue, Exit, Fail 6
IAdapter. Config sequence diagram • • • Get. Config. Schema must return the appropriate XSD which defines the configuration properties. The schema will be validated against the Biz. Talk. Adapter. Framework. xsd Get. Schema is called if there any import nodes in the WSDL files returned by the adapter during setup using the Adapter Wizard as a way to be able to import necessary schemas into the Biz. Talk project but don't get confused by the name of the return parameter as defined by the interface (file. Location), the return should be the actual string representation of the schema and will be validated against the Biz. Talk. Adapter. Framework schema Note: The Get. Schema is called just when a WSDL is returned by the Get. Config. Schema with an import of an external schema (probably is not called when implement just the IAdapter. Config interface) 7
IAdapter. Config configuration public interface IAdapter. Config { string Get. Config. Schema( Config. Type cfg. Type); } Adapter Design-time Get. Config. Schema public enum Config. Type { Receive. Location = 0, Transmit. Location = 1, Receive. Handler = 2, Transmit. Handler = 3 } public enum Result { Continue = 0, Cancel = 1, Back = 2, Fail = 3, Exit = 4 } XSD 8
IAdapter. Config sample implementation public string Get. Config. Schema(Config. Type type) { switch (type) { case Config. Type. Receive. Handler: return Get. Resource("Receive. Handler. xsd"); case Config. Type. Receive. Location: return Get. Resource("Receive. Location. xsd"); case Config. Type. Transmit. Handler: return Get. Resource("Transmit. Handler. xsd"); case Config. Type. Transmit. Location: return Get. Resource("Transmit. Location. xsd"); } } default: return null; public Result Get. Schema(string xsd. Location, string xsd. Namespace, out string xsd. Schema) { xsd. Schema = null; return Result. Continue; } 9
IAdapter. Config sample schema • Below a schema which defines a Property. Name as a property of type string <? xml version="1. 0" encoding="utf-16"? > <xs: schema xmlns: baf="Biztalk. Adapter. Framework. xsd" xmlns: b="http: //schemas. microsoft. com/Biz. Talk/2003" xmlns="http: //tempuri. org/XMLSchema. xsd" element. Form. Default="qualified" target. Namespace="http: //tempuri. org/XMLSchema. xsd" xmlns: xs="http: //www. w 3. org/2001/XMLSchema"> <xs: import namespace="Biztalk. Adapter. Framework. xsd" /> <xs: element name="Config"> <xs: complex. Type> <xs: sequence> <xs: element name=“Property. Name" type="xs: string"> <xs: annotation> <xs: appinfo> <baf: designer xmlns: baf="Biztalk. Adapter. Framework. xsd"> <baf: displayname _loc. ID="Property. Name">Edit this field in the resource file</baf: displayname> <baf: description _loc. ID="Property. Name. Desc">Edit this field in the resource file</baf: description> <baf: category _loc. ID="transmit. Location. Category">Adapter Properties</baf: category> </baf: designer> </xs: appinfo> </xs: annotation> </xs: element> </xs: sequence> </xs: complex. Type> </xs: element> </xs: schema> 10
IAdapter. Config. Validation • IAdapter. Config. Validation defines a single method, Validate. Configuration. This method will be called when saving the configuration for any one of the four configuration types • Under Microsoft. Biz. Talk. Adapter. Framework namespace • A method must be implemented: – string Validate. Configuration ( Config. Type config. Type, string configuration ) Validates the adapter configuration information • Parameters – config. Type » One of the Config. Type values. (One of Receive. Handler, Receive. Location, Transmit. Handler, Transmit. Location) – configuration » A string containing the xml instance that the adapter can load into an Xml. Document instance. • Return Value – A string containing the xml instance configuration information, corrected if necessary – Throw an exception to notify wrong parameters specified on the property page 11
IAdapter. Config. Validation sample impl. public string Validate. Configuration(Config. Type config. Type, string xml. Instance) { string valid. Xml = String. Empty; switch (config. Type) { case Config. Type. Receive. Handler: valid. Xml = Validate. Receive. Handler(xml. Instance); break; case Config. Type. Receive. Location: valid. Xml = Validate. Receive. Location(xml. Instance); break; case Config. Type. Transmit. Handler: valid. Xml = Validate. Transmit. Handler(xml. Instance); break; } case Config. Type. Transmit. Location: valid. Xml = Validate. Transmit. Location(xml. Instance); break; return valid. Xml; } private string Validate. Transmit. Location(string xml. Instance) { if(something wrong with the instance) throw new Application. Exception(“Something wrong”); // Prompted by the property page on the OK button click } 12
NOTE: Address (URI) is mandatory • The Address (URI) property is mandatory and read only on BTS – To set the Address (URI) property add a property called URI (browseable=false) <xs: element name="uri" type="xs: string"> <xs: annotation> <xs: appinfo> <baf: designer xmlns: baf="Biztalk. Adapter. Framework. xsd"> <baf: browsable show="false" /> </baf: designer> </xs: appinfo> </xs: annotation> </xs: element> – Implement the IAdapter. Config. Validation to return a valid calculated address URI • transport. Type + “: //” + some. Other. Property 13
IAdapter. Info • IAdapter. Info defines a single method, Get. Help. String which should return a link to the help file associated with the configuration. This method will be called when the help button is clicked while viewing the custom adapter configuration property sheet for any one of the four configuration types 14
IStatic. Adapter. Config • • • The UI for the IStatic. Adapter. Config interface will be generated based on the xml returned by a call to the Get. Service. Description method (the return will be validated against the Biz. Talk. Adapter. Framework schema and will be used to generate a tree-view of the "services" the adapter provides Under Microsoft. Biz. Talk. Adapter. Framework namespace Two methods must be implemented – string Get. Service. Organization ( IProperty. Bag endpoint. Configuration , string node. Identifier ) Get an XML representing the way the adapter organizes its services. This tree is used to generate the service organization tree that is displayed to the user in the Add Adapter Wizard • Parameters – – endpoint. Configuration node. Identifier » The name of the node. The Adapter Framework passes null to request the root of the service organization hierarchy and the name of a node to request the hierarchy under an expandable tree node. • Return Value – – A string containing XML that represents the way the adapter organizes its services string[] Get. Service. Description ( string[] wsdl. References ) Gets an array of Web Service Description Languages (WSDL), based on the unique WSDL references specified in the returned XML of the Get. Service. Organization method • Parameters – wsdl. References » An array of string with the WSDL references (as obtained from the Service Organization XML). Each input string is derived from the XML provided from the Get. Service. Organization call. • Return Value – An array of string of WSDLs. Each output string should contain the WSDL content corresponding to the WSDL reference in the input parameter 15
IStatic. Adapter. Config sequence diagram • • • The Get. Service. Organization is called to get the hierarchical structure of the services The service description (as WSDL format) is requested for each service selected on the UI For each import defined on the WSDL the Get. Schema is called to retrieve the external schema 16
IStatic. Adapter. Config configuration public interface IStatic. Adapter. Config : IAdapter. Config { string Get. Service. Organization(); string [] Get. Service. Description(string [] wsdls); Result Get. Schema(string uri, string namespace. Name, ref string file. Location); } public enum Result Adapter Design-time Get. Service. Organization Get. Service. Description Get. Schema XML { Continue = 0, Cancel = 1, Back = 2, Fail = 3, Exit = 4 } WSDLs XSDs 17
IStatic. Adapter. Config sample implementation public string Get. Service. Organization(IProperty. Bag end. Point. Configuration, string Node. Identifier) { // Simplementation, assuming the Tree. View xml instance is on the filesystem string result = ""; Open. File. Dialog file. Dialog = new Open. File. Dialog(); file. Dialog. Filter = "Service description files (*. xml)|*. xml|All files (*. *)|*. *"; if (file. Dialog. Show. Dialog() == Dialog. Result. OK) { using (Text. Reader tr = new Stream. Reader(file. Dialog. File. Name)) { result = tr. Read. To. End(); tr. Close(); } } return result; } public string[] Get. Service. Description(string[] wsdls) { // Simplementation, assuming the wsdl is on the filesystem string[] result = new string[1]; result[0] = ""; Open. File. Dialog file. Dialog = new Open. File. Dialog(); file. Dialog. Filter = "Service description files (*. wsdl)|*. wsdl|All files (*. *)|*. *"; if (file. Dialog. Show. Dialog() == Dialog. Result. OK) { using (Text. Reader tr = new Stream. Reader(file. Dialog. File. Name)) { result[0] = tr. Read. To. End(); tr. Close(); } } return result; } 18
IStatic. Adapter. Config sample XML & UI • Service Organization sample XML <? xml version="1. 0" encoding="utf-8" ? > <Category. Tree> <Display. Name>Services Organization</Display. Name> <Display. Description>An organization of application services</Display. Description> <Category. Tree. Node> <Display. Name>Health Care</Display. Name> <Description>Services under Health Care</Description> <Category. Tree. Node> <Display. Name>Administrative</Display. Name> <Description>Administrative Health Care Svc</Description> <Service. Tree. Node> <Display. Name>Eligibility</Display. Name> <Description>Eligibility Verification Tx</Description> <WSDLReference>ANSI X 12 270</WSDLReference> </Service. Tree. Node> </Category. Tree. Node> <Category. Tree. Node> <Display. Name>Manufacturing</Display. Name> <Description>Manufacturing Services</Description> <Category. Tree. Node> <Display. Name>Inventory</Display. Name> <Description>Inventory Services</Description> <Service. Tree. Node> <Display. Name>Requisition</Display. Name> <Description>Requisition</Description> <WSDLReference>Requisition. Service</WSDLReference> </Service. Tree. Node> </Category. Tree> 19
IDynamic. Adapter. Config • The UI for the IDynamic. Adapter. Config interface is defined by the developer and should be loaded in the Display. UI method which will be called by the wizard – Result Display. UI ( IProperty. Bag endpoint. Configuration, IWin 32 Window owner, out string[] service. Description. Files ) Displays the user interface for the custom adapter, enabling the user to import the services descriptions that are returned to Biz. Talk and then added to the Biz. Talk project • Parameters – endpoint. Configuration – owner » An IWin 32 Window containing the handle to the parent window. – service. Description. Files » An array of string with the Web Service Description Languages (WSDL) references (as obtained from the Service Organization XML). Each string should be a valid WSDL file (with root element <definitions>). The Adapter Framework reads the strings into instances of the Service. Description class. • Return Value – An array of string of WSDLs 20
IDynamic. Adapter. Config sequence diagram • • The Display. UI open a custom form. An array of WSDLs is returned by the UI For each import defined on the WSDL the Get. Schema is called to retrieve the external schema 21
IDynamic. Adapter. Config configuration public interface IDynamic. Adapter. Config : IAdapter. Config { Result Display. UI( ref string [] WSDLFile. List); Result Get. Schema(string uri, string namespace. Name, ref string file. Location); } public enum Result { Continue = 0, Cancel = 1, Back = 2, Fail = 3, Exit = 4 } Adapter Design-time Get. Display. UI Get. Schema Display Custom UI WSDLs XSDs 22
IDynamic. Adapter. Config sample implementation • Display. UI sample 23
Run-time components • • Messages Message Engine Receive adapter Transmit adapter 24
Messages • A message (IBase. Message) has one or more message parts represented by the IBase. Message. Part interface. Each message part has a reference to its data through an IStream interface pointer. The context of a message is represented by its IBase. Message. Context interface. The following figure illustrates the Biz. Talk message object model 25
Message Engine • The messaging engine has three public interfaces used by adapters: – IBTTransport. Proxy Adapters always talk to the messaging engine via their own Transport Proxy. The Transport Proxy is used to create batches, get the message factory, and register isolated receivers with the engine – IBTTransport. Batch The interface exposed by the messaging engine's batch. Work done against the engine is performed using a batch; batches are processed asynchronously. – IBTDTCCommit. Confirm Adapters using DTC transactions on batches must notify the engine of the outcome of the transaction using this interface 26
Message Engine – receive message flow 1. The Adapter creates a new message, connecting the data stream to the message. 2. The Adapter requests a new batch from the messaging engine via its Transport Proxy. 3. The Adapter adds a message to the batch to be submitted. 4. The batch is committed, which causes it to be posted to the messaging engine's thread pool. 5. The messaging engine's thread pool starts processing the new batch. 6. The message is processed by the receive pipeline. 7. Zero or more messages will be produced by the receive pipeline. Pipelines can consume messages providing they do not return any errors; receive pipelines can produce more than one message, typically when the dissassembler component disassembles a single interchange into many messages. Usually, the receive pipeline will normalize the message submitted into XML. 8. The message(s) produced by the pipeline may be processed in the mapper if mapping is configured. 9. The message(s) will be published to the Message agent and Message. Box. 10. The Messaging Engine will call back the adapter to notify it of the outcome of that batch of work. 27
Adapter load and initialisation • When the Biz. Talk service starts, all receive adapters are instantiated, as long as they have one or more configured and active receive locations • By default a send adapter is not instantiated until the Messaging Engine removes from the queue the first message to be sent by using that send adapter • The following figure shows the logic for creating adapters: 28
Receive adapter interfaces • Below a list of mandatory/optional interfaces to be implemented by the receive adapter 29
Receive adapter initialisation • Immediately after a receive adapter is instantiated it is initialized by the Messaging Engine, the engine calls Query. Interaface for IBTTransport. Control. It then calls IBTTransport. Control. Initialize passing in the adapter's transport proxy, which the adapter persists in a member variable. Next the engine calls Query. Interface for IPersist. Property. Bag. This is an optional interface; if the adapter implements it, the handler configuration is passed to the adapter in the Load method call. The final stage of initializing a receive adapter involves passing the endpoint configuration to the adapter. During this phase the engine calls IBTTransport. Config. Add. Receive. Endpoint once for each active endpoint, passing in the URI for the endpoint, the adapter specific configuration for the endpoint, and the Biz. Talk configuration for that endpoint 30
In-process receive adapter initialisation • The Messaging Engine creates an instance of an adapter, initializes it, and sets the configuration of receive locations. The Messaging Engine passes a property bag to an adapter on the Add. Receive. Endpoint method call. The property bag contains the configuration for the receive location and receive handler. The configuration is stored in the database in the form of an XMLstyled property bag. The Messaging Engine reads the XML and rehydrates a property bag from the XML. After at least one endpoint (receive location) is added, the adapter can start submitting messages 31
Isolated receive adapter initialisation • After the adapter has successfully registered with the transport proxy, the Messaging Engine passes the configuration information and the other receive locations back to the adapter by calling the Load method of the IPersist. Property. Bag interface and the Add. Receive. Endpoint method of the IBTTransport. Config interface respectively 32
Receive adapter operations • Receive adapters can perform the following operations: – One-way submit: void Submit. Message(IBase. Message msg). After receiving a message from a receive port, the adapter submits it to Biz. Talk Server to be processed by a subscribing orchestration or send port – Suspend: void Move. To. Suspend. Q(IBase. Message msg). When the adapter determines a parsing, transmission, serialization, or other applicable failure has occurred after submission, it moves the message to the Suspended queue – Submit request: void Submit. Request. Message(IBase. Message request. Msg, string correlation. Token, bool first. Response. Only, Date. Time expiration. Time, IBTTransmitter response. Callback). A receive adapter submits an incoming message to Biz. Talk Server in a request-response pair. After Biz. Talk Server successfully processes this request message, it sends the response to the adapter to transmit it to the specific endpoint 33
One-way batch receive • • • A receive adapter obtains the batch from the transport proxy by calling the Get. Batch method of the IBTTransport. Proxy interface. In its call to Get. Batch the adapter passes in a pointer to its IBTBatch. Callback interface implementation. An adapter adds the messages one at a time into the batch by calling the Submit. Message method of the IBTTransport. Batch interface. If this is a two-way operation such as solicit-response messaging, the Submit. Response. Message method of this same interface is called to submit the response message. When all the messages have been added to the batch, the adapter calls the Done method of the IBTTransport. Batch interface to submit the batch to the transport proxy. Because receive adapters are asynchronous in nature, the adapter can immediately obtain a new batch and start submitting other messages after it calls Done. After the batch has been processed, the Messaging Engine invokes the adapter's Batch. Complete callback method using the transport proxy to make the actual call. An array of BTBatch. Operation. Status objects containing the status of the submission is passed to the adapter. Each object corresponds to an operation type and contains the overall status of the operation as well as the status for each message for which the operation was performed. The following sequence describes the actions the adapter needs to perform to analyze the status of batch processing: Check the overall batch status HRESULT value passed as a parameter to the Batch. Complete method. If it is a failure, it means that at least one of the operations in the batch was unsuccessful. Therefore the submission of the entire batch as one entity failed. The adapter should then try to discover the offending message(s) and resubmit as a batch only the ones that did not initially cause a failure. If the overall batch status succeeded, it means that all the messages that were given to the transport proxy were persisted to disk. However, it does not mean that the pipeline successfully processed all the messages. It is possible that messages that failed in the pipeline were suspended. For messages that fail in the pipeline, the overall batch status returned is successful because the data was written to disk. Check the status for each operation type in the operation. Status parameter. If the status is S_OK, the submission for this operation succeeded and you do not need to check the status any further. If the status is set to BTS_S_EPM_MESSAGE_SUSPENDED some of the messages were suspended. BTS_S_EPM_SECURITY_CHECK_FAILED signifies that some messages failed authentication in an authentication-required receive port. If E_FAIL is returned, or any HRESULT with a value that is less than zero, the message submission for this operation failed. Check the status of individual messages for the operation type. For the submit operation type, the status of each message is set to S_OK if the submission succeeded. BTS_S_EPM_MESSAGE_SUSPENDED is returned if the message was suspended. BTS_S_EPM_SECURITY_CHECK_FAILED is returned if the message failed authentication on a receive port that requires authentication. E_BTS_NO_SUBSCRIPTION comes back if there were no subscribers for the published message. If E_FAIL is returned, or any HRESULT with a value that is less than zero, the message submission failed. Depending on your adapter, you may want to suspend messages that return E_FAIL or any failing HRESULT. The Batch. Complete method needs to return either S_OK or E_FAIL to indicate the result of execution. If the Batch. Complete method returns E_FAIL or any negative HRESULT, the transport proxy logs an error. 34
One-way transactional batch receive • A transactional receive adapter creates and passes a pointer to a Microsoft Distributed Transaction Coordinator (MSDTC) transaction on the Done method of the IBTTransport. Batch interface. This ensures that all batch operations are performed in the scope of that specific transaction object. When the batch submission completes, the adapter callback method commits or rolls back the transaction. Which action it takes depends upon the status returned from the transport proxy, and possibly upon other transaction-related work that the adapter does that is not visible to the transport proxy. The adapter determines whether the transaction failed or succeeded. The adapter reports the result of the transaction (commit or rollback) back to the transport proxy by using the DTCCommit. Confirm method of the IBTDTCCommit. Confirm interface. It passes in true for a successful transaction or false for a failure 35
Request-response receive adapter • • • The receive adapter receives incoming request messages. It obtains a batch from the transport proxy by calling the Get. Batch method of the IBTTransport. Proxy interface. In this call the adapter passes in a callback pointer to its implementation of the IBTBatch. Call. Back. Batch. Complete method. The adapter adds request messages into the batch by calling the Submit. Request. Message method of the IBTTransport. Batch interface, once for each request message. When all the messages have been added, the adapter calls the Done method of the IBTTransport. Batch interface, which submits the batch to the Messaging Engine through the transport proxy. After the batch has been processed, the Messaging Engine invokes the adapter's IBTBatch. Call. Back. Batch. Complete callback method through the transport proxy. The status of the submission is passed to the adapter as an array of HRESULT values corresponding to each message in the batch. If the batch fails, either in the pipeline or in the orchestration, the SOAP fault message is returned to the adapter as a response. The incoming request messages may have orchestration subscribers. After the orchestration completes and the request message has been processed, the Messaging Engine sends the response message through the transport proxy to the adapter by calling the adapter's Transmit. Message method from the IBTTransmitter interface. The adapter sends a response message and deletes the original message from the Message. Box database. 36
IBase. Component • Three read only properties to be provided by the adapter – String Name – Adapter name – String Description – Adapter description – String Version – Adapter version 37
IBTTransport • Three read only properties to be provided by the adapter – String Transport. Type – Guid Class. ID 38
IBTBatch. Call. Back • Batch. Complete – Called by BTS once the message is received by the EPM 39
IBTTransport. Config • Add. Receive. End. Point – Called by BTS for each port bound to the adapter and started when the BTS service instance starts – Or – When a port bound to the adapter is started • Remove. Receive. End. Point – Called when a port is shut down • Update. End. Point. Config – Called when the properties of the port are changed 40
IBTTransport. Control • Initialize – Called by BTS when the BTS service starts • Terminate – Called by BTS when the BTS service is stopped 41
Transmit adapter interfaces • Below the list of the mandatory/optional interfaces: 42
Transmit adapter initialisation • • When the Messaging Engine initializes a send adapter, it first performs a Query. Interface for IPersist. Property. Bag, which is an optional interface. If the adapter implements the interface, the handler configuration is passed to the adapter in the Load method call. The adapter uses this information to ensure it is configured correctly. The Messaging Engine performs a Query. Interface for IBTTransport. Control, which is a mandatory interface. The engine calls IBTTransport. Control. Initialize, passing in the transport proxy for the adapter. The Messaging Engine performs a Query. Interface for IBTTransmitter. If the Messaging Engine discovers this interface, the adapter is treated as a batch-unaware transmitter. If the Messaging Engine does not discover this interface, the Messaging Engine performs a Query. Interface for IBTBatch. Transmitter, discovery of which indicates that the adapter is a batch-aware transmitter. If the Messaging Engine discovers neither of these interfaces, an error condition results, causing the initialization to fail. The initialization fails if any mandatory interfaces are not discovered. 43
Transmit adapter operations • • • Resubmit: void Resubmit(IBase. Message msg, Date. Time time. Stamp). After a transmission failure occurs on a message, an adapter resubmits it when appropriate. This is called on a per-message basis. If a batch of messages was submitted unsuccessfully, the adapter must determine the messages causing the failure, and resubmit the ones that did not cause the batch to fail in separate calls to Resubmit. There is information at the end of this topic about how to preserve message context property values when you call Resubmit. Move to Next Transport: void Move. To. Next. Transport(IBase. Message msg). If a message fails during a send operation and its retry attempts have been exhausted, the adapter can send the message to the next configured transport for retransmission. Suspend: void Move. To. Suspend. Q(IBase. Message msg). The adapter moves a failed send message to the Suspended queue if no additional backup transport is configured. There is information at the end of this topic about how to preserve message context property values when you call Suspend. Delete: void Delete. Message(IBase. Message msg). The adapter deletes a message after being notified by Biz. Talk Server of its successful transmission. Deleting a message tells Biz. Talk Server that the adapter is finished with the message. Generally the Submit. Response operation is done in the same batch as its associated Delete operation. Submit Response: void Submit. Response. Message(IBase. Message solicit. Msg. Sent, IBase. Message response. Msg. To. Submit). The adapter submits a response to the batch to be sent back to Biz. Talk Server. This operation includes the original message in the call along with the response so that Biz. Talk Server can correlate them. Cancel Response: void Cancel. Response. Messages(string correlation. Token). If the sending of a response message needs to be canceled before the batch is submitted, the Cancel. Response. Messages method is used, passing in the correlation token for the associated response message to be deleted. 44
Transmit adapter synchronous send • In a synchronous send, the adapter sends the message while blocking Transmit. Message, and after successful transmission returns True 45
Transmit adapter asynchronous send • • The Messaging Engine uses the transport proxy to pass an outgoing message to a send adapter by calling the Transmit. Message method of the IBTTransmitter interface. The adapter returns immediately from Transmit. Message after storing the message to be sent to some internal queue, and returns False for b. Delete. Message. This tells the Messaging Engine the message will be transmitted in an asynchronous manner. The adapter sends the message using its own thread pool. After the send operation completes, the adapter deletes the original message from the Message. Box database. It obtains a batch from the Messaging Engine using the IBTTransport. Batch. Get. Batch method of the transport proxy, and then calls Delete. Message. 46
Transmit adapter synchronous batch send • • Batch-aware adapters may send messages synchronously or asynchronously, and may perform transacted send operations. To send batches of messages, a send adapter must implement the following interfaces: For the synchronous batch send, the Messaging Engine gets a batch from the adapter and adds messages to be transmitted to that batch. The Messaging Engine adds each message to the batch and sends the messages only when it calls the Done method on the batch. The adapter returns True for b. Delete. Message for each message that it intends to transmit synchronously. The adapter should save message data, as opposed to a message pointer, in its Transmit. Message implementation. This is because the message pointer is no longer valid after True is returned, and should not be used or cached for later use 47
Transmit adapter asynchronous batch send • For the asynchronous batch send, the Messaging Engine gets a batch from the adapter and adds messages to be transmitted to that batch. The messages are only sent when the Messaging Engine calls the Done method on the batch. The adapter returns False for each message that it intends to transmit asynchronously. The adapter then gets a batch from the adapter proxy and deletes those messages that it successfully transmitted 48
Transmit adapter tx asynchronous batch send • An adapter creates an MSDTC transaction and returns a pointer to that object in the call to the Begin. Batch method of the IBTTransmitter. Batch interface. The Messaging Engine calls this method to obtain a batch with which it posts outgoing messages to the send adapter. When the adapter finishes the send operation and commits or rolls back a transaction, it notifies the Messaging Engine of the result of the transaction by using the DTCCommit. Confirm method of the IBTDTCCommit. Confirm interface 49
Transmit adapter solicit response • • After the adapter sends a solicit message, it receives back a response message from that destination server. It then obtains a batch from the transport proxy. The adapter adds the response message to the batch by calling IBTTransport. Proxy: : Submit. Response. Message. The adapter submits the batch by calling IBTTransport. Proxy: : Done passing in a pointer to its IBTBatch. Complete interface for the callback from the Messaging Engine. The Messaging Engine calls the adapter's IBTBatch. Call. Back: : Batch. Complete callback method using the transport proxy notifying it of the result of submission operation. 50
IBTTransmitter • Initialize • Terminate • Transmit. Message – Called by Biz. Talk when a message needs to be sent – It returns a Boolean • If the return value is True Biz. Talk remove the message from the Message. Box • If the return value is False you have to write the code to remove the message from the Message. Box – If the send function is called asynchronously it is better to return False then process the message in a separate thread and then remove the message from the Message. Box – If the port is a dynamic port the message context property Adapter. Config (containing the port properties) is not present. You need to access the Outbound. Transport. Location property with the following namespace http: //schemas. microsoft. com/Biz. Talk/2003/system-properties in order to retrieve the dynamic properties of the port 51
Adapter registration • The information about adapters must be registered in the registry and the Biz. Talk Management database • Information such as an adapter's alias, receive hander, receive location, and transport type is called metadata – These metadata entries can be created manually during the development phase in the form of a registry file – Alternatively, you can run the Adapter Registration Wizard (Adapter. Registry. Wizard. exe) SDK utility to generate a registry file for your custom adapter 52
Report errors to Biz. Talk • If you are suspending a message, you must provide failure information to Biz. Talk Server from the previous message context. Biz. Talk Server provides error reporting capabilities using the Set. Error. Info method on both the IBase. Message and ITransport. Proxy interfaces. You can report errors as follows: – When a failure occurs while processing a message, set the exception using Set. Error. Info(Exception e) on the message (IBase. Message) to be suspended. This allows the engine to preserve the error with the message for later diagnosis and logs it to the event log to alert the administrator. – If you encounter an error during initialization or internal bookkeeping (not during message processing) you should call Set. Error. Info(Exception e) on the ITransport. Proxy pointer that was passed to you during initialization. If your adapter is based on the Base. Adapter implementation, you should always have access to this pointer. Otherwise, you should be certain that you cache it. 53
Adapters registry entries • Registry entries – Location [HKEY_CLASSES_ROOTCLSID{%uuid of custom transport%}Biz. Talk] @="Biz. Talk" – Adapter type name "Transport. Type"="My. Transport. Adapter" – Adapter constraints define the adapter's capabilities "Constraints"=dword: 00003 C 0 b 54
Adapters registry entries – Each adapter must define a namespace for its properties "Property. Name. Space"="namespace" – Each adapter may have a set of prefixes that uniquely identify the adapter type within Biz. Talk Server. This allows resolution of the correct transport type when sending a message through a dynamic send port "Aliases. XML"="<Adapter. Alias. List><Adapter. Alias>sample: //</Adapter. Alias></A dapter. Alias. List>" – The adapter must have configuration property pages to configure its receive locations and send ports. Each adapter registers its property pages by specifying their respective class IDs "Inbound. Protocol_Page. Prov"="{%CLSID for inbound protocol prop page%}" "Outbound. Protocol_Page. Prov"="{%CLSID for outbound protocol prop page%}" "Receive. Location_Page. Prov"="{%CLSID for receive location prop page%}" "Transmit. Location_Page. Prov"="{%CLSID for transmit location prop page%}" If the adapter uses the Adapter Framework's user interface for property page generation, it must specify the following values for the registry keys "Inbound. Protocol_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689 A 281}" "Outbound. Protocol_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689 A 283}" "Receive. Location_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689 A 280}" "Transmit. Location_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689 A 282}" 55
Adapters registry entries – – – The adapter registers its runtime components by specifying their class IDs (for COM and . NET), type names, and assembly paths (for. NET) for receive and send runtime components "Outbound. Engine. CLSID"="{%CLSID of outbound transport%}" "Inbound. Engine. CLSID"="{%CLSID of inbound transport%}" "Inbound. Type. Name"="Biz. Talk. Samples. Adapters. My. Receiver" "Outbound. Type. Name"="Biz. Talk. Samples. Adapters. My. Transmitter" "Inbound. Assembly. Path"="C: Program FilesMy. Transport. dll" "Outbound. Assembly. Path"="C: Program FilesMy. Transport. dll" The adapter needs to register its properties with the Biz. Talk Server SSO database to be able to store and retrieve the properties at design time and run time Receive. Handler. Properties. XML Receive. Location. Properties. XML Send. Handler. Properties. XML Send. Location. Properties. XML The adapter must be registered under its Implemented Categories attribute in the registry as a transport provider. This attribute identifies its characteristics to consumers of the adapter [HKEY_CLASSES_ROOTCLSID{%uuid of custom transport%}Implemented Categories] [HKEY_CLASSES_ROOTCLSID{%uuid of custom transport%}Implemented Categories{7 F 46 FC 3 E-3 C 2 C-405 B-A 47 F-8 D 17942 BA 8 F 9}] 56
Registry file sample Windows Registry Editor Version 5. 00 [HKEY_CLASSES_ROOTCLSID{62018 D 08 -281 A-415 b-A 6 D 3 -6172 E 3762867}] @="Static Dot. Net. File Adapter" "App. ID"="{12 A 6 EBAA-CF 68 -4 B 58 -B 36 E-A 5 A 19 B 22 C 04 E}" [HKEY_CLASSES_ROOTCLSID{62018 D 08 -281 A-415 b-A 6 D 3 -6172 E 3762867}Biz. Talk] @="Biz. Talk" "Transport. Type"="Static Dot. Net. File" "Constraints"=dword: 00003 C 0 b "Inbound. Protocol_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689 A 281}" "Outbound. Protocol_Page. Prov"="{2 DE 93 EE 6 -CB� 01 -4007 -93 E 9 -C 3 D 71689 A 283}" "Receive. Location_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689�A 280}" "Transmit. Location_Page. Prov"="{2 DE 93 EE 6 -CB 01 -4007 -93 E 9 -C 3 D 71689 A 282}" "Inbound. Engine. CLSID"="{3 D 4 B 599 E-2202 -4 bbb-9 FC 6 -7 ACA 3906 E 5 DE}" "Inbound. Type. Name"="Microsoft. Biz. Talk. SDKSamples. Adapters. Dot. Net. File. Receiver" "Inbound. Assembly. Path"="C: \Program Files\Microsoft Biz. Talk Server 2006\SDK\Samples\Adapters. Development\File Adapter\Runtime\bin\Debug\Microsoft. Biz. Talk. SDKSamples. Adapters. Dot. Net. File. Runtime. dll" "Outbound. Engine. CLSID"="{024 DB 758 -AAF 9 -415 e-A 121 -4 AC 245 DD 49 EC}" "Outbound. Type. Name"="Microsoft. Biz. Talk. SDKSamples. Adapters. Dot. Net. File. Transmitter" "Outbound. Assembly. Path"="C: \Program Files\Microsoft Biz. Talk Server 2006\SDK\Samples\Adapters. Development\File Adapter\Runtime\bin\Debug\Microsoft. Biz. Talk. SDKSamples. Adapters. Dot. Net. File. Runtime. dll" "Adapter. Mgmt. Type. Name"="Microsoft. Biz. Talk. SDKSamples. Adapters. Designtime. Static. Adapter. Management" "Adapter. Mgmt. Assembly. Path"="C: \Program Files\Microsoft Biz. Talk Server 2006\SDK\Samples\Adapters. Development\File Adapter\Design Time\Adapter Management\bin\Debug\Microsoft. Biz. Talk. SDKSamples. Adapters. Dot. Net. File. Designtime. dll" "Property. Name. Space"="http: //schemas. microsoft. com/Biz. Talk/2003/SDK_Samples/Messaging/Transports/dotnetfile-properties" "Aliases. XML"="<Adapter. Alias. List><Adapter. Alias>Dot. Net. FILE: //</Adapter. Alias></Adapter. Alias. List>" "Receive. Handler. Properties. XML"="<Custom. Props><Adapter. Config vt="8"/></Custom. Props>" "Send. Handler. Properties. XML"="<Custom. Props><Adapter. Config vt="8"/></Custom. Props>" "Receive. Location. Properties. XML"="<Custom. Props><Adapter. Config vt="8"/></Custom. Props>" "Send. Location. Properties. XML"="<Custom. Props><Adapter. Config vt="8"/></Custom. Props>" [HKEY_CLASSES_ROOTCLSID{62018 D 08 -281 A-415 b-A 6 D 3 -6172 E 3762867}Implemented Categories] [HKEY_CLASSES_ROOTCLSID{62018 D 08 -281 A-415 b-A 6 D 3 -6172 E 3762867}Implemented Categories{7 F 46 FC 3 E-3 C 2 C-405 B-A 47 F-8 D 17942 BA 8 F 9}] 57
Registry entries • For 32 bit adapters the keys are stored in – HKEY_CLASSES_ROOTCLSID • For 64 bit adapters the key are stored in – HKEY_CLASSES_ROOTWow 6432 NodeCLSID • Dll can be addressed: – By file name • "Outbound. Type. Name"="HTTPAdapter. Transmitter" • "Outbound. Assembly. Path"="C: \Temp\HTTPAdapter\bin\De bug\HTTPAdapter. dll” – By Fully Qualified Assembly • "Outbound. Type. Name"="HTTPAdapter. Transmitter, HTTPAdapter, Version=1. 0. 0. 0, Culture=neutral, Public. Key. Token=……" • "Outbound. Assembly. Path"="” Note: the empty string for the path 58
Adapter registry wizard • Adapter. Registry. Wizard. exe – The wizard (under the SDKutilities) helps you to create the registry entries for a custom adapter – Generates a. reg file 59
Best practices • Split the adapter into three components – So BTS at run-time needs just to load the receive and transmit • Adapter configuration loaded as static properties – To improve the scalability of the adapter • Use a custom stream for the messages – Just remember that the XMLDisassembler needs aseekable stream • Test the adapter with a static and a dynamic send port – The adapter configuration (property bag) passed is different 60
ESB Toolkit • The adapter implemented cannot be called natively from the ESB Toolkit from a STATIC or BRE resolver • The configuration properties specified on the resolver need to be translated into message context properties through an Adapter Provider • Sample of and Adapter Provider is attached with the source code 61
Static Resolver • The Resolver may use a Static port like in the screenshot To set the endpoint dynamic properties the string in the Static port needs to be converted in actual message context properties 62
BRE Resolver • The Resolver may use a BRE like the rule in the screenshot To set the endpoint dynamic properties the string in the Rule needs to be converted in actual message context properties 63
How to implement an Adapter Provider • And Adapter Provider is a. NET component (Class Library) • Add the following references: – – Microsoft. Biz. Talk. Global. Property. Schemas Microsoft. Biz. Talk. Pipeline Microsoft. XLANGs. Base. Types Microsoft. Practices. ESB. Adapter 64
Add a class with the following code • Public class deriving from Base. Adapter. Provider – public class Adapter. Provider : Base. Adapter. Provider • Implement a Adapter. Name property – – public override string Adapter. Name { get { return "Simple. HTTP"; } • Overrides a Set. Endpoint method – public override void Set. Endpoint(Dictionary<string, string> resolver. Dictionary, XLANGMessage message) 65
Set. Endpoint • Calls the base Set. Endpoint and retrieve the base transport properties – base. Set. Endpoint(resolver. Dictionary, message); – string transport. Location = resolver. Dictionary["Resolver. Transport. Location"]; – string outbound. Transport. CLSID = resolver. Dictionary["Resolver. Outbound. Transport. CLSID"]; – string transport. Type = resolver. Dictionary["Resolver. Transport. Type"]; • Sets the context properties – message. Set. Property. Value(typeof(BTS. Outbound. Transport. Location), transport. Location); – message. Set. Property. Value(typeof(BTS. Outbound. Transport. Type), transport. Type); – message. Set. Property. Value(typeof(BTS. Outbound. Transport. CLSID), outbound. Transport. CLSID); 66
Set. Endpoint • Gets the endpoint config – string endpoint. Config = resolver. Dictionary["Resolver. Endpoint. Config"]; • Parses the string and assigns the properties – – – if (!string. Is. Null. Or. Empty(endpoint. Config)) { // parse delimited endpointconfig and set SFTP specific adapter properties // end. Point. Config data with this format "Key 1=Value 1; Key 2=Value 2; . . " var config = endpoint. Config. Split('; '). Select(part => part. Split('=')). To. Dictionary(split => split[0], split => split[1]); – – – – – // Set the context for the SFTP adapter if (config. Contains. Key("Method")) { message. Set. Property. Value(typeof(Simple. HTTP. Method), config["Method"]); } if (config. Contains. Key("Content. Type")) { message. Set. Property. Value(typeof(Simple. HTTP. Content. Type), config["Content. Type"]); } 67
Set. Endpoint properties parsing • The implementation just splits by “; ” to get key-value pairs then splits by “=” to separate the key from the value • Simple to read and maintain but your configuration cannot contain ; or = as values (i. e. your password cannot contain = or any base 64 encoded string) • Better implementation is to embed an XML fragment and parse using the DOM 68
How to deploy the Adapter Provider • The deployment requires: – On all the Biz. Talk nodes, GAC the Adapter Provider dll – Edit the esb. config file to add the following XML fragment under adapter. Providers: – <adapter. Provider – name="Simple. HTTP" – type="HTTPAdapter. ESBProvider. Adapter. Provider, HTTPAdapter. ESBProvider, Version=1. 0. 0. 0, Culture=neutral, Public. Key. Token= " – moniker="Simple. HTTP" /> • Restart the Biz. Talk Services 69
How to call the adapter provider • Now you can call the Off-Ramp on your Itinerary and the dynamic port transmission detail can be stored in a rule 70
The sample adapter (Simple. HTTPAdapter)
Introduction • The adapter implement a simple HTTP adapter – In-Process adapter (hosted by Biz. Talk service) • Implement the Receiver using the Http. Listener class provided by the. NET Framework 2. 0 – One-Way – Request-Response • Implement the Transmitter using the Http. Web. Request – One-Way – Solicit-Response • Other – The adapter is asynchronous – The adapter is not transactional – The adapter is not batching (it sends/receives messages straight to/from the EPM) – Implements a property browser at design time 72
Configuration properties • Receiver – Port Number: the TCP/IP port number used by the HTTP listener • Each receive port needs a different number • Transmitter – Url: The url to post the body part of the message 73
Project folder structure • Simple. HTTPAdapter – Source code for the adapter • Test. App – Console application to test some methods of the adapter • Http. Requestor – Windows application to post strings to urls • Biz. Talk. Test. App – Orchestrations to test the adapter • Test. Web – A web application to test the send adapter • File. Out – Folder used to dump messages from the orchestrations 74
Simple. HTTPAdapter • Created a new Class Library – Simple. HTTPAdapter • Added the following references: – C: WINDOWSassemblyGAC_MSILMicrosoft. Biztalk. Adapter. Framework3. 0. 1. 0 __31 bf 3856 ad 364 e 35Microsoft. Biztalk. Adapter. Framework. dll – C: Program FilesMicrosoft Biz. Talk Server 2006Microsoft. Biz. Talk. Interop. Transport. Proxy. dll – C: Program FilesMicrosoft Biz. Talk Server 2006Microsoft. Biz. Talk. Pipeline. dll • Folders – – Config. Schemas: contains the schemas for the BTS property page Management: contains the source code for the configuration interfaces Receiver: contains the source code for the receiver Transmitter: contains the source code for the transmitter 75
Management implementation • Simple. HTTPAdapter. Management. cs – Simple. HTTPAdapter. Management class which implements • IAdapter. Config – to return the schemas for the BTS property page • IAdapter. Config. Validation – to check validity of the configuration and to add the URI (Address URI) • Config. Schemas – Contains the schema files which are embedded resources 76
Receiver implementation • Simple. HTTPAdapter. Receiver. cs – Simple. HTTPAdapter. Receiver class which implements • IBase. Component – the 3 props implemented • IBTTransport – the 2 props implemented • IBTTransport. Control – To initialize and terminate the adapter • IBTTransport. Config – To start and stop the HTTP listener for each receive port • Receiver. Base. cs – Receiver. Base class – Defines the Start and Stop abstract methods – Provides a Submit. Message, Submit. Request. Message and Extract. Config. Property methods for the derived class • Http. Receiver. cs – Http. Receiver class which implements • Receiver. Base – implements the Start and Stop methods • IBTTransmitter – implemented for the solicit-response ports • IBTBatch. Call. Back – BTS call back delegate 77
Transmitter implementation • Simple. HTTPAdapter. Transmitter. cs – Simple. HTTPAdapter. Transmitter class which implements • IBase. Component – the 3 props implemented • IBTTransport – the 2 props implemented • IBTTransmitter – To send the message to the destination • Transmitter. Base. cs – Transmitter. Base • Defines the Transmit. Message abstract method • Provides Create. Message and Extract. Config. Property methods to the derived classes • Http. Transmitter. cs – Http. Transmitter class which implements • Transmitter. Base – Implements the Transmit. Message • IBTBatch. Call. Back – BTS call back delegate 78
Other classes • Adapter. Stream. cs – Adapter. Stream class • Implements a seekable stream • Derives from Memory. Stream class • Implement a static method to clone streams • Constants. cs – Constants class • List of constants used throughout the code • Controlled. Termination. cs – Controlled. Termination class • Semaphore used to control the adapter termination. The adapter when BTS calls the terminate method is waiting until all the messages are submitted to BTS 79
Exception Handling • During the initialization and termination phases: – Called the Set. Error. Info of the Transport. Proxy object to inform BTS of the error • When a message is involved – Called the Set. Error. Info of the message • Implement the retry logic – By resubmitting the message on the Message. Box in case the retry count is not exhausted – Invoking the secondary transport if defined – Suspending the message in all other cases Sample code of the above implementation is on the catch block of the transmitter 80
Http. Requestor test application URL to post Post body Response Click here to post Error 81
Biz. Talk. Test. App test application • One Schema (Namespace http: //test) – Root element r one child a • <r xmlns=“http: //test”><a>some text</a></r> • Three orchestrations – Biz. Talk Orchestration 1. odx • Receive a message from a One-Way receive port • Send the message received to a file drop port • Send the message received to a One-Way send port – Biz. Talk Orchestration 2. odx • Receive a message from a Request-Response port • Send the message received to a file drop port – Biz. Talk Orchestration 3. odx • Receive a message from a One-Way receive port • Send the message received to a Solicit-Response send port • Send the message received (from the solicit-response port) to a file drop port 82
Bindings • Biz. Talk Orchestration 1. odx – Simple. HTTP_One. Way_Receive: To a Simple. HTTPAdapter (Listening on port 8080) – File_Send port: To a folder – Simple. HTTP_One. Way_Send: To a Simple. HTTPAdapter (http: //localhost/Test. Web/Default. aspx) • Biz. Talk Orchestration 2. odx – Simple. HTTP_Two. Way_Receive: To a Simple. HTTPAdapter (Listening on port 8888) – File_Send port: To a folder • Biz. Talk Orchestration 3. odx – Simple. HTTP_One. Way_Receive: To a Simple. HTTPAdapter (Listening on port 9999) – Simple. HTTP_Two. Way: To a Simple. HTTPAdapter (http: //localhost/Test. Web/Default. aspx) – File_Send port: To a folder 83
Test. Web test application • http: //localhost/Test. Web/Default. aspx – On the On. Load • Reads the content posted by the client and trace it (Output. Debug. String) • Returns an XML message 84
How to deploy • Adapter – – Open the. reg file and change the path of the assemblies Register the. reg Add the adapter to the adapter list (from the BTS Admin) Restart BTS service • Biz. Talk. Test. App – Deploy the solution – Bind the ports as per specification – Start the orchestrations • Test. Web web site – Add the VDIR to the IIS locally 85
How to test • If you want to test the initialize methods – – – Disable all the ports bound to the adapter Restart BTS Attach VS to the BTS process Set the breakpoints Enable the ports Now disable the ports and stop the BTS service to test the termination source code • If you want to test the One-Way receive port – – – Enable the port and the BTS service Start the Biz. Talk Orchestration 1 Attach VS to the BTS process Set the breakpoints Use the HTTPRequestor to post a message (http: //localhost: 8080) The result is the message posted saved as file in the file drop location 86
How to test • If you want to test the One-Way send port – – – – Enable the port and the BTS service Start the Biz. Talk Orchestration 1 Attach VS to the BTS process Set the breakpoints Use the HTTPRequestor to post a message (http: //localhost: 8080) The result is the message posted saved as file in the file drop location On the output window of VS you can see the dump of the message (done by the default. aspx page) • The entry starts with the following string: Received from Test. Web web app: 87
How to test • If you want to test the request-response receive port – – – Enable the port and the BTS service Start the Biz. Talk Orchestration 2 Attach VS to the BTS process Set the breakpoints Use the HTTPRequestor to post a message (http: //localhost: 8888) The orchestration is responding with the same message so you can see the same message you sent as request on the response text box of the HTTPRequestor – The result is the message posted saved as file in the file drop location • If you want to test the solicit-response port – – – – Enable the port and the BTS service Start the Biz. Talk Orchestration 3 Attach VS to the BTS process Set the breakpoints Use the HTTPRequestor to post a message (http: //localhost: 9999) The solicit-response post the message to the testweb application The result is the message returned by testweb and saved as file in the file drop location 88
How to test • If you want to test the dynamic port – – – – Enable the port and the BTS service Start the Biz. Talk Orchestration 4 Attach VS to the BTS process Set the breakpoints Use the HTTPRequestor to post a message (http: //localhost: 9999) The solicit-response post the message to the testweb application The result is the message returned by testweb and saved as file in the file drop location 89
Assembly file locked when loaded • If the assembly is locked by the client you cannot compile with VS • Here a list of possible clients: – Visual Studio (if you are using the Biz. Talk explorer) – Biz. Talk Administration – Biz. Talk service • It is useful to have a tool to identify which process(es) keep locked the dll 90
Misc • If you change some of the configuration settings on the registry file you need to: – Remove the adapter from the Biz. Talk adapter list – Re-register the new reg file – Add the adapter the Biz. Talk adapter list • Part of the registry configuration is copied on the Biz. Talk Management database 91
Test cases • Tested – – – – Management interfaces (Visual Studio, BTS Admin) One-Way receive static port Request-response static port One-Way send static port Solicit-Response static port Dynamic Send Ports Exception handling (& message suspension) 92
- Slides: 92