Is there a way to do the service inference on a workflow definition XAML to create an interface that can be distributed to the client to be used with ChannelFactory instead of the host exposing WSDL and the client having to generate a service definition by adding a service reference?
I did this in a three step process:
Temporarily exposing the metadata from the workflow service
Creating proxy code with svcutil
Changing configuration back to not exposing metadata
In detail:
Include your XAMLX file which defines the service in a project that was created as "WCF Workflow Service Application" (DeclarativeServiceLibrary1)
Compile the project
Set the project as startup project
Select xamlx file in Solution Explorer
Press Ctrl-F5 -> WCF Test Client starts, you see your service loaded
RightClick on the xamlx URL in WCF Test Client, choose Copy address (e.g. http://localhost:56326/Service1.xamlx)
Open a VS2010 Admin console window
Create the proxy code with svcutil.exe:
cd /D %TEMP%
svcutil http://localhost:56326/Service1.xamlx
This creates two files, a *.cs and a *.config, that contain the proxy code
I had a lot of problems with other ways of craeting the proxy code (inside VS2010), the external svcutil was the most stable way to do it. Hope this helps.
Related
I was trying to copy the functionality of an existing WCF service library to use it as a template for a new WCF service library. Since I was going to cut and paste all the code that I needed, and I didn't want it to create the default service stubs, I didn't start it by using the built-in "WCF Service Library" project template. I just added a new blank project to my solution, using the "Empty Project" template.
I then created two new blank .cs code files to my project to hold the interface and class for my service, and copied/pasted the Interface and Class code from my original WCF service library project, and made the alterations that I needed to make.
The new project compiles fine, however...
1) If I go into the project properties, the "WCF Options" section does not appear, as it does in my original WCF service library.
2) With the original WCF service libary project, I could right-click on it and select Debug->Start New Instance, and it would automatically start it using WCF Service Host. With the new project, if I try that, it says, "A project with an Output Type of Class Library cannot be started directly".
How do I get Visual Studio (I'm using 2012 Professional) to see this project as a true WCF class library, short of starting over and using the "WCF Service Library" project template?
You are missing the ProjectExtensions section from your project file
This is from one of my VS2010 projects.
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
<WcfProjectProperties>
<AutoStart>True</AutoStart>
</WcfProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
If I remove it, the WCF Options properties section goes away.
EDIT:
I did a comparison of an Empty project to a WCF Service Library, and found that you also need to add this to your project to get the WCF Options to appear in the project properties
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
There is another entry in WCF (and not in the Empty project)
<StartArguments>/client:"WcfTestClient.exe"</StartArguments>
which I'm assuming is needed when you do the
Debug->Start New Instance
There is other stuff that you will need however, such as a reference to System.ServiceModel.
To be honest, I think you'd be better off using the proper WCF Service Library template and cutting out stuff you don't want, rather than trying to figure out what you do need.
I added wcf service (exposed by biztalk) proxy and app.config file in VS 2005 class library project and i am calling this class library methods from windows application. In this case getting error while creating service instance, so i moved app.config file from class library to window applcation, now working fine.
Question: If i will change service url from machine001 to machine002 in config file (from bin folder but not from application) and run the app from exe file. Will it work without build.
Class library configuration always depends on configuration file (web.config / app.config) of parent application that is really using it. And Parent application should be a console / winform / ASP.NET application and can be a windows service. Any change in WinForm's app.config will change the behavior of your class library.
To Answer your question, Yes if you change service url from machine001 to machine002 in config file of windows application it will work if machine002 is hosting the WCF service.
Hope it clears your doubt.
How do I create a client programatically?
Open Visual Studio command prompt and move to client application folder using change directory command and type
svcutil.exe http://your_service_url/your_service_name.svc?wsdl
This will generate a configuration file (output.config) and a client class.
Client class name will be your_service_nameClient
Next you need to copy the <system.serviceModel> section from output.config to your App/Web config. Now your client application is ready to consume the service.
You can create client class object and invoke service methods.
Hope this will help you
You'll need to start the svcutil.exe process -- it could be done from a program, but it will generate source code, not binary code.
If you are new to WCF check out this site:
http://msdn.microsoft.com/en-us/netframework/dd939784.aspx
If you are only interested in learning how to create a client, this is the video for you:
http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-WCF-Client/
I have 4 services running via a service host project, which communicate fine with my asp.net application when the ASP.NET development server hosts them through VS for debugging.
I am trying to deploy these to IIS on a windows server 2008 machine, using WAS.
I have the project set up as an application in IIS, and have copied the entire config section from app.config in servicehost project to web.config of the IIS site.
After a few compliation issues, I now get a directory listing when i navigate to http://localhost:8000/Services
I have also created a Service.svc file, which contains
<%#ServiceHost Service=MyApp.AddressService %>
When I navigate to localhost:8000/Services/AddressService, I get a message that i've created a service, and appending ?wsdl gives me the xml to create a client.
Problem is, I get an error when I try to add any more services to the .svc file.
Should I be using service.svc to configure multiple services, or is there a different way using WAS?
How can I expose my other three services through the same application?
Thank you!
You cannot add multiple service to a SVC file. One SVC file = one service class. No way to change that.
However: you can definitely implement multiple service interfaces on your service class:
public class YourService : IService1, IService2, IService3
{
...
}
and then you have one SVC file = one service (implementation) class = 3 service contracts.
In .NET 4 / WCF 4, you'll be able to define URL's for service in your web.config, and you don't need the SVC files anymore.
See this blog post here or this one here for more info, if .NET 4 is an option for you.
I have an old WSDL file and I want to create a server based on this WSDL file.
The WSDL is generated from a ASMX (I suppose but I am not sure).
How can I achieve this ?
original question where the OP thought he needed to create a client based on the WSDL.
Using svcutil, you can create interfaces and classes (data contracts) from the WSDL.
svcutil your.wsdl (or svcutil your.wsdl /l:vb if you want Visual Basic)
This will create a file called "your.cs" in C# (or "your.vb" in VB.NET) which contains all the necessary items.
Now, you need to create a class "MyService" which will implement the service interface (IServiceInterface) - or the several service interfaces - and this is your server instance.
Now a class by itself doesn't really help yet - you'll need to host the service somewhere. You need to either create your own ServiceHost instance which hosts the service, configure endpoints and so forth - or you can host your service inside IIS.
There are good resources out there if you know what to search for. Try "Contract First" and WCF. or "WSDL First" and WCF.
Here is a selection:
Basic overview of WSDL-First development with WCF and SvcUtil.exe.
WSCF - A free add-in to Visual Studio enabling Contract-First design with WCF
Introduction to WSCF
A walkthrough of using WSCF
The WSCF project page on CodePlex (WSCF is now open source)
Article on how to design "WCF-Friendly" WSDL
Use svcutil.exe with the /sc switch to generate the WCF contracts. This will create a code file that you can add to your project. It will contain all interfaces and data types you need to create your service. Change the output location using the /o switch, or you can find the file in the folder where you ran svcutil.exe. The default language is C# but I think (I've never tried it) you should be able to change this using /l:vb.
svcutil /sc "WSDL file path"
If your WSDL has any supporting XSD files pass those in as arguments after the WSDL.
svcutil /sc "WSDL file path" "XSD 1 file path" "XSD 2 file path" ... "XSD n file path"
Then create a new class that is your service and implement the contract interface you just created.
You could use svcutil.exe to generate client code. This would include the definition of the service contract and any data contracts and fault contracts required.
Then, simply delete the client code: classes that implement the service contracts. You'll then need to implement them yourself, in your service.
Using the "Add Service Reference" tool in Visual Studio, you can insert the address as:
file:///path/to/wsdl/file.wsdl
And it will load properly.