Thursday, 15 January 2009

How to send Custom Soap Headers from BizTalk


Hi, I have been searching for an good article which shows the step by step development approach for sending a Custom Soap Headers from Biztalk. I found a couple of Microsoft blogs but its not very clear to me.

I just started my invention to find the right direction to accomplish this task today. I thought this would a help others to work with custom soap adapters.

The first Step is to develop an Webservice which had an additional SOAP header to the Webmethod. I hope you are expert in writing .net code to build an simple Webmethod.Here is my sample WebMethod and custom Soap header.

Now lets start work on Biztalk Part

First Step is to create a Similar Soap Header Property Schema at biztalk and set the couple of property to make use of Custom Soap header. How you are going to achieve this?
Add webreference to your Biztalk Application. You can find the Reference.XSD Schema with custSoap header.

Steps to Create Soap Header Schema:
Create a Property Schema and rename to any(not necessary to rename) Just to keep this schema as more understandable. I renamed it as SoapHeader.xsd
Rename the “Property1” element to your Custom soap Header Class name and set the properties as mentioned below.
Ex: In my above .net Code my Soap header class name is “CustAuthHeader
Schema property:
TargetNamespace=http://schemas.microsoft.com/BizTalk/2003/SOAPHeader
CustAuthHeader Property :
PropertySchemaBase = MessageContextPropertyBase


Assign SoapHeader Property values at Orchestration level :
As soon as you add web reference you can find Reference.xsd file which contain the SoapHeader elements. Here you have 2 options
  1. You can use Reference.XSD schema to send the UserName, Password
If you don’t find Reference.xsd then Create your Own schema and maintain Rootnode same as SoapHeader Class name and Input params as Elements.

Here I am using Reference.xsd schema to test this sample.
Before you call webMethod you need to pass the Soap Headers to the WebService Request. The orchestration Steps are

  1. collect the Input values from the Inbound Schema
  2. map the InputSchema to Reference.xsd Schema
  3. Assign Reference Schema Values to SoapHeader Property
  4. Call Webservice and get Response

Here step1, 2 and 4 is easy. What about the step 3 ? what you need to write at Assignment Shape ?
Here is the code
vxmlObj = new System.Xml.XmlDocument();
vxmlObj= WsReferenceMsg;
SoapHeaderWsRequestMsg(SOAPHeaderTest.CustAuthHeader)=vxmlObj.InnerXml.ToString();
Note: SOAPHeaderTest.CustAuthHeaderĂ  ProjectName.YourPropertySchemaRoot element.

Your final Orchestration should look like above image.
You can reach me at : raj.webjunky@yahoo.com

Monday, 5 January 2009

Custom Soap Exception Detail Propty -Work with BizTalk

How to make use of Custom SOAP error Detail property in BizTalk ?
Today I start this artical with showing a property of Soap Exception. Just have a look at the below image. Have you ever played around with Detail Propery provided by SoapException? If your anwer is "Yes" then jump to Biztalk part below the Webservice code and see how to handle the Detail property at biztalk level. Otherwise check the below code for detailed programming for Custom Soap Exceptions. ( Build a Detail property using Csharp Code).
.

I have written a simple webservice (webmethod) which accepts two input parameters and check the authentication. If success then returns the Bool value of "True" else raise the Cusom Soap Error Message.

WebService Code
[WebMethod]
public bool CheckAuthentication(string UserName , string Password)
{ if (UserName == "TestUser" && Password == "TestPwd")
{ return true; }
else
{
throw RaiseCustomSoapError("AuthenticationCheck","","101","User is not Authorize person to access this site" "CustomSOAPException");
}
}
________________________________________________________________________________________________________
public SoapException RaiseCustomSoapError(string NameofActor, string wsNamespace, string errNumber,string errMsg, string errSource)
{
XmlQualifiedName tmpfaultCode = null;
tmpfaultCode = SoapException.ClientFaultCode;

XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element,SoapException.DetailElementName.Name,SoapException.DetailElementName.Namespace);
XmlNode errorNode1 = xmlDoc.CreateNode(XmlNodeType.Element, "Errors", wsNamespace);
XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error",wsNamespace);
errorNode1.AppendChild(errorNode);

XmlNode errNumberNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber", wsNamespace);
errNumberNode.InnerText = errNumber;

XmlNode errMsgeNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorMessage", wsNamespace);
errMsgeNode.InnerText = errMsg;

XmlNode errSourceNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource", wsNamespace);
errSourceNode.InnerText = errSource;

errorNode.AppendChild(errNumberNode);
errorNode.AppendChild(errMsgeNode);
errorNode.AppendChild(errSourceNode);
rootNode.AppendChild(errorNode1);

//Constructing the exception
SoapException soapEx = new SoapException(errMsg, tmpfaultCode, NameofActor, rootNode);
return soapEx;
}
When you select soapEx.Detail property will retun the XML Structure of Error Details as mentioned in below format.
Custom Error Message Structure



BizTalk Code
Summary of Orchestration Flow : BizTalk receives the Inbound XML File which has username,password and Sends the same to Webservice method (CheckAuthentication) "Request"
If the UserName and password is valid then Wesbservice return the Success status of "True" value and you need to build the output Message and send to Destination Location.
Incase of Failed Authentication Webservice Throws Custom SOAP Exception. Biztalk will pick this Exceptions at SOAP Exception block (System.Web.Services.Protocols.SoapException) using Detail Property.

Inbound and Outbound Schemas:



Orchestration Flow


Write the below code at Assign Error Detail ( Assignment Shape) Code

vErrDetails = soapEX.Detail.OuterXml.ToString();
vXmlObj = new System.Xml.XmlDocument();
vXmlObj.LoadXml(vErrDetails);
GenMsg = vXmlObj;

vXmlObj2= new System.Xml.XmlDocument();
vXmlObj2.LoadXml(" Your generated output Schema structure");

OutputMsg = vXmlObj2;
xpath(OutputMsg,"//Errors") = xpath(GenMsg,"//Error");



For success Output message Error node would be empty and for the Failure (Custom Soap Error Detail property message) Error node filled with details.


you can reach me at raj.webjunky@yahoo.com

Wednesday, 24 December 2008

How to Call Custom Receive Pipeline inside Orchestration

How to Call Custom Receive Pipeline inside Orchestration
Create a simple project which accepts OrderDetails as input xml and transform to OrderSummary xml file.
ProjectName : CallPipeline
Here I created custom receive Pipeline which uses the “XML disassembler” component to validate my input message against the predefined XSD schema.

Step-1

Create Schema CallPiplineInOrder.xsd and define the structure as mentioned below image
Create Schema CallPipelineOutOrder.xsd and define the structure as mentioned below image and do a simple map.

Step-2
Add new receivepipeline and name it as receiveOrderPipe.btp and add the “XML Disassember” and set the property

DocumentSchema = CallPipeline.CallPiplineInOrder

Step-3
Add reference of Microsoft.XLANGs.Pipeline.dll from the location C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.XLANGs.Pipeline.dll
Create New Orchestration and place an Scope shape and set the Transaction Type= Atomic

Create new Variable vReceivePipeline and set the property
Type= Microsoft.XLANGs.Pipeline.ReceivePipelineOutputMessages

Inside the Expression Shape Write the following Code.
vReceivePipeline = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(CallPipeline.receiveOrderPipe),inboundMsg);

CallPipeline.receiveOrderPipe is projectName.Receive Pipeline TypeName



Here MY projectName = CallPipeline and Receive Pipeline TypeName = receiveOrderPipe

Finally your orchestration looks like ..


You can reach me @raj.webjunky@yahoo.com











Thursday, 11 December 2008

BizTalk Consumes Complex Data Type (Class/Object) Web Service

I have been trying to find an article that shows some light on how to consume a Web Service that returns Complex Data Type like Class / Object. At last I tried with small example which gave me good “Beep” to do a further investigation for Complex Data Types with Web Service.Here is my Class which I am going to use it as Complex data Type in Webservice.
Here is my Class which I am going to use it as Complex data Type in Webservice.

Create a C# WebService and create an Web Method that accepts 3 input parameters lime Employee ID , Employee Name and Employee JOB, also the web method returns the EMPLOYEE class as a datatype. Below is the Sample Code.


Now I am trying to Call this Webservice from the BizTalk , The challenge work is how Biztalk Returns the Employee Class to the destination ??

Schemas and Maps

Add a webreference to the BizTalk Application. Once you add web reference You can find a Reference.XSD file under your webReference. Here I renamed my webreference from localhost to “BTSlocalhost
Solution

Create a InputSchema that contain EmpID, Name, Job fields. The Structure looks like below


Create an ouput file with 3 fields as shown below

Now the Map is not between Input and Output Schema. Confused ??? , yes Here input schema used to send the data to the Webservice and that webservice returns the Employee Class as a Datatype. So the Reference.XSD is used as Source Schema and destination schema is ouput schema.
The Reference Schema contains the Employee Class and which creates a “Result” Method for Response object.


Orchestration

Create Message
Ws1_Resquest
= WebServiceTest.BTSLocalhost.AbcBTSWebServiceTest_. TestEmployee_request
Ws1_ResponseMsg = WebServiceTest.BTSLocalhost.AbcBTSWebServiceTest_.TestEmployee_response
Apart from this BizTalk creates an additional method called “Result” automacially.
Ws1_ResponseMsg. TestEmployeeResult
You need construct the TestEmployeeResult Message in your message Assignment shape.

Generate an Instance for your Reference.xsd and Load that XML file from your Message assignment shape and assign to “Ws1_ResponseMsg.TestEmployeeResult”

Apparently assign the input values to Webservice Method input parameters by extracting the values using xpath.
Ex: Ws1_Resquest.ename= xpath(InputMsg, string(“your xpath ”));



Now you need to use the Result Object in Transform Shape to assign the values to Output Schema.

Finally your Orchestration Looks like below.

Test your Application with sample File
Let me know If you have any issues reach me @ raj.webjunky@yahoo.com

Thursday, 27 November 2008

BizTalk Message Life Cycle

BizTalk Message Life Cycle
Receive Ports and Receive Locations
A receive port is a collection of one or more receive locations that define specific entry points into BizTalk Server. A receive location is the configuration of a single endpoint (URL) to receive messages. The location contains configuration information for both a receive adapter and a receive pipeline. The adapter is responsible for the transport and communications part of receiving a message
The receive pipeline is responsible for preparing the message for publishing into the MessageBox.
Send Ports
A send port is the combination of a send pipeline and a send adapter. A send port group is a collection of send ports and works much like an e-mail distribution list.The send pipeline is used to prepare a message coming from BizTalk Server for transmission to another service
Orchestrations
Orchestrations can subscribe to (receive) and publish (send) messages through the MessageBox. In addition, orchestrations can construct new messages. Messages are received using the subscription.


Thursday, 20 November 2008

BizTalk 2009 - up coming Version - Whats New?

Hi Friends, Today I am going through the MS site and I found some of the Useful information which I would Like to share with you Guys. MS is planning to lanch a new Biztalk 2009 ( BTS R3). Below are the new enhancements of BTS2009. ( I just copied the details from MS site)

BizTalk 2009 The next version of BizTalk Server continues to build on the investments made to address the concerns of service oriented architecture and enterprise connectivity.

Updated Platform Support
New Application Platform Support
BizTalk 2009 supports the latest Microsoft platform technologies, including Windows 2008, Visual Studio 2008 SP1, SqlServer 2008 and the .NET 3.5 SP1. These platform updates enable greater scalability and reliability, and many advances in the latest developer tools.
New Hyper-V Virtualization Support
(
BizTalk / Moss Virtualization Issues [Hyper-V]) BizTalk 2009 now takes advantage of the latest virtualization improvements included as part of Windows 2008 Hyper-V, which can lead to reduced costs through lower hardware, energy, and management overhead, plus the creation of a more dynamic IT infrastructure.
Improved Failover Clustering
By taking advantage of
Windows 2008 clustering, BizTalk Server is now able to be deployed in multi-site cluster scenarios, where cluster nodes could reside on separate IP subnets and avoid complicated VLANs.

Service Oriented Architecture and Web Services

New Web Services Registry
BizTalk 2009 includes a UDDI 3.0 registry which provides support for registry affiliation, extended discovery services, digital certificates and extensibility for a subscription API.
New Line of Business Adapters
BizTalk 2009 provides two new adapters for Oracle E-Business Suites and SQL Server, plus additional improvements have been made to the existing set of adapters.
Enhanced Host Systems Integration
BizTalk 2009 adds a new WCF WebSphere MQ channel by providing the transport, data formatter and encoder to integrate directly with WebSphere MQ via WCF and a new WCF Service for Host Applications has been added to expose the traditional Transaction Integrator to .NET Framework developers. Additionally, BizTalk 2009 includes updated platform support for the most recent versions of CICS, IMS, CICS HTTP transport, DB2, DB2/400, DB2 Universal Database, and WebSphere MQ. ( as well as TIBCO Chooses Microsoft .NET WCF & Silverlight )
Enhanced Business Activity Monitoring
By expanding the out of the box BAM functionality with
SqlServer 2008 Analysis Services, BizTalk 2009 provides support for UDM cubes and scalable real-time aggregations which enhances support for Microsoft PerformancePoint Server 2007.
Enhanced
Enterprise Service Bus (ESB) Guidance ESB Guidance 2.0 delivers updated prescriptive guidance for applying ESB usage patterns, improved itinerary processing, itinerary modeling using a visual Domain Specific Language (DSL) tools approach, a pluggable resolver-adapter pack, and an enhanced ESB management portal.

Business to Business Integration
Enhanced Support for EDI and AS2 Protocols
BizTalk Server 2009 provides support for multiple message attachments, configurable auto message resend, end-to-end filename preservation, improved reporting to address new features, and Drummond re-certification for AS2.
Updated SWIFT Support
By building on a rich SWIFT foundation,
BizTalk 2009 updates all message schemas and business rules for compliance with SWIFTReady Financial EAI Gold certification, as a result adds support for SWIFT FIN Flat File message types and business rules, BIC Plus IBAN interface, and Extensibility to support SEPA Routing.

Device Connectivity
New Mobile RFID Platform and device management
BizTalk 2009 delivers a new lightweight platform for a variety of mobile devices, which simplifies the development of mobile applications that expose relevant, real-time business information. BizTalk RFID Mobile includes support for enhanced device management, Powershell support for administration of edge infrastructures and the ability to monitor RFID infrastructure using System Center Operations Manager 2007. New RFID industry standards support
Support for key industry standards (including LLRP, TDT, TDS, WS Discovery and partial EPCIS support).


Developer and Team Productivity
New Application Lifecycle Management (ALM) support
BizTalk 2009 provides support for Team Foundation Server (TFS), and allows development teams to be able to leverage the integrated source control, bug tracking, support for team development, Project Server integration and support for automating builds via MSBuild.
Enhanced Developer Productivity
BizTalk 2009 introduces a number of improvements have been made to the underlying Visual Studio based BizTalk project system which enhances debugging support for artifacts such as BizTalk Maps (XSLT), pipeline components and XLANG Orchestrations, and enables support for unit testing via Visual Studio Test.

Other Enhancements

Messaging
BizTalk 2009 improves recoverable interchange processing of validation failures by providing support for recoverable interchange processing for disassembly (DASM) and a validation stage within the pipeline. The WCF Adapter has been enhanced to provide support for configurable transactions and the ability to choose the transaction isolation level in the WCF-Custom Send Adapter.
Administration
By continuing to build on the improvements to the BizTalk Management Console made in
BizTalk 2006 R2, two new query types have been added for tracked message events and tracked service events which consolidates all queries – tracked/archived data, live data and specialized EDI reports, into a single tool.

"Oslo" is the codename for Microsoft’s forthcoming modeling platform. Modeling is used across a wide range of domains and allows more people to participate in application design and allows developers to write applications at a much higher level of abstraction. "Oslo" delivers a new integrated platform for connecting across modeling domains, including a new "Oslo" modeling tool, an "Oslo" modeling language, and an "Oslo" repository. As we gathered feedback from BizTalk customers, they indicated they would prefer to take a disciplined, evolutionary path to adopting some of these newer platform technologies. We have thousands of customers that have deployed mission-critical applications on top of our BizTalk Server architecture; they want to decide for themselves when to move to newer versions of the platform.