How to add service to a WCF Service library. Is this correct? - wcf

I am new to WCF and .Net application. So pardon me if I am asking some basic and silly question.
Basically my project is to create a WCF Service that would call an Oracle Stored Procedure that returns a set of parameters which is then passed to the Exchange Server to send Email.
For this so far I have done something like this:
In VS 2010 Create Project; Visual C#; WCF; select WCF Service Library.
Described as "A project for creating a WCF service class library (.dll)".
Gives an app.config
Debug brings up a WCF Service Host and a WCF Test Client automatically.
I initially followed the MSDN sample that is given below in the following website:
http://msdn.microsoft.com/en-us/library/ms731835.aspx
Now I Added another project to the same solution and chose WCF Service Application to host the above in IIS host. This gives me web.config file.
Before I proceed to my next question please let me know if the last step is correct or wrong?
To proceed further I tried to add my implementation service reference in web.config file.
When I try to debug I am getting a Service host that is running seperately (an icon on my machine) and a WCF Test Client opens up as well. Is this correct? Now how do I proceed further? I have no clue..
Now do I create methods that would call the Stored Procedure using Data access?
How do I proceed further? I am stuck. Please help.
Thank you.

You are on right path you just need to call your stored procedue and then call read the data and invoke method and pass it to client.
Here is full example with screenshot for your help
SQL Server
http://www.codeproject.com/Tips/468354/WCF-example-for-inserting-and-displaying-data-from
WCF Data Services and OData for Oracle Database
http://download.oracle.com/oll/obe/EntityFrameworkWCF/WCFEntityFramework.htm
Invoking Operations on the Oracle Database WCF
http://msdn.microsoft.com/en-us/library/dd788075%28v=bts.10%29.aspx

Related

Workflow WCF Service - Can't call from application - The request object expects an argument that I can't identify

I have created a WCF service using Workflow. It works just fine. I created another Workflow application to consume it. I added the service reference to the application project and rebuilt the project. I added the component from the service to the app, but it's expecting an argument that I never specified.
I've tried rebuilding both the service and the app, generating an entirely new solution and starting from scratch - same problem. I've looked at others' code and they've structured this project the same as mine but this issue does not show up on theirs. Googling this problem seems to bring up not results.
My workflow service is defined as such: https://i.imgur.com/E8mEfs6.png
The parameters of the receive component are: https://i.imgur.com/TaNRw2y.png
But when I add it to my app, the parameters are defined as: https://i.imgur.com/tqgEwNr.png
Which is not what I had defined in my service. I can't even figure out what it wants me to pass in for _GetCityStateFromZip. It says the type is InArgument.
I was expecting it to be expecting the zipcode parameter as I specified in the service. I think I might be adding the service reference incorrectly, but I don't know how. I went to Add Service Reference in Visual Studio, then copy/pasted the path to the .xamlx file of the service on localhost.
Thank you.
I found a solution to this problem here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/5279fc5f-8a53-43e7-8ef2-3073808dc90f/configuring-workflow-services-how-to-configure-workflow-control-endpoint?forum=wfprerelease
I re-made my service using the steps listed and it works as originally intended.

Configure SSRS delivery extension for invoking a WCF service

Have created a custom delivery extension in SQL Server Reporting Services (2008 R2). Within the custom delivery I am making a call to a WCF service. Am not sure where to put the app.config settings for the WCF bindings.
Have tried adding the entire 'system.serviceModel' section into the Reporting Server config file (rsreportserver.config). Have also added the generated app.config file from the custom DLL into the report server's /bin folder. Am still getting the following error though.
Could not find default endpoint element that references contract 'name of my WCF service' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
For now I am changing the code to create the bindings through code but would rather have this config file based. Any help is greatly appreciated.
Thanks
David
A. I would just create a proxy class of SSRS service objects in code.
B. Then make your own wrapper code for creating a report or getting report info. I explained this in another question here:
Programmatically Export SSRS report from sharepoint using ReportService2010.asmx
C. Then build a service around those wrapper methods to get your data.

How to call a WCF service from a SSIS Custom Log Provider?

I created a SSIS Custom Log Provider (SQL Server 2012 / Visual Studio 2010 / .Net Framerowk 4), and now I have to call a WCF service. I am not sure how to do that, since this is a custom library project, with no config file.
Ideas? Thanks!
This is a tricky thing to do in SSIS. You would be better off calling the WCF Service from C# and using that app to populate and thus stage a table that you can get to from SSIS.
Having said this...if you want to access a WCF Service here are the basic steps.
WCF Endpoint Config Settings. The endpoint to your WCF Serivce must be placed in the dtsexec.exe.config AND the DtsDebugHost.exe.config file located in the following folder: C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn it would be wise to do the same in the Program Files folder if you are running 64 bit SQL Server as well.
Now you can create your SSISScript and add the Service Reference by right clicking on References and then Add Service.
If you have complied your own "internal" Proxies and contracts into DLL then you will need to copy those to the same location as the dtsexec.exe above AS WELL AS registering them in the GAC.
Remember...you need to do this where the SSIS package will run so typically your local instance of SSIS and the Production SQL Server.
Now...an alternative to this may be to "Brute Force" code all of the WCF Endpoint settings in code in your SSIS Script. I have not tired this but if it works that would eliminate the need for the endpoint in those obscure locations and config files. It would be cleaner and a better route. You could then store your WCF endpoints and other settings as variables the pass them into the SSIS Script as readonly values.
Good Luck!

WCF RIA service

having the following issue with newly created RIA service:
system.servicemodel.domainservices.client.Domainoperationexception:
load operation failed for query 'GetUser'.
Why did the project automatically inlude the UserRegistrationContext service anyway? Can anyone please help?
I have seen this issue many times and there are so many reasons for the same.
Secondly as soon as you create RIA service, VS automatically generate the proxy code in SL application. You can find the proxy code under generatedcode folder in your solution.

Silverlight WCF service acting strange

I have a silverlight project that calls into a wcf service. Everything works fine on my local machine.
However when I deploy to a virtual machine, with the exact same query the wcf service returns, but the result is empty.
I've tried debugging, but have not been able to get it to break in the wcf service.
Any ideas what the problem could be, or how I could go about debugging it?
Thanks
I figured out what the problem is, but am not sure what the solution is.
In my silverlight project the wcf service I am referencing is http://localhost/.../SilverlightApiService.svc
I used fiddler on my vm to see the request that was made and instead of trying to contact the above service, it was trying to contact:
http:///.../SilverlightApiService.svc
So, for some reason my machine name is getting inserted in there instead of localhost. Any thoughts on this would be appreciated.
I had this exact problem when deploying to amazon ec2 - The machine name for the service was being returned in the wsdl rather than the dns.
There were a couple solutions (one involved creating static wsdl - yuck!)
But the other was creating a sort of factory pattern for the service
This thread (you can read it all, but the answers are at the bottom.)
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/c7fd51a2-773e-41d4-95a0-244e925597fe/
The slight downfall with this is that although it works - if you change the location of the server, you will need to remember to update your config - Which although isn't hard, it's easy to forget to do.
Can you give us a bit more information? What kind of binding are you using? What does the service config and the client config look like? Where do you get your data from that gets returned? Could it be the service on the VM just doesn't get any data? (e.g. queries a database that just doesn't have the data requested?)
Marc
I have had that happen before. I would try this. Set you start page as the web service file and run the app. Then set the start page back to your default page. Then update all the server references in your SL project. Recompile everything and republish. This has helped me a bunch of times in the past.
I figured it out.
Basically my machine name was hard coded in my ServiceReferences.ClientConfig file in my silverlight project.
What I had to do was specify programmatically what url to use for the service reference when instantiating my service client:
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri
(Application.Current.Host.Source, "../WebServices/SilverlightService.svc"));
ServiceClient serviceClient = new ServiceClient("BasicHttpBinding_IService", address);
I figured out what the problem is, but am not sure what the solution is.
In my silverlight project the wcf service I am referencing is http://localhost/.../SilverlightService.svc
I used fiddler on my vm to see the request that was made and instead of trying to contact the above service, it was trying to contact:
http:///.../SilverlightService.svc
So, for some reason my machine name is getting inserted in there instead of localhost. Any thoughts on this would be appreciated.