|
Home > Archive > BizTalk Server Framework > September 2005 > How Do I Promote Context Properties from Within an Adapater
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 |
How Do I Promote Context Properties from Within an Adapater
|
|
| Jim Lavin 2005-09-14, 8:49 pm |
| I have created an adapter based on th Adapter Wizard and I'd like to promote
a couple of context properties based on the message received.
I have created a Property Schema and set each of the properties to
MessageContextPropertyBase and have modified the stock function Create
Message as follows:
IBaseMessage ConstructMessage(SOAPIntermediaryMsgCont
ext msgContext,
SOAPIntermediaryReceiveEndpoint ep)
{
// Create a new message...
IBaseMessage msg = this._TransportProxy.GetMessageFactory().CreateMessage();
IBaseMessagePart body =
this._TransportProxy.GetMessageFactory().CreateMessagePart();
msg.AddPart("Body", body, true);
// Attach the request stream to the message body part...
msg.BodyPart.Data = msgContext.MsgDataStreamIn;
// Get the content type and stamp on the message context...
msg.BodyPart.ContentType = msgContext.ContentType;
msg.BodyPart.Charset = msgContext.CharSet;
// Promote the InboundTransportLocation and InboundTransportType
msg.Context. Promote(InboundTransportLocationProperty
.Name.Name,
InboundTransportLocationProperty.Name.Namespace, msgContext.Uri);
msg.Context.Promote(InboundTransportTypeProperty.Name.Name,
InboundTransportTypeProperty.Name.Namespace, this.PROTOCOL);
// promote additional properties for this message
msg.Context.Promote("Action", "http://foo.com/BizTalk/Adapter",
msgContext.Action);
msg.Context.Promote("To", "http://foo.com/BizTalk/Adapter", msgContext.To);
msg.Context.Promote("From", "http://foo.com/BizTalk/Adapter",
msgContext.From);
msg.Context.Promote("FromVia", "http://foo.com/BizTalk/Adapter",
msgContext.FromVia);
msg.Context.Promote("ReplyTo", "http://foo.com/BizTalk/Adapter",
msgContext.ReplyTo);
msg.Context.Promote("ReplyToVia", "http://foo.com/BizTalk/Adapter",
msgContext.ReplyToVia);
return msg;
}
Everything seems to work okay until my code calls the function
SubmitRequestMessage in the function ProcessRequestResponse. I get the
following exception:
Base Adapter: Info: StandardRequestResponseHandler.SubmitRequestMessage()
called
A first chance exception of type 'System.ArgumentException' occurred in
microsoft.samples.biztalk.adapters.baseadapter.dll
Additional information: The parameter is incorrect.
I am assuming this has to do with the fact that it does not like me
promoting properties. I've looked for examples of how to promote properties
from within the adapter and hav enot seen any real good examples. Has anyone
done this before and if so, do you have any hints or ideas on how to get it
done.
Thanks
| |
| Jim Lavin 2005-09-15, 8:52 pm |
| All,
I solved this finally. Knowing the difference between promote and write when
it comes to a context property makes a big deal.
So my question to everyone is as follows:
When does one choose to use Context.Promote over Context.Write?
I have come to the conclusion that if you are working with a message that
does not have a data schema, but has a property schema you should use
Context.Write to set the values in the property schema. If you have a
message that has a data schema and has a property schema, you should use
Context.Promote to promote the data values from the data schema to the
property schema.
Is this correct?
"Jim Lavin" <jamesjoseph.lavin@eds.com> wrote in message
news:ulfba8XuFHA.3932@TK2MSFTNGP15.phx.gbl...
>I have created an adapter based on th Adapter Wizard and I'd like to
>promote a couple of context properties based on the message received.
>
> I have created a Property Schema and set each of the properties to
> MessageContextPropertyBase and have modified the stock function Create
> Message as follows:
>
> IBaseMessage ConstructMessage(SOAPIntermediaryMsgCont
ext msgContext,
> SOAPIntermediaryReceiveEndpoint ep)
>
> {
>
> // Create a new message...
>
> IBaseMessage msg =
> this._TransportProxy.GetMessageFactory().CreateMessage();
>
> IBaseMessagePart body =
> this._TransportProxy.GetMessageFactory().CreateMessagePart();
>
> msg.AddPart("Body", body, true);
>
> // Attach the request stream to the message body part...
>
> msg.BodyPart.Data = msgContext.MsgDataStreamIn;
>
> // Get the content type and stamp on the message context...
>
> msg.BodyPart.ContentType = msgContext.ContentType;
>
> msg.BodyPart.Charset = msgContext.CharSet;
>
> // Promote the InboundTransportLocation and InboundTransportType
>
> msg.Context. Promote(InboundTransportLocationProperty
.Name.Name,
> InboundTransportLocationProperty.Name.Namespace, msgContext.Uri);
>
> msg.Context.Promote(InboundTransportTypeProperty.Name.Name,
> InboundTransportTypeProperty.Name.Namespace, this.PROTOCOL);
>
> // promote additional properties for this message
>
> msg.Context.Promote("Action", "http://foo.com/BizTalk/Adapter",
> msgContext.Action);
>
> msg.Context.Promote("To", "http://foo.com/BizTalk/Adapter",
> msgContext.To);
>
> msg.Context.Promote("From", "http://foo.com/BizTalk/Adapter",
> msgContext.From);
>
> msg.Context.Promote("FromVia", "http://foo.com/BizTalk/Adapter",
> msgContext.FromVia);
>
> msg.Context.Promote("ReplyTo", "http://foo.com/BizTalk/Adapter",
> msgContext.ReplyTo);
>
> msg.Context.Promote("ReplyToVia", "http://foo.com/BizTalk/Adapter",
> msgContext.ReplyToVia);
>
> return msg;
>
> }
>
> Everything seems to work okay until my code calls the function
> SubmitRequestMessage in the function ProcessRequestResponse. I get the
> following exception:
>
> Base Adapter: Info: StandardRequestResponseHandler.SubmitRequestMessage()
> called
> A first chance exception of type 'System.ArgumentException' occurred in
> microsoft.samples.biztalk.adapters.baseadapter.dll
>
> Additional information: The parameter is incorrect.
>
> I am assuming this has to do with the fact that it does not like me
> promoting properties. I've looked for examples of how to promote
> properties from within the adapter and hav enot seen any real good
> examples. Has anyone done this before and if so, do you have any hints or
> ideas on how to get it done.
>
> Thanks
>
>
|
|
|
|
|