Cannot get Sharepoint 2010s Lists.asmx service to work - c#

I'm trying to access Sharepoint 2010's Lists.asmx web service. I've created new console project in C#, added reference to a web service (http://[SITE]/_Vti_Bin/Lists.asmx) and it found the Lists web service all right. However, when I try to do
ListsService.Lists objLists = new ...
It says that Lists does not exist! In object viewer, I see all sorts of things in the ListsService namespace:
AddAttachmentRequest
AddAttachmentRequestBody
....
but I don't see Lists. However, every example I found online says that after I add a reference, I should have Lists in the namespace...
What am I doing wrong?
EDIT: app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://SITE/_Vti_Bin/Lists.asmx"
binding="basicHttpBinding" bindingConfiguration="ListsSoap"
contract="ListsService.ListsSoap" name="ListsSoap" />
</client>
</system.serviceModel>
</configuration>

Make sure you are doing ListsService.Lists objLists = new ListsService.Lists() (not "new Lists()")
Make sure that the web service reference is setup correctly in the Settings.settings file and web.config/app.config file. Try removing the web service reference and re-adding it

The problem was that I have created "service" reference, not a "web service" reference. You have to click "Advanced" and then "Add Web Service reference" in order to add a web service refernce, otherwise it creates a WCF service reference that works differently.

Related

How to include .config file inside C# .dll, that will use in vba project for ms access?

I am write an C# library that will use as reference for VBA
This library has service reference for some online product we using
and this service reference require an .config file to be in the same folder as the application/dll
when I use the service reference in .net application all work grate.
But when I use it in Ms access VBA I gets error about variables that are missing and I know they are in the config file.
I was trying few solutions i found but the problem is I cant change the variables in the reference cause we update it every few weeks.
so I have to include the config file with the .dll without change variables in the project.
Thanks,
config sample that the service reference use:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Isoapbinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.180/soap"
binding="basicHttpBinding" bindingConfiguration="Isoapbinding"
contract="time.Isoap" name="IsoapPort" />
</client>
</system.serviceModel>
</configuration>

Call WCF Service from Windows service via DLL

Basically my situation is this:
Windows Service --Calls--> MethodinDLL --Calls--> WCFService.
Service configuration is written on the DLL side manually, and on windows service side in config - I am insterested if WCF parameters on DLL side and on the Windows service side should match. More elaboration below.
I will tell you my setup. I call WCF Service from DLL. There is code inside DLL which calls WCF service such as this:
//Inside DLL
BasicHttpBinding binding = new BasicHttpBinding(SecurityMode.None);
EndpointAddress epa = new EndpointAddress("http://localhost:16593/FreeSpaceDatabase.svc");
YourServiceClient proxy = new YourServiceClient(binding, epa);
I manually provide parameters as you can see.
Now, I have a windows service which actually refers to this DLL, and using DLL (or via DLL), calls the WCF Service. (The call to WCF Service is located in DLL - windows service doesn't have method to call WCF Service).
But I was forced to still add this on the Windows service side:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFreeSpaceDatabase" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:16593/FreeSpaceDatabase.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFreeSpaceDatabase"
contract="ServiceReference1.IFreeSpaceDatabase" name="BasicHttpBinding_IFreeSpaceDatabase" />
</client>
</system.serviceModel>
</configuration>
My question is what if the EndpointAddress("http://localhost:16593/FreeSpaceDatabase.svc") which I specify in the code on the DLL side(like in the beginning of my question):
EndpointAddress epa = new EndpointAddress("http://localhost:16593/FreeSpaceDatabase.svc");
is different from the endpoint address specified in the AppConfig file as of the Windows service? Is it allowed? Or they should always be the same?
You can remove this address from your config and it should work. I have these settings (bindings and endpoints) in my code and only this in my config:
<system.serviceModel>
<bindings />
<client />
</system.serviceModel>

Test a WCF service

This question must be newbie and i know it but i haven't found the answer for some time now. I have implemented a WCF service which i want to test. So when i click open in browser it opened something like
So i created the configuration file and the code file and i have input it into my solution in the same folder where the web service lies. When i have put the c# code mentioned above in a button of a web form this
EDIT: This is the output.config that i have mentioned above (i hope that is the client's config)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Icheck_for_quantity" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51182/check_for_quantity.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Icheck_for_quantity"
contract="Icheck_for_quantity" name="BasicHttpBinding_Icheck_for_quantity" />
</client>
</system.serviceModel>
</configuration>
If i run wcftestservice the following appears:

Could not find default endpoint element that references contract... But application still works

I am currently working on a WPF Application, using a different project to call a WebService.
When I try to build i get this error:
Could not find default endpoint element that references contract
'VisitorRegistrationWebService.VisitorRegistrationWebServiceSoap' 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.
The app.config from my webservice project is just the same as the one from my WPF project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="VisitorRegistrationWebServiceSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/webservices/VisitorRegistrationWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="VisitorRegistrationWebServiceSoap"
contract="BasicVisitorRegistrationWebService.VisitorRegistrationWebServiceSoap"
name="VisitorRegistrationWebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
The strange thing is that I can run the project and use the webservice to get data, but the error will not go away, no matter how many times I clean and rebuild my solution.
in error message, contract name is 'VisitorRegistrationWebService.VisitorRegistrationWebServiceSoap'
and in endPoint configuration, contract="BasicVisitorRegistrationWebService.VisitorRegistrationWebServiceSoap"

Class Project and WCF Could not find default endpoint element

I am adding a WCF client via “Add Service Reference” to the Class project with Visual Studio 2012. However I am getting the well known error:
Could not find default endpoint element that references contract ‘Service1.IService1′ 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.
The steps I followed was : (1) Create the Service1.cs and output.config via svcutil.exe, (2) Add service reference I am giving reference namespace as “MyFirstWcfWebServiceReference”. (3) add your existing Service1.cs file to the project. (4) in app.config Removed “MyFirstWcfWebServiceReference” and keep only IService1 in contract, (6) Build Project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WCFServiceBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/webiste/WebService.svc"
binding="basicHttpBinding" bindingConfiguration="WCFServiceBinding"
contract="IService1" name="WCFServiceBinding" />
</client>
</system.serviceModel>
</configuration>

Categories