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.
Related
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.
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.
I am new to Biztalk (Stack Overflow as well) I want to receive an xml schema file containing 2 digits and send it to WCF service which will do some arithematic operation on them and give me answer in a file as well. I have tried a lot but unfortunately couldn't succeeded.
What I have done...
I created a service and host it to IIS. It is running fine. I have tested it through (WCFTestClient.exe). Then I have created a biztalk project and Consume WCF Service from generated items. Then I deployed the project. And configured Receive and Send ports accordingly but have no luck.....
I have solved problem myself. Actually I read error message in suspended service messages in Biztalk Administration Console and after some google I was able to solve the issue.
I have a WPF app that uses WCF (duplex netMsmqBinding) to talk to a self-hosted service app in our domain.
I'm now trying to move this WPF app to the big wide world out there, to talk to the WCF service over the internet (well, make them talk to each other).
I've installed MSMQ and created the services on both, and checked queue and firewall permissions. Based on the reading I've found, what I needed to do then is:
1) Enable MSMQ's HTTP addon.
2) specify the binding's useActiveDirectory=false and queueTransferProtocol="Srmp" to ensure that it uses DIRECT to find the private queue.
However I did that and the WPF app receives the error
An error occurred while opening the queue:Unrecognized error
-1072824215 (0xc00e0069). The message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that
the queue is available to open with the required access mode and
authorization.
Which translates to MQ_ERROR_REMOTE_MACHINE_NOT_AVAILABLE.
I can browse to the remote server ok, and the rest services work fine, so I must be missing something with HTTP or the fact that it's self hosting. Any ideas?
MSMQ over HTTP is a push technology (client -> web server).
You cannot open a remote queue and pull messages from it.
I am writing an application that has one Windows Service that needs to communicate with another Windows Service. The "target" service will accept a request from the "source" service and will perform a task. The "source" service will not wait for a response, so the request should return as soon as possible.
The plan was to have the "target" service host a WCF service which the "source" will communicate with. Once the request is received I need to communicate with the host Windows Service to tell it to do the work. I was thinking that the "target" WCF service would put a message on a MSMQ which the "target" Windows service will monitor. Once this is done the WCF service can return back to the caller.
Does this sound like a sensible approach for allowing a WCF service to tell a hosting Windows Service to perform a task?
Kind Regards
Michael
Allow me to disagree. Based simply on what you've described, using MSMQ to communicate between the "target" WCF service and the hosting Windows service seems extremely heavyweight to me. MSMQ allows different processes to communicate in a failsafe manner. In your case, the WCF service is hosted in the same process as the Windows service. Thus, while MSMQ as a commmunication mechanism between the two would work, it's not necessary.
Additionally, using the MSMQ binding between the "target" WCF service and the "source" WCF service makes sense if the two WCF services are not always running at the same time. For example, if the "target" WCF service is not always running, the MSMQ binding would allow the "source" WCF service to still send tasks. These tasks would be stored in the MSMQ to be retrieved when the "target" WCF service begins running. However, it sounds like both services will be running, so I can't see the need for the MSMQ binding.
For selecting WCF bindings, refer to this SO post.
C# - WCF - inter-process communication
Let me address one other thing. When your "target" WCF service receives a task request from the "source," simply communicating the task back to the Windows service is not going to do anything in and of itself. The Windows service is running, yes, but it does not have a thread of execution that you can leverage. The point is that in order to make task processing asynchronous, you'll need to start a thread to manage the task(s). I would suggest leveraging the ThreadPool to do this.
Hope this helps.
Yeah, that is a good approach. MSMQ is perfect for this task - the source service can send a request to the target by putting a message on the queue via WCF. MSMQ is good anytime you want to send a request to a service for asynchronous processing, especially if you don't need to get a response back. If you do need a response, you can setup the source as a WCF service as well, and the target can send a message back if needed. There are several different ways to accomplish this with the MSMQ binding.
#Matt
Thanks for your help.
After thinking about it a bit more and see how your approach would make things easier to setup and use. I need to have the "target" service send the outcome of the work back to the "source", so I will probably use nettcp and use a callback. The plan then is to setup a new thread, do the work and once its finished send a response back to the "source".
#Andy
Thanks for you help.
I took a look at msmq, but seeing as I would probably have to setup a new thread once I receive the message I might as well let the web service do the work.