Can BizTalk publish a single one and two way web service? - wcf

I am publishing a WCF service, using schemas not orchestrations, and using the BizTalk 2010 wizard. Some of my methods are one way and others are request/response. I finished the wizard successfully, published the services (hosted in IIS) and things were going fine until I went to import the bindings to my app.
There is only one Port, and one receive location connected to it, and its URI is something like /BizService.FTW/BizService.svc. The receive Port is marked as two way, so I can't bind my orchestrations that are one way to it. You cant have two receive locations pointed to the same URI, so my question is this; did the Wizard pull a fast one on me or is there a way to publish one and two way methods in a single service? If there is no way(using the wizard to do it) can I at least have two services (say at /BizService.FTW/BizService.svc and /BizService.FTW/BizServiceRR.svc ) coming from the same Web App?

Yes, but BizService and BizServiceRR would be two separate 'services'.
However, for the one-way Orchestration, did you consider Direct Binding and setting up a Filter for that particular message type?

I'll recommend you publishing two biztalk services (one-way and two-way ones). And build a WCF service, that will route requests to Bzt. services, based on request schema.

Related

What is the code created by the BizTalk WCF Service Publishing Wizard?

We have exposed a BizTalk Schema as a WCF service for a third party vendor so that they can push messages onto our ESB. The WCF service has a single function which accepts and returns messages of that schema type. The issue is that if a response is not made in a timely manner or another message e.g. an error is generated by the ESB the third party app fails/crashes.
It doesn't really matter what is in the message as long as it is in the correct format and the data in the returned message is not used by the vendor or ourselves. The vendor also supplies its own WCF service which we can use to pass back messages should we wish to do so. I would like to modify the existing WCF service or manually create an new one which immediately returns a response but also passes the message onto the ESB for further processing.
I have created an interface from the WSDL using svcutil but cannot find any code examples of how manually create a WCF service to expose a BizTalk schema. All examples point to the wizard.
What is the code that the wizard creates? Is there an example? Thank you.
EDIT 23/08/2013
So it would appear that changing a wcf service created by the wizard is not an option nor is creating a new service manually. I have tried creating an orchestration which consumes the service and sends a response then binding that to the same receive port which works if the itinerary works but doesn't run if there is an error. Plus it only runs after the itinerary is complete which is no good. I need an immediate response.
You can change a wcf service created by the wizard, but it is generally better to use the Wizard to re-publish it using the below from the command line.
BtsWcfServicePublishingWizard -WcfServiceDescription=C:\..\WcfServiceDescription.xml
The WcfServiceDescription.xml will be under under the folder where you published the web service in \App_Data\Temp\ e.g. C:\Inetpub\wwwroot\BizTalkWcfService\App_Data\Temp\WcfServiceDescription.xml
Keeping a copy of this xml file in your source control is a good idea. Running the wizard against the one under the web service is not a good idea as it deletes and re-creates everything in the folder and so you might manage to corrupt it, so copy it out first and run against the copy.

WCF central service with multiple clients

i can't find any good architecture explanation of how can WCF SHOULD be part of a main-server with multiple clients.
in my solution, i want to have a central WCF service (hosted in windows-service on windows server machine).
The central service is the only one that's connected to the DB.
all the clients, are connecting to this main service, login, and get having a duplex communication.
via that main service, one client can connect another one. or when one client using the main service to change the DB, the main service updates all other clients.
for doing that, i added in the main service the InstanceContextMode.Single attribute, and in the windows-service, i init ServiceHost with the WCF-service singleton.
it works. so so..
i can continue and search where the problems are, and how to fix them, but it looks like something here is not right, like i'm not supposed to do it this way.
i could really use an advice on how WCF service should be used as a main service with multiple clients, that require common memory.
it's basically for ~20 clients with not too intensive operations, but i still want the option to let them all communicate simultaneously with the main service, and not only one by one.

Improving performance of WCF services working with real time data

In my application I need to push notifications of real time events from server to clients. The amount of data to pass is very small, mostly and Id. The number of clients listening simultaneously can be around 100 and I may have to publish one notification every 2 - 3 seconds. Both the server and client are built using .Net and WCF.
Given these requirements I have built a set of WCF services which will be run on a load balanced server cluster. The Instance context mode is Per Call and there is no need for sessions etc.
I am currently using BasicHttpBinding. Will TCP binding be better? Does it run on IIS 5 or 6? If not why?
What configuration for serialization can work best?
What are the things I need to do to make sure I get maximum performance?
Edit - Adding more information based on some of the responses -
I host a small WCF service in the client process using manual hosting. The server just calls this service on each client to push the data to all of them.
Firstly have you considered using messaging for what you are trying to achieve?
In answer to will TCP binding work better than BasicHttpBinding- almost certainly yes. If you want to use TCP, you can't use IIS- look into WAS with Windows Server 2008. If you're stuck with Windows Server 2003, then you'll have to host in a windows service instead.
You've made a good choice by choosing per call- this is the preferred instance management mode for creating scalable WCF services.
Edit:
Now you've update your question, I recommend you take a look at IDesign's Pub/Sub framework if you want to stick with WCF. I'd also look at Pub/Sub with MSMQ in WCF and also with "Vanilla" products such as Tibco RV.
If you need pushing data from service to clients you need sessions and you need duplex binding - NetTcpBinding or WSDualHttpBinding. It will not work with BasicHttpBinding because it allows only pulling data (client pools the service for changes). Push data means tha service sends data to clients when needed.
NetTcpBinding always crete session. It can't be hosted in IIS 6 or older. NetTcpBinding is allowed only in Windows Activation Service (WAS) which is extension of IIS 7.x. For older systems you need self hosting = windows service.
Edit:
Based on your description you need Publish-Subscribe message exchange pattern.

Under what circumstances does it make sense to run a WCF client and server on the same machine?

In Learning WCF, by Michele Bustamante, there is a section that describes a binding called the NetNamedPipes binding. The book says that this binding can only be used for WCF services that will be called exclusively from the same machine.
Under what circumstances would it make sense to use this? Ordinarily, I would write asynchronous code without using WCF... Why would Microsoft provide something for WCF that can only run on the same machine?
Look at it from the other direction. Once the service is built, you can run in in a variety of binding configurations. If it was a remote machine, you could use the HTTP or TCP bindings. Or, the service happened to be running on the same box, you have those options plus the named pipes option. The named pipes is just another option that is provided just in case you are running locally, but you should be able to switch to a different binding if you are running remote.
Yu could start with everything on the same box because you have less traffic, and use named pipes because it was the shortest path to the service. Then, if load demanded it, you can move the service to another box, and then change it to use TCP or HTTP instead.
You probably won't have a service that exposes only a NetNamedPipe endpoint - that doesn't make a lot of sense. But if you run your WCF service on a server, exposing service endpoints out to the world using the usual bindings, and you need e.g. a management or admin console or something like that, running on that same machine, it can make sense to use the NetNamedPipe binding since it's the fastest around.
Another possible scenario that I learned about is having an error collection service - any error or exception that happens is sent to a service to be logged. Again: that service would probably expose several types of endpoints, but if you have other services running on the same server, using NetNamedPipe binding to connect these two services makes a lot of sense.
I don't think you'll use the NetNamedPipe binding an awful lot in your WCF days - but it can definitely make sense in some cases and be quite useful in such specialized scenarios.

Consuming a WCF service in BizTalk 2006 R2

I'm trying to figure out how to consume a WCF service in BizTalk 2006 R2 (sending a request and receiving a response).
I've gotten as far as going through the "Add Generated Items" wizard. Now I am trying to find out how to use the items it generated in an orchestration.
How should the request be made?
Below is a description of how to do this - I'm going to presume at least basic knowledge of things like BizTalk mapping, please let me know if you need any more detail and I'll update.
After generating the items in BizTalk you should have (at the least):
An orchestration file with Messages and Port Types created
A schema that describes the messages you send and receive from and to your WCF service
A .Binding.xml file that describes the service contract exposed by the WCF service and allows easy configuration in BizTalk
Open the orchestration file. This should be empty.
Drag a Port from the toolbox onto the orchestration designer surface.
Name the port appropriately.
Select "Use an existing Port Type" - one of the existing port types will be your WCF service (created by the Add Generated Items wizard)
Specify that you will be sending and receiving messages
Specify Bind Later
This port should have Request and Response operation messages and they should have been automatically configured to use the messages for your WCF service. If your service exposes multiple operations, you will see that reflected here.
Using standard BizTalk mapping methods, map the data you want to send to the WCF service into the request message for the WCf port. (you may want the change the message names in the orchestration designer to be something better than the default message_1, message_2...)
Drag Receive and Send shapes onto the orchestration designer and connect them to the right Port messages.
Wire up the rest of the BizTalk orchestration to take data from appropriate source systems (this is just basic BizTalk, not WCF)
Deploy the BizTalk application.
The application is now ready to go, you can deploy it to BizTalk.
Configure the BizTalk application
Open the BizTalk Server 2006 Administration Console and find the application containing the orchestration you just deployed.
The orchestraion will be unenlisted, you need to bind all of its ports
For most of the ports this is just like any other BizTalk application - only the ports that deal with the WCF service differ.
For the WCF ports you have (at least to begin with) two main options:
Import the bindings file made by the BizTalk Generate Items wizard (right click on the applicaiton and import - navigate to the .xml binding file) - Perhaps advisable until you have an idea of how Biztalk represents all the WCF binding options.
Configure your own WCF send port.
For this the port needs to be Solicit-Response to match the WCF service.
Choose one of the WCF Send Port types to match the binding type of your WCF service.
To begin with (for a basic Webservice) this will often be WCF-BasicHttp.
Once you have the basics working you might want to return here and experiment with the options available in the Custom binding - there is a LOT there!
Configure the send port.
In the general tab enter the url where the .svc file is specified
e.g. http://localhost/WCF/myservice.svc
Set the Action to match the action specified in the WCF service .wsdl file
e.g. http://tempuri.org/IMyContract/MyMethod
With your WCF port now created you can bind the orchestration ports to it.
Once all this is done, you should be able to start the BizTalk application and things should work.
One thing that may help - errors will be written to the event log, they may not be helpful, but you should also be able to see any soap fault messages returned from the service in the suspended message view.
Good luck!
BizTalk is overkill if you are just using it to orchestrate WCF services. You can use WCF services in .NET 3.5 inside of Windows Workflow Foundation a bit more easily.
That said, here is a screencast that should help:
http://www.pluralsight.com/community/blogs/aaron/archive/2007/11/15/49172.aspx
Its is very simple as other Service development in BizTalk. Let make it more simpler.
Just Develop you desire Work Flow (Orchestration) and Service.
Open WCF Web publishing Wizard and Check (a) Enable Metadata Endpoint , (b) Create BizTalk Receive Location in the in ur application.
Go to you BizTalk console and Enable the Receive location and Start your Application from Biztalk Console.
Then Browse it from IE or Fire Fox to check that either Service is running or Not.
Now Service has been Develop. Lets do something for its Client.
Go to the Patah "c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\" and Write SVCUTL and your url of your service i.e. c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\svcutil localhost:axix//axx.svx?wsdl, this will copy the two files, one is output.config and other is BizTalkServiceInstance. cut and paste both files to your ciletn and then See you service desp for its consumption.
I Think this is the most simplest which i tried to make.
Thanks
Abdul Aziz Farooqi.