Friday, April 5, 2013

BizTalk ESB Toolkit Sample Service ESB NorthAmericanServices Fails to execute

If you try to call ESB.NorthAmericanServices/CustomerOrder.asmx web service which is part of Dynamic Resolution Sample provided as part of ESB ToolKit 2.1, then most likely you will get the following error:

There was a failure executing the receive pipeline: "GlobalBank.ESB.DynamicResolution.Pipelines.ESBReceiveXML, GlobalBank.ESB.DynamicResolution.Pipelines, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e457dd48ca33cd6f" Source: "ESB Dispatcher Disassemble" Receive Port: "DynamicResolutionReqResp" URI: "/ESB.NorthAmericanServices/CustomerOrder.asmx" Reason: The document specification from assembly failed to load. Verify the schema for this document specification is deployed and is in the Global Assembly Cache.

Cause

The cause of this issue is the code of ESB.NorthAmericanServices/CustomerOrder.asmx refers to the old dll GlobalBank.ESB.DynamicResolution.Schemas V2.0.0.0.
Most likely Microsoft forgot to regenerate the service code after updating their assemblies to 2.1.0.0 version

Solution

The fix for this solution is to go to ESB.NorthAmericanServces\App_Code\CustomerOrder.asmx.cs file and go to submitOrder method code and change the following line of code:
string bodyTypeAssemblyQualifiedName = "GlobalBank.ESB.DynamicResolution.Schemas.NAOrderDoc, GlobalBank.ESB.DynamicResolu" +
"tion.Schemas, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e457dd48ca33cd6f";

                To
string bodyTypeAssemblyQualifiedName = "GlobalBank.ESB.DynamicResolution.Schemas.NAOrderDoc, GlobalBank.ESB.DynamicResolu" +
"tion.Schemas, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e457dd48ca33cd6f";


Error - The itinerary header could not be found Or There is an error in XML document (1, 2).


Once you resolve the above error then you may get this error depending on how are you calling this service:
NorthAmericanServices is nothing but a re-routing service to CanadianServices and that's why there is no corresponding orchestration.
If you look at closely at DynamicResolutionReqResp_SOAP receive location, it uses a ESBReceiveXML pipeline which uses ESB Dispatcher component to resolve the end points of canadian web service from BRE resolver and then it routes the service call to Canadian service. 

From here the call goes to DynamicResolutionSolicitResp send port, due to its filter on DynamicResolutionReqResp receive port. 

You may receive error "There is an error in XML document (1, 2)." This error occurs on DynamicResolutionReqResp receive port because it tries to route the request to Canadian web service while it receive request for NA web service, the schema for both are different. In order to resolve this issue, You need to make sure you have Inbound and Outbound Map on receive port to convert NA request to CN request on Inbound side and to convert CN response to NA response on outbound side. These maps are already present in Dynamic Resolution sample of ESB

Or
You may also receive "the itinerary header could not be found" on DynamicResolutionSolicitResp send port. Because this port uses ItinerarySendPassthrough pipeline it expects to have itineraryheader to be present in message context and if it does not find it throws this error.

If you call this service from an itinerary it will work on this send port. However in order to call the NorthAmericanServices directly from a .net app, you need to create another two-way send port which use XmlTransmit and XmlReceive pipelines.

No comments: