I'm trying to use a custom method to encode strings into an XML payload, so that it removes escape characters.
I aim to do this by building the payload in a Message Assignment, passing through the input values for each element, and then where I know there will be XML escape chars in the input values, call my custom method to return the string'd, encoded equivalent (e.g. & becomes &);
e.g.
Calling the method from a Message Assignment;
<data>
<value>department</value>
<value>" + ExtensionPrintingSolution.Encode(StudentCanonical(Student_Feed.StudentCanonicalProperty.school_name)) + @"</value>
</data>
The Encode Class Method;
using System;
using System.Web;
public class XmlEncoder
{
public string Encode(string input)
{
return HttpUtility.HtmlEncode(input);
}
}
The problem;
The method is held in a separate project. I've added the project to the solution, and the reference of the Encoder .dll to the BizTalk project. When I try to call the method in my Message Assignment shape, declaring the namespace, method and parameter (as above), it tells me the reference can't be found.
To get around this, I've created a variable that I use to reference the Extension class .dll, and I can now link the method in the Assignment, but when I build the BizTalk project, it tells me:
a non-serializable object type 'XmlEncoder ExtensionPrintingSolution' can only be declared within an atomic scope or service
Is there a way to achieve what I'm trying to do here?