I have a WCF Service. I add reference of a DLL in the WCF service.Now ddl has a class, i'm able to get access of the class at WCF client side by using the serviceknowntypeattribute but not the functions inside the class.Any solution?
I'm guessing that You are using autogenerated code (by Add Service Reference in Visual Studio).
This creates a stub for your class (only a container) but it is not actually your class.
To use your actual class in client code you must reference it in client project and in service reference advanced options make sure you have 'use types from referenced assemblies' checked.
Related
I want to retrieve data from a database using a WCF service and service reference in my Silverlight project. All things that I do are:
created Linq-to-SQL file and add server connection then drag some table from server explorer to PersonDataClass.dbml file
Create WCF service
Implemented the functions defined in the interface:
created a Service Reference named DBServicesRef
but in my code I can access just one function of the WCF Service, just the getPersonComplete service method :
I searched the web but I am beginner in Silverlight :)
I clean, build, rebuild the project, update DBServiceRef (with check or uncheck reuse type in referenced assemblies ) or even delete and create files but I can not insert any value to database :( because I can not access the addPersonComplete service method to handle it .
Your addPersonRecord does not return any value. Therefor it will not get it's own event handler. It will use a generic handler.
When you've written the += after webService.addPersonCompleted just press tab twice and you should get a new function with the correct signature automatically.
I want to invoke a web service from my winforms application in visual studio 2012. So, I have added a service reference to my web service in my project. This service contains two methods. How can I can invoke those methods from my c# code ?
You should be able to call it as follows:
using Your.Service.Namespace;
// ...
IYourService serviceClientInstance = new YourServiceClient();
serviceClientInstance.SomeServiceMethod();
PS: You can see info about the service and available methods by right clicking the reference (under Service References), and selecting View in object browser. Among other things, you should see a class YourServiceNameClient there, which should have been generated for you, which you can use as above.
I'm trying to connect to the a provider website which has a soap based API. I'm new to C# so I am not really sure how to do it. I've been googling around like mad but I am getting nothing but errors. Here is what I've done.
I've added the URL (ex:http://www.companysite.com/api/api.cfc?wsdl) as a web service inside my .net solution and gave it a namespace of CompanyAPI.
If i right click on the service reference inside the solution explorer window, then go to object explorer. I can see all of the available methods.
When i try to instantiate it is when I get errors like cannot instantiate an instance of abstract class.
'CompanyApi.Api MBApi = new MyApp.CompanyApi.Api();'
I have no clue what i am doing wrong. Thanks in advance for any help.
When you add a Service Reference in Visual Studio, it creates an interface to represent the service contract and a client class which implements the interface. You are probably attempting to create an instance of the interface directly, which is not allowed; you should create an instance of the client. The client should be named something like ApiClient, in which case you can do the following:
CompanyApi.ApiClient MBApi = new MyApp.CompanyApi.ApiClient();
Can I expose a System.Collections.Generic.List<> from a asmx service.
I tried it but the reference class generated at client have converted it as Arrary[].
Have you set the option in update service reference?
You can set this by right mouse clicking on your service located in the Service References folder, then select Configure Service Reference.
And may you have set that option already and your still getting back an array then may i suggest to look here
http://johnnblade.wordpress.com/2012/06/07/service-reference-returns-array-t-instead-of-listt/
At client side, I have this class without [DataContract]:
public class UserEntity
{
public string login;
public string password;
}
when I put [DataContract] and refresh the reference of this class at WCF side, then I can't initiate the web service. It says an error:
cannot create metadata...
What's wrong?
Are you sure that you actually know, why you can't refresh the reference? I mean you add [DataMember] - and it fails, you remove it - it works? Or it works several days ago and now you add [DataMember] (and many other stuff) and it not works now?
But anyway, the easiest way to solve "refresh reference" issues - to refresh reference manually with SvcUtil.exe. In this case error message would be much more descriptive the simple "oops! error!".
What is client and server side in your case? What is refreshing reference on the WCF side? Your description is very uncommon. Here is description how to create service with complex data type and WCF Class library:
Create WCF class library
Add data contract to the class library
Add service to class library
Implement service contract and service in the class library
Add host project
Reference WCF class library from host project
Host service from class library in host project
Add Metadata endpoint to your hosted service
Create client project
Run the host project outside the visual studio
Use Add service reference to create proxy on WCF service hosted in your host project
Implment code to call your service through created proxy
As you see there is no modification of data contract on the client side and no refreshing WCF service.