BizTalk Server General - Accessing HTTP header from within Biztalk custom pipeline

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > December 2004 > Accessing HTTP header from within Biztalk custom pipeline





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 Accessing HTTP header from within Biztalk custom pipeline
paul

2004-12-20, 5:48 pm

Hey all

Is it true that I can access an HTTP header from a custom pipeline while
using the BTSHTTPReceive.dll as the HTTP adapter?

I saw an extremely brief pseudo-code by Matt Milner that suggests the above
can be done as follows:
MyStringVar = MyinboundMessage(Http.InboundHttpHeaders);


If this is correct, what is the type of MyinboundMessage? Is it
IBaseMessage? Because I've tried it and it doesn't work. Is there an
example somewehere out there on this????

Below is a paste of the original conversation regarding this issue:


========================================
=====================================


See this hotfix for info on setting custom http headers:

http://support.microsoft.com/defaul...kb;en-us;841994

In order to retrieve headers, you can use the context property
(Http.InboundHttpHeaders) to get at them:

MyStringVar = MyinboundMessage(Http.InboundHttpHeaders);

..... do something with the string to get the header you want.

Matt


"Raj" <Raj@discussions.microsoft.com> wrote in message
news:B64E1966-BAFF-4115-A0D6-BDC8FAA395A4@microsoft.com...
> Is there a way to retain the HTTP headers in biztalk when receiving the

messages through the HTTP Adapter?
> Also can I add custom HTTP headers before sending the message?
> Thanks
> Raj
>



paul

2004-12-20, 5:48 pm

Here's a link to the definition for InboundHttpHeaders:

http://msdn.microsoft.com/library/d...t_file_gvaa.asp

Still clueless... I hope someone can help me out here.


Matt Milner

2004-12-21, 2:50 am

That code is for an orchestration. In a pipeline, access the context
properties of the IBaseMessage to get this value using the name and
namespace. This should give you a string with all of the values as
described in the article.

matt


"paul" <boloh77@hotmail.com> wrote in message
news:efquFxr5EHA.3120@TK2MSFTNGP12.phx.gbl...
> Hey all
>
> Is it true that I can access an HTTP header from a custom pipeline while
> using the BTSHTTPReceive.dll as the HTTP adapter?
>
> I saw an extremely brief pseudo-code by Matt Milner that suggests the
> above can be done as follows:
> MyStringVar = MyinboundMessage(Http.InboundHttpHeaders);
>
>
> If this is correct, what is the type of MyinboundMessage? Is it
> IBaseMessage? Because I've tried it and it doesn't work. Is there an
> example somewehere out there on this????
>
> Below is a paste of the original conversation regarding this issue:
>
>
> ========================================
=====================================
>
>
> See this hotfix for info on setting custom http headers:
>
> http://support.microsoft.com/defaul...kb;en-us;841994
>
> In order to retrieve headers, you can use the context property
> (Http.InboundHttpHeaders) to get at them:
>
> MyStringVar = MyinboundMessage(Http.InboundHttpHeaders);
>
> .... do something with the string to get the header you want.
>
> Matt
>
>
> "Raj" <Raj@discussions.microsoft.com> wrote in message
> news:B64E1966-BAFF-4115-A0D6-BDC8FAA395A4@microsoft.com...
> messages through the HTTP Adapter?
>
>



paul

2004-12-21, 5:51 pm

Hi there

Thanks for the reply! I've made some progress thanks to your advice. There
is still one wrinkle left for me to iron out however.

On the CLIENT side, I added the following header info to my HTTPWebRequest:

HttpWebRequest request = (HttpWebRequest)
HttpWebRequest.Create(requestLocation);
request.Method = "POST";

NameValueCollection colHeader = new NameValueCollection();
colHeader.Add("myName", "My Name");
colHeader.Add("myTitle", "My Title");
colHeader.Add("mySource", "my.source.com");
colHeader.Add("myPort", "80");

int iCount = colHeader.Count;

for(int i=0; i<iCount; i++)
{
request.Headers.Add(colHeader.Keys[i], colHeader[i]);
}

request.ContentType="application/x-www-form-urlencoded";
request.ContentLength = xmlDocument.OuterXml.Length;


On the BIZTALK side inside the custom pipeline I have the following code to
access the header:

private IBaseMessage ExecuteInternal(IPipelineContext pContext, IBaseMessage
pInMsg)
{
...

IBaseMessageContext myContext = pInMsg.Context;
uint propCount = myContext.CountProperties; // get the number of
properties

string[] propName = new string[propCount];
string[] propNamespace = new string[propCount];
object[] propObj = new Object[propCount];

// cycle through each context property and store the property's name and
values via LogEvent(...)
for(int i=0; i<myContext.CountProperties; i++)
{
myContext.ReadAt(i, out propName[i], out propNamespace[i]);
propObj[i] = myContext.Read(propName[i], propNamespace[i]);
}

...
}


Here's the thing, when I look at the content of the header through
probObj[i].ToString(), all I get is the following:
Connection: Keep-Alive
Content-Length: 12845
Content-Type: application/x-www-form-urlencoded
E

I don't see the additional information regarding myName, myTitle, mySource,
and myPort. Anybody know why this is the case? What am I missing? (maybe
you know Matt?)

Thanks,
Paul


paul

2004-12-21, 5:51 pm

Please ignore the LogEvent(...) mention I made




"paul" <boloh77@hotmail.com> wrote in message
news:e5hUVE45EHA.3648@TK2MSFTNGP11.phx.gbl...
> Hi there
>
> Thanks for the reply! I've made some progress thanks to your advice.
> There is still one wrinkle left for me to iron out however.
>
> On the CLIENT side, I added the following header info to my
> HTTPWebRequest:
>
> HttpWebRequest request = (HttpWebRequest)
> HttpWebRequest.Create(requestLocation);
> request.Method = "POST";
>
> NameValueCollection colHeader = new NameValueCollection();
> colHeader.Add("myName", "My Name");
> colHeader.Add("myTitle", "My Title");
> colHeader.Add("mySource", "my.source.com");
> colHeader.Add("myPort", "80");
>
> int iCount = colHeader.Count;
>
> for(int i=0; i<iCount; i++)
> {
> request.Headers.Add(colHeader.Keys[i], colHeader[i]);
> }
>
> request.ContentType="application/x-www-form-urlencoded";
> request.ContentLength = xmlDocument.OuterXml.Length;
>
>
> On the BIZTALK side inside the custom pipeline I have the following code
> to access the header:
>
> private IBaseMessage ExecuteInternal(IPipelineContext pContext,
> IBaseMessage pInMsg)
> {
> ...
>
> IBaseMessageContext myContext = pInMsg.Context;
> uint propCount = myContext.CountProperties; // get the number of
> properties
>
> string[] propName = new string[propCount];
> string[] propNamespace = new string[propCount];
> object[] propObj = new Object[propCount];
>
> // cycle through each context property and store the property's name and
> values via LogEvent(...)
> for(int i=0; i<myContext.CountProperties; i++)
> {
> myContext.ReadAt(i, out propName[i], out propNamespace[i]);
> propObj[i] = myContext.Read(propName[i], propNamespace[i]);
> }
>
> ...
> }
>
>
> Here's the thing, when I look at the content of the header through
> probObj[i].ToString(), all I get is the following:
> Connection: Keep-Alive
> Content-Length: 12845
> Content-Type: application/x-www-form-urlencoded
> E
>
> I don't see the additional information regarding myName, myTitle,
> mySource, and myPort. Anybody know why this is the case? What am I
> missing? (maybe you know Matt?)
>
> Thanks,
> Paul
>
>



paul

2004-12-21, 5:51 pm

I am beginning to suspect that it is not possible to access custom header
information from within the Biztalk pipeline after all.

I took the same message I used for HTTP Post (with the additional custom
header info) and posted it to a standard .NET HTTP Server written in C#. Lo
and behold, those custom header info got through to the HTTP server.

It seems rather silly that the Biztalk HTTP adapter does not allow custom
header information to be passed over into the message context. I certainly
hope this isn't the case, becaues it seems like an overkill to write a
custom Biztalk HTTP adapter JUST so that I can access those custom header
information inside my custom pipeline.

Can someone please tell me whether this is the case or not?

Thanks,
Paul


Matt Milner

2004-12-23, 2:46 am

Did you apply the hotfix that allows you to get at these custom headers when
using the HTTP adpater? I believe ther is a post out on the
support.microsoft.com site that has information on the download. Sorry, I
thought you were referending that posting in your previous remarks, but I
think it was some other listing you were referring to.

Matt


"paul" <boloh77@hotmail.com> wrote in message
news:ec0Y1g65EHA.3612@TK2MSFTNGP14.phx.gbl...
>I am beginning to suspect that it is not possible to access custom header
>information from within the Biztalk pipeline after all.
>
> I took the same message I used for HTTP Post (with the additional custom
> header info) and posted it to a standard .NET HTTP Server written in C#.
> Lo and behold, those custom header info got through to the HTTP server.
>
> It seems rather silly that the Biztalk HTTP adapter does not allow custom
> header information to be passed over into the message context. I
> certainly hope this isn't the case, becaues it seems like an overkill to
> write a custom Biztalk HTTP adapter JUST so that I can access those custom
> header information inside my custom pipeline.
>
> Can someone please tell me whether this is the case or not?
>
> Thanks,
> Paul
>



paul

2004-12-23, 5:51 pm

Bingo! That's exactly what I need. Thanks Matt.


"Matt Milner" <matt.milner@m3technologypartners dot com> wrote in message
news:OU51G7K6EHA.1260@TK2MSFTNGP12.phx.gbl...
> Did you apply the hotfix that allows you to get at these custom headers
> when using the HTTP adpater? I believe ther is a post out on the
> support.microsoft.com site that has information on the download. Sorry, I
> thought you were referending that posting in your previous remarks, but I
> think it was some other listing you were referring to.
>
> Matt
>
>
> "paul" <boloh77@hotmail.com> wrote in message
> news:ec0Y1g65EHA.3612@TK2MSFTNGP14.phx.gbl...
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com