I am attempting to add a WCF web service to my project and each time I add a new web service it adds a new Service Behavior, new Service configuration, and changes the formatting of my web.config.
Is it possible to add a new WCF Web service (.svc extension) to my project without it changing my web.config file? I am willing to add the information I need manually.
Yes, the behavior of the Add Service Reference part in Visual Studio is a major PIA - and it's not been improved a single iota in VS 2010, unfortunately :-((
And even more unfortunate, you cannot really tell the importer to leave your existing stuff alone - what I do is create a backup of my web.config, import the WCF service and let the importer mess up my web.config, and then I just slap my backup over the mess again and go about making the necessary additions manually.
One alternative is to use svcutil.exe on the command line - first of all, you can tell it to /noconfig and skip messing with your config (or you can output the recommend config into a separate config with a different name), and secondly, it'll happily create your client-side proxy service class in a C# or VB.NET file for you, ready to use.
But yes - of course you can add all the necessary information by hand!
In a typical client side config, the most important point is the <client> tag - just add whatever it is you need - using the "ABC of WCF" - (A)ddress, (B)inding, (C)ontract:
<client>
<endpoint name="something-useful"
address="your-address-on-the-server"
binding="wsHttpBinding" -- or whatever it is you're using
contract="IYourServiceContract" />
That's the minimal client-side config you need. Anything else is just additional stuff, used when needed. This uses all the default settings for your binding, obviously.
Here are two really good videos that show how to do a lot of manual WCF configuration - sounds scary, turns out to be much easier than deciphering the mess the VS importer creates....
DotNet Rocks TV Show #122: Miguel Castro on Extreme WCF
DotNet Rocks TV Show #135: Keith Elder Demystifies WCF
Related
I would like to split my .NET Core web application into multiple layers:
UI
API
Logic/Domain
Data
...
All of them seem clear enough apart from (1). Is it possible to create a simple web site which consumes the API layer? When I mean simple I mean that I do not think it needs .NET Core, just client side libraries such as Bootstrap/Angular.
I can create a simple project like this outside of VS easily, but I want it as part of my project, when I go to New Project all I see is:
What is the correct approach to take here?
Just want to ask you to confirm that I'm right (but may be totally wrong :).
Situation: I have a VS2010 Solution with 3 projects A) WCF Library, B) Web Site that host this library C) test application that use the web service. Last I could configure two different ways: adding reference to the WCF Lib or Web Site.
I've discovered that when I'm referencing WCF library directly (some may be remember those endpoints http://localhost:8732/Design_Time_Addresses/...) the configuration of custom servicehostfactory in app.config element
<serviceHostingEnvironment><serviceActivations>..
is ignored.
Since interpretation of serviceHostingEnvironment is responsibility of the host I make an assumption that VS2010 WCF Library Host have such feature - ignore serviceHostingEnvironment? Am I right?
P.S. May be I could ask you to point me the doc where I could find the information about VS2010 WCF library's host.. It seems I should get to know better.
Description of test service host is here. ServiceHostingEnvironment element controls integration with web server = I don't think that any part of this configuration section is used for self hosted services and test host is self hosting.
ServiceActivations element contains file-less activation configuration for web server. That means ability to activate service without physical existence of hosting .svc file. That is something which doesn't make sense in self hosted scenario.
I use VS2008, .net 3.5.
There is an external Web Service (it is PHP implementation, but dont mind implementation -.net, java, php,...-).
In my project csproj, I want add Service Reference to WebService and I want use WCF.
When I add Service Reference in VS2008, WCF proxy is created.
Any best practices (patterns and practices) for add service reference (external service) ?
The WCF Proxy Generator (I think the same svcutil command) generates source code like this. Perhaps it will be interesting manages the code generated (ServiceContractAttribute Namespace="http://192.168.50.63/WebService" use IP address, and OperationContractAttribute(Action="http://devservername/webservice/SmoBridge.php/login" use servername).
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://192.168.50.63/WebService", ConfigurationName="ServiceEasyVista.WebServicePortType")]
public interface WebServicePortType {
[System.ServiceModel.OperationContractAttribute(Action="http://devservername/webservice/SmoBridge.php/login", ReplyAction="*")]
[System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)]
[return: System.ServiceModel.MessageParameterAttribute(Name="return")]
string login(string SESSION_ID, [System.ServiceModel.MessageParameterAttribute(Name="LOGIN")] string LOGIN1, string PASSWORD, string COMPANY_ACCOUNT);
Update:
the Erwyn’s recommendations about the correct closing of a faulted WCF Channel.
http://bloggingabout.net/blogs/erwyn/archive/2006/12/09/WCF-Service-Proxy-Helper.aspx
Why does ClientBase Dispose need to throw on faulted state? (Or, what's the difference between close and abort?)
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/b95b91c7-d498-446c-b38f-ef132989c154/
check this out:
http://www.sanity-free.com/125/php_webservices_and_csharp_dotnet_soap_clients.html
i think that one is sophisticated technique.
Regards,
Mazhar Karimi
I don't know why there would be any particular best practices around adding a reference. Having said that, the "Refresh Reference" command in Visual Studio (right-click on an existing service reference) sometimes doesn't work too well, so it can be easier to use the svcutil command manually, and have a .bat file in your solution that updates the service reference (svcutil is what "Add Service Reference" is using behind the scenes).
Also, if the service you're referencing is returning an array, you can get WCF to automatically turn it into a generic list (or some other type) - this might make things easier.
I created a small VS solution that includes WF with WCF ReceiveActivity project (using basicHttpBinding) and a number of plain C# services. They all work perfectly when tested from VS 2008 using WCFTestClient.
I deployed them into a single Windows Service. All but WF service work fine. I spent 6 hours browsing, but didn’t find a solution that works. Please help.
You should be using the WorkflowServiceHost instead of the normal ServiceHost. The WorkflowServiceHost does all the usual WCF related stuff but also makes sure a workflow runtime is created and the required workflow routing environment is setup.
See this blog post for how to do so. This second post show a bit more about how to change the configuration.
BTW. In general you should be using the context bindings like the basicHttpContextBinding and wsHttpContextBinding as they pass the context information containing the workflow instanceId with the messages.
My company is looking into writing a custom application that will need to perform many list item queries across multiple site collections. It will need to run for WSS 3.0 and it 'would be nice' if it worked on WSS 2.0 as well. It won't be designed for MOSS/SPS but again it 'would be nice' if it worked on these platforms. There is no restriction on which .NET version should be used for the solution.
For this type of application, what would be better: the object model/API or SharePoint web services? The primary factor I'm considering is performance, followed by features and functionality. Thanks!
Object model is better as you can gain access to additional features and the full detail of the list items, such as the version history.
The object model is also better for performance (as long as you dispose() your spsite and spweb objects properly).
The Sharepoint object model has some differences between 2 and 3, but if you look at the reference for v2 then it will also work fully with v3.
The web services have not changed at all between v2 and v3, which explains why they do not have any new features of v3.
The reason the object model will win on performance is that you will not be serialising the data as Xml and then transmitting a large chunk of Xml, and then deserialising the Xml. The object model spares your memory and bandwidth.
The first thing to consider is "will my code run on a sharepoint server or remotely ?"
If it's running remotely, you don't
have any choice, use web services
If it's running on a sharepoint
server, I would suggest using object
model, as performance will be
better, you'll have access to more
API and authentication will be
easier (=automatic).
+1 to the other posters.
If you decide to go the OM route then you can compile for both WSS 2.0 and WSS 3.0 from the one source. These should get you started.
Developing for Sharepoint 2003 using Visual Studio 2008?
How to reference two versions of an API?
Can the OM be used inside an Infopath form? Currently I'm using the web services to pull in the list data I want but I would rather use the OM.