How Do I Promote Context Properties from Within an Adapater
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > BizTalk Server > BizTalk Server Framework > How Do I Promote Context Properties from Within an Adapater




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How Do I Promote Context Properties from Within an Adapater  
Jim Lavin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-15-05 01:49 AM

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







[ Post a follow-up to this message ]



    Re: How Do I Promote Context Properties from Within an Adapater  
Jim Lavin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-16-05 01:52 AM

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
>
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:50 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register