Monday, 31 October 2011

BizTalk Published Service Certificate Authentication Consume by Java Client Part1

BizTalk Published Service Certificate Authentication Consume by Java Client - Part1

I had a situation where my BizTalk published wcf service is consume by non .net Framework applications like java.I have been trying to accomplish this task for last one month but could not get right answer. After regressive search I found a useful class library which can support .net applications and java with supporting NetBeans 7.0 or higher class library.

As I mentioned in the title, I will explain you how to secure your BizTalk published (schema/Orchestration) WCF Service.Here I am not keen to describe the steps to publish Schema / Orchestration as WCF Service. If you are looking for “How to publish” refer this link
http://msdn.microsoft.com/en-us/library/bb226564(v=bts.70).aspx

Step:-1
First step is to download the “WCF Express Interop Bindings 1.0.zip.zip“ file and install on your development box.http://wcf.codeplex.com/releases/view/68276

Step:-2
Amend machine.config file with metroBinding.

If you are running with .net Framework 4.0 then you need to update in two machine configuration files

1. C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
2. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

If you are running with .net Framework 4.0 under 64bit windows then you need to update in another two machine configuration files

1. C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\ machine.config
2. C:\Windows\Microsoft.NET\Framework64\v4.0.30319\CONFIG\ machine.config

Add Binding Extensions
Name ="metroBinding" type="Microsoft.ServiceModel.Interop.Metro.Configuration.MetroBindingCollectionElement, Microsoft.ServiceModel.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4fc38efee625237e"

Add Client endpoint

binding="oracleEBSBinding"
contract="IMetadataExchange"
name="oracleebs"
your machine.config should look like below



Note: Make sure you back up of each machine.config file before you update.

So far we have done the install and configure the metro binding. Now we do the actual BizTalk configuration and testing part.

Step:-3
Generate Server and Client certificate to authenticate the service for “Mutual authentication” process

Generate Server Certificate
makecert -r -pe -n "CN=BTSTestServerCertificate" -sky exchange BTSServerCert.cer -sv BTSServerCert.pvk
pvk2pfx.exe -pvk BTSServerCert.pvk -spc BTSServerCert.cer -pfx BTSServerCert.pfx

Generate Client Certificate
makecert -r -pe -n "CN=BTSTestClientCertificate" -sky exchange BTSClientCert.cer -sv BTSClientCert.pvk
pvk2pfx.exe -pvk BTSClientCert.pvk -spc BTSClientCert.cer -pfx BTSClientCert.pfx

Install Server and Client certificates (.cer) at Trusted Root Certification Authorities

Install Server and client Personal Information Exchange (.pfx) files at Personal Tab

If java client is consuming the BizTalk published service then you need to send Server and Client .pfx files to Java guys to generate .jks (Java Key store file) file

Step:-4
Create Two-Way receiveLocation for the published service ( if you have mentioned application name during le publishing Wizard open the receive location)
use WCF-Custom / WCF-CustomIsolated adapter and then use metrobinding to configure the Certificate authentication.

Selecting adapter and General Configuration



MetroBinding – General configuration



MetroBinding – Security configuration




Behavior Configuration



You are ready with certificate authentication for BizTalk published WCF service. You can use this service to consume .net and non .net application like Java.

I will update you on my next article for how to test using “.net client”

Continue -- Part-2

Drop a comment if this article helped you to solve your problemalso you can email me for complete solution zip file to download
you can reach me @ raj.webjunky@yahoo.com

Friday, 23 September 2011

Biztalk Dynamic Request Response Port –Consume WCF Service - Error MoveToNextTransport()


Dynamic Request Response Port – Consume WCF Service - Error MoveToNextTransport()
The transport proxy method MoveToNextTransport() failed for adapter WCF-Custom: Reason: "Messaging engine has no record of delivering the message to the adapter. This could happen if MoveToNextTransport() is called multiple times for the same message by the adapter or if it is called for a message which was never delivered to the adapter by the messaging engine". Contact the adapter vendor.


Recently I developed a common Orchestration to send message to WCF Service and get a response from service using Dynamic Request-Response Port.

Basically I am using this Orchestration to receive message from any other orchestration or ESB Itinerary. Here I have two options to resolve the endpoint details.

When a message received form another orchestration, the received message (Xml) contains the additional elements to detail about the endpoint info. When a message received from ESB Itinerary, I am using Resolver dictionary to find the endpoint info, it could be a static or UDDI or BRE resolver.

Every thing looks fine and my orchestration looks like below, I also included XLANGs.BaseTypes.Address and XLANGs.BaseTypes.TransportType to define my endpoint info.
Orchestration is working fine when I submit properly formatted message. It also received a proper fault message when ever endpoint service throws a fault.
Here is the issue, when SOAP fault comes back to orchestration it could see an event log with below error.

The transport proxy method MoveToNextTransport() failed for adapter WCF-Custom: Reason: "Messaging engine has no record of delivering the message to the adapter. This could happen if MoveToNextTransport() is called multiple times for the same message by the adapter or if it is called for a message which was never delivered to the adapter by the messaging engine". Contact the adapter vendor.

When I google it, some one suggested me to add “PropogateFaultMessage=False” to the dynamic port to overcome this error. However that resulted me many other issues then I started digging the issue for 2 days and finally found the solution.




The solution is to add the adapter binding type before you submit message to endpoint system.
Here is my updated code at message assignment shape.




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

Thursday, 7 July 2011

How to call WCF Service using ESB ToolKit

This example aims to describe the key design model for Consuming WCF Service and send the WCF Response to any local folder.
IService.cs


Service.cs


Web.config
I knew this configuration is simple and everyone knows the basic config settings. However I am giving this example because, I have seen many problems while calling wcf service at Itinerary design resolvers.
If you have more complex configuration, then you cannot use existing Wcf-wsHttp adapter instead you must go for wcf-Custom adapter
Here I am trying to use existing wcf-wshttp adapter.



After successful creation of WCF Service build and execute it and test with
WCF-Test Client before you consume the service in BizTalk.

If everything is fine , then use BizTalk Add generate items wizard to extract the WCF xsd schemas.
Steps to generate schemas using BizTalk add Generate Items wizard
Click on BizTalk solution and right click and select
Add Generated Items -> Click Consume WCF Service->
Metadata Exchange(MEX)Endpoint -> enter your WCF service URL
and click Ok to generate the XSD Schemas at your BizTalk application.

Here I am giving you my solution explorer for sake of more clarity


Create maps from Createorders to WCF Request and wcf-Response to OrderSummary (output) schema.
Hope you can create basic schemas by observing this maps. Hence I am not providing another steps to creating OrderSummary and CreateOrders Schemas.




Create a new Biztalk Application and add two send ports and define the properties mentioned below
Name : ESBConsumeWCFService.TwoWaySendPort
Type : Two-Way Port
SendPipeline : ItinerarySendPassthrough
ReceivePipeLine :ItinerarySendReceive
Filter Properites:
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceName == TwoWayOrderSubmit And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceState == Pending And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceType == Messaging And
Microsoft.Practices.ESB.Itinerary.Schemas.IsRequestResponse == True

Name : ESBConsumeWcfServiceTest.WCFOutput.FILE
Type : One-Way Port
SendPipeline : ItinerarySendPassthrough
Filter Properites:
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceName == OneWaySend And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceState == Pending And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceType == Messaging

Configuring Receive Port
Receive Port : ESBConsumeWcfServiceTest.ReceiveNewOrder
Receive Location : ESBConsumeWcfServiceTest.ReceiveNewOrder.FILE
Type : FILE (Enter local folder path to pick up the input file)
ReceviePipeline : ItinerarySelectReceiveXml
ReceviePipeline Properties:
ItineraryFactKey : Resolver.Itinerary
ResolverConnectinString :ITINERARY:\\name=ESBConsumeStockService;


Finally Itinerary Design
Here is the sample for consume WCF service using ESB Toolkit 2.1 Itinerary design. No need of suing Orchestration process






Properties for Get Endpoint config Static Resolver






Drop a comment if this article helped you to solve your problem
also you can email me for complete solution zip file to download
you can reach me @ raj.webjunky@yahoo.com

Friday, 1 July 2011

ESB Portal unhandled exception - HTTP request is unauthorized -server was Negotiate NTLM Basic realm localhost

I have been trying to fix the below error for last couple of days , But could not get right path and I had an impression that this error is more related to Windows permissions for my ESB.Portal application. But that is not the fact.

Exception message: The HTTP request is unauthorized with client authentication scheme Negotiate. The authentication header received from the server was Negotiate,NTLM,Basic realm=localhost.

I had around 80,600 records of data on my Exception Database for 1 month of transaction. Initially when I tried for Hour , Day and week view of ESB Portal it worked fine for me but it did not work for Month view. So, it gave me an impression that MS had developed a code to restrict the usage of ESB.Portal because this is a sample version. Then I started looking at the Stored procedures used for ESB Portal but did not get any clue.

After a while I started to debug the code and I found the root cause of this issue. The issues is due to large size of data (exceptions database) been imported for the Faults Service and this is more to deal with application configuration section than database level.

You might find Warning or Error in Event log as below

Log Name : Application
Source : ASP.NET 2.0.50727.0
Event code : 3005
Event message : An unhandled exception has occurred.

Application information:
Application domain: /LM/W3SVC/1/ROOT/ESB.Portal-1-129539791417651141
Trust level: Full
Application Virtual Path: /ESB.Portal
Application Path: C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\ESB.Portal\

Process information:Process ID: 13408
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
Exception type: MessageSecurityException
Exception message: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM,Basic realm="localhost"'.

Request information:Request URL: http://localhost/ESB.Portal/Faults/Faults.aspx
Request path: /ESB.Portal/Faults/Faults.aspx
User host address: ::1
User: MYUSER
Is authenticated: True
Authentication Type: Negotiate
Thread account name: NT AUTHORITY\NETWORK SERVICE

The Fix is very simple
all you have do is Update the web.config files for both ESB.Exceptions.Service and ESB.Portal. Make sure you have done the same changes for both files. including the message size and maxarray lengths.


ESB.Exception.Service - Web.Config Changes





ESB.Portal - Web.Config Changes



Drop a comment if this article helped you to solve your problemyou can reach me @ raj.webjunky@yahoo.com




Thursday, 19 May 2011

Monday, 16 May 2011

Cshap Transform embedded XSLT from Resource .resx and convert to Class/Object

I had a situation execute a xslt Transform from my Csharp Class Library.When I googled I found an incomplete solution in many search result. Hence It would be worth to keep a complete solution for "How to read and embedded XSLT from Resource file and transform to expected output with deserialize as Class. Here is my simple Class












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




















Thursday, 28 April 2011

LINQ Group By Query - Cannot implicitly convert System.Collections.Generic.List

LinQ query is throwing an error mentioned below while I query a RecordSet with Group By Category of my Orders. After two hours of fighting with this query I came to know how to solver this issue. Hope this could be help any one hanging with these kind of error.
Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List'
< AnonymousType#1 > to 'System.Collections.Generic.List < ESB.Exceptions.Service.Implementation.EMPTable >'

My method looks like below which is throwing an error



The Fix is very simple , Add Class before writing new list.



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