Peek on MSMQIntegrationBinding - c#

I am attempting to bind to a non-transactional MSMQ queue using MSMQIntegrationBinding. What I want to be able to do is to peek at the message, and then if conditions are right, go ahead and process it. But, if conditions are not right, I want to leave the message on the queue.
I came upon ReceiveContextEnabled=True, but have seen very little documentation or tutorials on how to actually use this. I am hosting the WCF service library through a Windows Service. However, when I open my host, I get an error like:
The contract IWMInTranslator_Service_MSMQ has at least one operation annotated with ReceiveContextEnabledAttribute, but the binding used for the contract endpoint at address msmq.formatname:DIRECT=OS:CCNU404CCH5%5Cprivate$%5Cwmintranslateque does not support required binding property 'IReceiveContextSettings'. Please ensure that the binding used for the contract supports the ReceiveContext capability.
If I change it to a transactional queue it seems to work, but I dont want to do this. Can anybody help? I create my endpoints and bindings via code (not through app.config). If there are some properties somewhere I can change that would be great!
Thanks,
:) David

Related

Configuring Outbound WCF message body with promoted context properties

I have a send port that receives a document with a set of promoted context properties. The adapter on the send port is set as WCF-SQL, and have been configured to connect to the SQL server.
The only part missing is configuring the messages tab, so that the correct message is being sent to the database. Right now I simply have some hardcoded values along with the message itself:
<bizSaveDocument xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo">
<conversationID>547e0702-c0c8-4535-9ab0-fa52b2fdbdd0</conversationID>
<dataType>OIO</dataType>
<fromID></fromID>
<toID></toID>
<msgInfoExtension><![CDATA[<infoExt><fileInfo fileName="ublinvoice.xml" encoding="utf-8" /></infoExt>]]></msgInfoExtension>
<msgBody><bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="string"/></msgBody>
<msgBodyBin></msgBodyBin>
</bizSaveDocument>
I'm unsure how to properly insert my promoted context properties into these elements. To give an idea of where I want to configure this XML, see the screenshow below:

I cannot use the body option, since I need to insert some promoted properties into the database. Looking at the MSDN there seems to be no explanation of how to accomplish this. See this link: https://learn.microsoft.com/en-us/biztalk/core/specifying-the-message-body-for-the-wcf-adapters
For the receiving message, I created a pipeline component which promoted the required properties and works fine.
Is this simply not possible in standard Biztalk? If not, I will need to create an additional pipeline component to handle the sending.
Ah, ok, I see what you're doing....so....don't do it this way.
The best and essentially correct way to handle this is with a normal BizTalk flow with Maps and an Orchestration. Remember, there is nothing wrong with using an Orchestration, if someone is telling you to not use Orchestrations, they are, well, wrong.*
Basically, Map to you SQL Schema using temp values, then set them from the Context using Distinguished fields.
Don't ever bother with the Messages Tab, it's basically hiding code where it should never be.
If they still make you do it some other way, you need to tell your management that this will take you about twice as long to implement because you have to create a anti-pattern that replicates built in functionality.

How can I call a WCF service from a SendAndReceiveReply Activity in WF (.Net 4.5)?

I have a WCF service that is locally created in C# (with a [ServiceContract] and [DataContract]) and uses webHttpBinding for binding.
I would like to invoke "GET" and "POST" operations outlined in the contract from a WF workflow, but I just can't seem to get anything to work. Here are some of the things I've tried (from VisualStudio 2012):
Adding a service reference. I hear this is supposed to create the activities I want (after compiling), but I can only find my service by running it and finding it by address. I cannot "Discover" the service, even if I include the projects for the service in my solution that has the Workflow project. No activities are created as a result.
Importing a service contract. This seems to work a little better, in that I get activities, but I only get ReceiveAndSendReply activities. It doesn't seem to matter whether I make the contract as part of my Workflow project (and import it), or create a normal reference to the service's WCF project (and then import the contract through that reference).
Filling in the fields of the Send and ReceiveReplyForSend components of a SendAndReceiveReply activity directly (this was actually what I tried first). No matter what I try, I always run into a wall with the error, "Manual addressing is enabled on this factory, so all messages sent must be pre-addressed."
This seems like something that should be fundamental to WF and a lot easier, but I'm just not getting it. Am I missing something simple?

How to encapsulate code for WCF services without using a base class?

All of our services take a ServiceCallContext object as a parameter. The service then creates a broker and tells the broker what connection string to use based on the ServiceCallContext.
In other words, some of our customers have their own databases so the service calls have to point the brokers to their databases.
I would like to take the code that looks at the ServiceCallContext and chooses the correct connection and put it in a base service class. My team lead doesn't like that idea because with services he feels that this would be 'hiding' behavior and that this would be a bad thing. He suggested that there may be better ways to accomplish the same thing through some sort of WCF extensions.
I honestly don't care how we implement the code so long as I can reuse it because I think it's absolutely silly for me to be rewriting it in every service I create. I began looking into some WCF videos on PluralSight and it looks like there's a lot of great stuff it can do but unfortunately I'm not quite sure where to start. Can anyone give me a little direction as to whether WCF can accomplish what I'm trying to do and if so what particular features of WCF am I looking for?
The functionality you need is a custom interceptor.
This allows you to tell the WCF stack to look at incoming messages and the do some action based on them. If you wrap the interceptor up into it's own assembly then you can reference it from multiple services.

one-way operations in web service c#

Dear All,,
I need to consume web service and they send me WSDL. I was added it to service reference and when I called method GetDataWarehouse() in WSDL I got error..
"The one-way operation 'SubmitAccessList' on ServiceContract 'DataWarehouseWebService' is configured for transaction flow. Transactions cannot be flowed over one-way operations."
SubmitAccessList is one of method in WSDL but I wonder because I didn`t used it for now..
Can you give me a hint?
Ok, what you use is pretty irrelevant - WDSL is "all or nothing" in that the tool looks at it all, or not at all. You can argue this is a limitation -it is - but in most cases not a relevant one.
What is funny that this looks - never experienced this myself - like an error, as in the provider got a very funny non-legal setup for his web service, which means and hints there is nothing you can do. It seems they implmenent a one way web service.... and the service contract is putting in transactions. BAD combo.... a transaction can not be properly handled without additional communication and feedback to the sender, so the one way paradigm (fire and forget) is not logically compatible.
If noone else has a better ansqwer... I would say contact the web service provider for support (and have them fix their service).
I gladly take a correction on this if anyone has a better idea ;)

WCF Custom Service Behaviour

Context: I am hosting a number of services using WCF. I'd like for each of them to support a Ping operation (heartbeat, keep-alive, whatever...). But, I'd rather not go implement IPingable on each one. Instead, I'd love to do something like the serviceMetadata behavior does and dynamically add a channel dispatcher. This would mean all I'd need to do is add a pingable behvaior to the services and this operation is supported.
Any ideas? I've looked through the the source code of serviceMetadata and there is all kinds of internal stuff being called I don't have access to. Also, there may be an easier way.
Thanks for your time.
If you do it through a behavior, will your metadata indicate that the Ping operation exists?
Just off the top of my head could you add a dispatch behaviour that would handle the call and spoof the return true/false?
I also found the following

Categories