Home Page › Forums › BizTalk 2004 – BizTalk 2010 › get a String from a db using an external assembly
- This topic has 1 reply, 1 voice, and was last updated 9 years, 10 months ago by
community-content.
-
AuthorPosts
-
-
October 23, 2008 at 7:46 AM #21037
Hi everybody,
I hope someone can help me.
I receive messages using a http adapter into BizTalk. Depending on the costumerID the Message has to be transferred into drifferent
ERP’s (Axapta). So the sendport should be dynamic.The problem I got is, that at the moment the Send Port Target is set hard coded within an expression shape.
This is in my opinion not the best way cause of maintenance.
So my idea was to get the targets from a db table.
I wrote a serializable external assembly (VB.Net):
<Serializable()> Public Class HelperClass
Public Function GetAxTarget(ByVal CustomerID As String) As String
Dim strSQL As String = “”
Dim connStr As String = “”connStr = “Data Source=(local);Initial Catalog=db;User Id=user;Password=passsword;”
Dim cn As New SqlConnection(connStr)
Dim cmd As New SqlCommand(“GetAxaptaTarget”, cn)
cn.Open()Try
cmd.Parameters.Add(“@CustomerID”, SqlDbType.NVarChar).Value = CustomerID
cmd.CommandType = CommandType.StoredProcedure
GetAxTarget = cmd.ExecuteScalar().ToString
Catch ex As Exception
Throw ex
Finally
cn.Close()
cn.Dispose()
End TryEnd Function
End Class
The orchestration is marked as long running transaction and within an atomic scope the expression Shape should use the function.
The code is:
AxaptaDel = AxaptaDelivery;
chk_nodes = AxaptaDel.SelectNodes(“/*[local-name()=’purchorder’ and
namespace-uri()=”]/*[local-name()=’header’ and
namespace-uri()=”]/*[local-name()=’extaccount’ and namespace-uri()=”]”);
chk_node = chk_nodes.Item(0);customer = chk_node.InnerText;
System.Diagnostics.EventLog.WriteEntry(“BTS Axapta Del – Set target”,
customer);helper = new HelperClass();
AxAdress = helper.GetAxTarget(customer);
helper.Dispose();
helper = null;
AxaptaWS(Microsoft.XLANGs.BaseTypes.Address) = AxAdress;But it doesn’t work. Everytime I get a message I get errors.
Does anybody know how this scenario works?
Thanks for any help.
Marcus
-
October 30, 2008 at 1:50 AM #21091
Hi Marcus,
Thank you for posting your question,
[quote user="Anonymous"]So my idea was to get the targets from a db table.[/quote]
can you elaborate more on how many targets does this solution have?
Mike
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.