orchestration calling .net code
Hi
I have an orchestration from where I am calling a .Net library method UpdateReport() which returns an object of type FinalReport. The FinalReport is a serializable class which contains some fields like errorid,errordesc etc.
In this method UpdateReport() I am calling two webservices which updates some data in the database. Now if any exception occurs in the first webservice call or process then I catch that and populate the FinalReport.errorid & FinalReport.errordesc and I am handling this is the catch exception block in c#. However even if the error occurs in the first webservice then the process should continue with calling the second webservice and should only return object of FinalReport after completion of both the webservices or the entire UpdateReport() code block and then return the FinalReport object back to the calling orchestartion for further processing. And if any exception occurs even in the second webservice call then in the calling orchestration I need to get the errorid and errordesc of both the exceptions.
Could you please assist me in how can I handle this.
Thanks
August 28th, 2015 5:59pm

Hi,

The logic of calling the web service ad returning the success message or exception one in case of failure is being implemented in C# assembly within your UpdateReport()  method.

There is nothing for BizTalk to do here . You can check the if else  condition in your UpdateReport() method. In case of failure message returned from first call, you can have a logic to call the second web service call.

Note : All these logic of calling multiple web services can be implemented easily within BizTalk . You are not fully utilizing the capability of BizTalk as all the processing is being done through external assembly .I would suggest to have a look at your Integration Architecture design pattern to ease the process of supporting the developed artifacts.

Thanks

Abhishek

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 10:48pm

Thanks Abhishek....but in the .net class apart from just calling the webservices there is other business logic code as well so I am making use of this .net code. I get your point of using a condition in calling the second webservice even if the first one is either success or failure but then how will I get what exception had occurred in the orchestration.
August 28th, 2015 11:04pm

Hi,

You can try serializing your exception message ex or get the exception property necessary in your Orchestration and bind it to any element of the response object you are sending in the Orchestration .

For this you may need to add extra class variable inside your Orchestration.

Thanks

Abhishek

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 11:11pm

Thanks again...So I have serialized FinalReport which is the return type of the method inside which the two webservices and other business code is written.

sample pseudo code

public FinalReport  UpdateReport()
{
FinalReport frp = new FinalReport()
try
{call webservice1;
frp.errorid=0;//if success}
catch()
{
frp.errorid="something";frp.errordesc = "something"
return frp;
}

try
{call webservice2;
frp.errorid=0;//if success}
catch()
{
frp.errorid="something";frp.errordesc = "something"
return frp;
}
return frp;

}//close method

Now when the FinalReport object frp is returned to BizTalk orchestration I need to do something with the errorids and errordesc (assuming both the webservices has some error and threw execption) so how will I fetch the details of this FinalReport object in the orchestration.

Also as you suggested I can do something like calling the second webservice even from inside the first exception block so as to continue with the method execution even on failure, if that's what you suggested but then how will I access these details in the orchestration.

August 28th, 2015 11:45pm

Try referring to below MSDN article https://msdn.microsoft.com/en-us/library/dszsf989.aspx

You can always have a final block which will be executed in both the cases of success and failure (try or catch ). you can also refer https://msdn.microsoft.com/en-us/library/87cdya3t%28v=vs.110%29.aspx

to define user defined exception

Thanks

Abhishek



Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 12:01am

Hi Abhishek
Yes I got what you mean by continuing with the method despite the exception, but then how do I access the exception details in the orchestration, assuming both the webservice calls had a exception

Thanks

August 29th, 2015 12:23am

Try referring to below MSDN article https://msdn.microsoft.com/en-us/library/dszsf989.aspx

You can always have a final block which will be executed in both the cases of success and failure (try or catch ). you can also refer https://msdn.microsoft.com/en-us/library/87cdya3t%28v=vs.110%29.aspx

to define user defined exception

Thanks

Abhishek



Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 3:57am

Try referring to below MSDN article https://msdn.microsoft.com/en-us/library/dszsf989.aspx

You can always have a final block which will be executed in both the cases of success and failure (try or catch ). you can also refer https://msdn.microsoft.com/en-us/library/87cdya3t%28v=vs.110%29.aspx

to define user defined exception

Thanks

Abhishek



August 29th, 2015 3:57am

Try referring to below MSDN article https://msdn.microsoft.com/en-us/library/dszsf989.aspx

You can always have a final block which will be executed in both the cases of success and failure (try or catch ). you can also refer https://msdn.microsoft.com/en-us/library/87cdya3t%28v=vs.110%29.aspx

to define user defined exception

Thanks

Abhishek



Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 3:57am

Try referring to below MSDN article https://msdn.microsoft.com/en-us/library/dszsf989.aspx

You can always have a final block which will be executed in both the cases of success and failure (try or catch ). you can also refer https://msdn.microsoft.com/en-us/library/87cdya3t%28v=vs.110%29.aspx

to define user defined exception

Thanks

Abhishek



August 29th, 2015 3:57am

Hi,

Try to create an object of FinalReport in orchestration and access the details of it in the Orchestration.

Rahul

Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 6:52am

Can you list the steps 1, 2, 3...etc.  It's not very clear of the WS calls are inside your external class or not.
August 29th, 2015 8:47am

Sure
Step 1 - Orchestration calls the .Net library.

Step2 - The .Net code contains some business logic code including calls to the two webservices and then returns back to the Orchestration the result of the webservice call (success or fail). If fail then it also returns the errorid and errordesc. This is done using an object of FinalReport  class (which contains field like errorid and errordesc). But even if exception is occurred in first webservice call the  errorid and errordesc is set(FinalReport.errorid & FinalReport.errordesc) and rest of the code is executed and if again exception in second webservice call then errorid and errordesc is set(FinalReport.errorid & FinalReport.errordesc) and then the  object of FinalReport  class is returned back.

Step 2 - The .Net library returns back the object of FinalReport  to the Orchestration

Step 3 - Further processing is done in Orchestration for each errorid

Question - In Step 2 when the Orchestration receives the object of FinalReport and the errorid & errordesc is read it will only contain the errorid and errordescfor the second webservice call error as in Step 2 the first exception errorid & errordesc would have been overwritten. So how can I handle this to get both the set of errorid & errordesc in the Orchestration as further down I need to do some processing for each set of errorid and errordesc

Thanks

Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 10:13am

Without refactoring the external class, you can't.  The Orchestration only has access to whatever is returned so if the result of the first call lost inside the external class, that's it, it's gone.

Do you have access to that code?

Alternatively, can you replicate the functionality of this external class in the Orchestration?  Then you have full control over what happens with both calls.

August 29th, 2015 10:20am

Hi
Yes I have access to the external .Net code. Can you please suggest me what changes I would need to do in the .Net code.

Thanks

Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 10:40am

Without actually seeing it, it's difficult to give any specific advice.

You could change the method definition to return both FinalReport objects as out parameters.

August 29th, 2015 2:25pm

Hi Yes i can change the method definition & include 2 out parameters. But how to i then retrieve data from the parameters in biztalk. Can you give me a example of how will i call and get back the return value in the biztalk expression window Thanks
Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 5:38pm

Sorry, I don't follow.  You're just calling an external method, there's nothing special about it.

The two out parameters are the result instead of the return value, that's the only difference.

August 29th, 2015 6:12pm

Okay so in the biztalk expression window i can call the external method & use the two out params the same way as it would be done from a .net application? Thanks
Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 6:43pm

Hi
I have declared the type of the UpdateReport() as array of FinalReport (example below)

public FinalReport[]  UpdateReport()
{
//something;
}
Now in the orchestration expression window when I cam calling this C# method UpdateReport()
as
FReport= objRpt.UpdateReport();

So what should be the type of the variable I should declare FReport (I have given the type as the name of the C# class) but in orchestration expression I get an error as

"Cannot implicitly convert type PL.Reports.FinalReport[] to PL.Reports.FinalReport"

So how can I retrieve an array object into the orchestration?

Thanks

August 31st, 2015 2:25pm

:) Well, you chosen the one implementation you can't use in Expression Shapes.

FinalReport[] (as an Array) in not supported.

Can you expose the two FinalReports as Properties?  Like:

MyHelperClass.FinalReport1;

MyHelperClass.FinalReport2;

Or try out parameters.

Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 3:58pm

Hi
Thanks for the response. I am a newbie in BizTalk so just checking that if I use out parameters when I call the C# assembly from orchestration expression shape can I use this

FReport= objRpt.UpdateReport(out FinalReport1, out FinalReport2);

August 31st, 2015 4:08pm

Yes, out parameters are supported.
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 4:25pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics