|
Home > Archive > BizTalk Server General > June 2004 > Writing into message context
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Writing into message context
|
|
|
| I have a problem regarding how we write into the message context in a
custom pipeline the properties such as file name ...
so that I get the file output with that name instead of specifying any
macros.
If any one has already wriiten code in this scenario,Please include
the code as well.
Any help would be gratly appreciated.
Thanks
Srinivas.A
| |
| Sam Vanhoutte 2004-06-11, 5:43 pm |
| > I have a problem regarding how we write into the message context in a
> custom pipeline the properties such as file name ...
>
> so that I get the file output with that name instead of specifying any
> macros.
>
> If any one has already wriiten code in this scenario,Please include
> the code as well.
This should do the job. (we use this in our testing and never had any
problems with it)
string fileNameSpace =
"http://schemas.microsoft.com/BizTalk/2003/system-properties";
string propertyName = "OutboundTransportLocation";
string originalFileName = null;
string fullFileName = null;
//Read original filename
try
{
originalFileName = (string)inmsg.Context.Read(propertyName,
fileNameSpace);
}
catch(Exception ex)
{
throw new NullReferenceException("Unable to retrieve original filename
from context", ex);
}
//Promote filename
try
{
fullFileName = Path.Combine( new FileInfo(originalFileName).DirectoryName,
newFileName );
inmsg.Context.Write(propertyName, fileNameSpace, fullFileName);
}
catch(Exception ex)
{
throw new ApplicationException("Failed to change result filename to '" +
fullFileName + "' : " + ex.Message, ex);
}
HTH
| |
| Srini 2004-06-20, 11:07 pm |
| Hi
thanks a lot for your help.This is exactly what I needed.
I tried doing this but I could not which property was that as there
was no documentation syaing this.
Can I use the same property if I use FTP as well.
Thanks in advance
Srinivas.A
"Sam Vanhoutte" <sam.vanhoutte@unilin.com> wrote in message news:<#JsCTs4TEHA.2704@TK2MSFTNGP10.phx.gbl>...
>
> This should do the job. (we use this in our testing and never had any
> problems with it)
>
> string fileNameSpace =
> "http://schemas.microsoft.com/BizTalk/2003/system-properties";
> string propertyName = "OutboundTransportLocation";
> string originalFileName = null;
> string fullFileName = null;
> //Read original filename
> try
> {
> originalFileName = (string)inmsg.Context.Read(propertyName,
> fileNameSpace);
> }
> catch(Exception ex)
> {
> throw new NullReferenceException("Unable to retrieve original filename
> from context", ex);
> }
>
> //Promote filename
> try
> {
> fullFileName = Path.Combine( new FileInfo(originalFileName).DirectoryName,
> newFileName );
> inmsg.Context.Write(propertyName, fileNameSpace, fullFileName);
> }
> catch(Exception ex)
> {
> throw new ApplicationException("Failed to change result filename to '" +
> fullFileName + "' : " + ex.Message, ex);
> }
>
> HTH
| |
| Sam Vanhoutte 2004-06-20, 11:07 pm |
| I don't know the property for the FTP adapter, but when you save a message
from the HAT, you should see the property name and value in the context
file, I guess?
> Hi
>
> thanks a lot for your help.This is exactly what I needed.
>
> I tried doing this but I could not which property was that as there
> was no documentation syaing this.
>
> Can I use the same property if I use FTP as well.
>
> Thanks in advance
>
> Srinivas.A
>
>
>
> "Sam Vanhoutte" <sam.vanhoutte@unilin.com> wrote in message
news:<#JsCTs4TEHA.2704@TK2MSFTNGP10.phx.gbl>...[vbcol=seagreen]
FileInfo(originalFileName).DirectoryName,[vbcol=seagreen]
+[vbcol=seagreen]
|
|
|
|
|