How does one add the reference to use the SOAP API C#? - c#

I want to make an application that automatically deploys reports made in SSRS to the reporting server. I found that the best way to do this is by using SOAP.
I have been searching on this topic for a little while now and I don't see anyone saying how to add the SOAP API reference to a Visual Studio project.
This page page seems like it is directed toward the complete beginner with this API (which I am), yet it does not cover step #1 in actually using the API, which would be to add the reference. What using statement should I use, and/or what is the name and location of the DLL which needs to be specified, in order to start using the API?

I have never done it before until just now but it looks like you just need to add a Service Reference in Visual Studio. Since SQL 2008 R2 the URL looks like this:
http://server/reportserver/ReportService2010.asmx?wsdl
For more information see this MSDN page.

As mentionned by SMM, you simply have to add a web service reference to your Visual Studio project.
Go to "Project" menu, and click on "Add a service reference...".
Then put your SSRS service address in the window that shows as explained in previous post, and... that's it !
A new folder "Web reference" is now present in your project, with an item inside, representing the reference to the SOAP web service you add.
Let me know if you have some trouble.
Regards,

Related

How to Add Web Reference for UWP in VS 2015?

I am trying to migrate my code from normal wpf application to Universal Windows Platform.
Previously I have used VS 2012 for Developing my WPF application And its working fine. Now I want to use the same application for mobile also.I found UWP as a solution for it. Now I am using vs 2015 . But here in vs 2015 I am unable to find Web Reference Option I am able to see only Service Reference. Actually My situation is I am Dynamically taking Ip Address and port number from User Based on the request I am connecting to that particular services like
public const string GET_SKU_DETAILS = "http://{0}:{1}/OmniRetailerServices/SkuServices/getSkuDetails?skuID={2}";
So like this I am connecting to particular Remote servers for accessing services.
And I did this using Web References in vs 2012. But Here in vs 2015 I am not able to find Web Reference. So My Question is How can I do this in UWP application Using VS 2015.
Please Help me to solve this Issue.
Thanks In Advance.
Web references (ASMX web service clients) are considered as legacy even in classic desktop applications, such as WPF. Service references (WCF service clients) are their successor and as you already noticed, they are available in UWP apps.
Just create a service reference instead of a web reference. You should be able to create it by pointing at the same WSDL as you did to create a web reference.
You can change the endpoint URL when creating an instance of the client proxy:
// use the base URL without the method name
var url = String.Format("http://{0}:{1}/OmniRetailerServices/SkuServices", hostname, port);
var client = new SkuServicesClient(new BasicHttpBinding(), new EndpointAddress(url));
To invoke the web method, call the corresponding method on the generated proxy:
var result = await client.GetSkuDetailsAsync(argument);
Not knowing the details about your service, I tried to come up with reasonable URL value and names in my code to match the info you have provided. It should be enough to get you going even if they won't be identical in your case.
Yes you can. Just proceed as if you gonna add a new service reference (Yes I now that you need to add a web reference) then on the bottom left of the "Add Service Reference" window, click on "Advanced" option. Then, again on the bottom, you see "Compatibility" and near the "Add Web Reference" button, now got it! :)
you can't do this. you need to find another way like HttpClient.
HttpClient is the easy way to consume web services.
https://blogs.windows.com/buildingapps/2015/11/23/demystifying-httpclient-apis-in-the-universal-windows-platform/

Can't Added Service Reference from WFC

(In VS 2010)
I can't add a service reference to a WCF service in a Windows Forms Project. When I go to add a service reference I click the "Discover" button. It brings up the service I want to add (within the same solution). I click the "OK" button. A server port starts (according to a popup dialog). And I get a Meassage box that pops up and says "There was an error downloading metadata from the address. Please verify that you have entered a valid address." Rats! I don't know what to do :( Now I did mess around with the WCF service project's Web.Config file before I tried to do this. I don't know if that would affect anything. Any help would be much appreciated!!
I have discovered an answer to my own question. Apparently you can get this error if you rename your service but don't change the service name in your .svc file.

Calling a web service in a windows application form

EDIT. I was adding it as a service reference instead of a web service reference (found by when adding a service refererence, go into advanced and down the bottom it should say "add web reference") , I didn't know that option existed as it's hidden away.
I made a web service in c# .net. Initially it wasn't calling because I thought that the web form didn't like the codebehind for the web form that is created in VS2012, so I took that out and just included the web service file itself.
I'm pretty sure the libraries were included when I visit the url of the service with wsdl, but it still won't seem to call the service to the form.
It displays some XML data and shows TestCypher as a workable service, so it should be working? I'm not entirely sure where the wsdl file should be hosted if I take the web service out of the solution
Please see the below link
http://www.codeproject.com/Articles/26941/Consuming-Webservice-In-A-Windows-Application
you can use this method in your application. I just post this example in your requirement.
please note : i have no guarantee about the perfomrnce area in this method.
So please consider this element when your application is use a wide number of users.
Hope it help.

Creating a SOAP Service with C#

I am nowhere near a professional level on this topic so please forgive me when I use wrong terms.
A friend and I have been trying to create a http-based SOAP client/service for a personal project of ours.
The language used is C#, the IDE is VS2008.
We don't really know where and how to start. The tutorials I have found are either too advanced or are no longer usable due to VS constraints (vs2008 doesn't let me use WSE, which seemed quite nice for our purpose).
It would be great if anyone could help us on this task.
Regards
Daniel
Add a new WCF project. It should
create a default Web Service
(Service1) for you with a method
like GetData(...) or similar.
Add a second Console application
project.
Right-click on the Console project
and select Add Service Reference.
In the dialog that pops up, select
the option to search the solution
for services.
It should find the Service1 service.
Add it.
That basically generates client-side
code to call your service.
Then add some code to call it to the
main method of your Console project.
The code will look something like
this:
var myClient = new Service1Client();
var result = myClient.GetData(...);
Right click on the Console application and select Set as Startup project.
Place a breakpoint on the line where you create the Service1Client. Press the F5 key to run the code in debug mode.
Visual studio will run your application in debug mode. It'll host the service itself. You should be able to step through the code using F10 to see how it works.
When you added the service reference, and App.config will have been added to the console project. If you have a look in there it will have all of the client configuration data for connecting to the service. If you want to host your service in IIS, then you'll need to update the service endpoint URL.
Hopefully that's enough to get you up and runnning with something that works. Once you're there I'm sure you'll have many other questions.
I would recommend you taking a look at WCF which is the de-facto standard of creating web services on the .NET framework. And here's are some nice tutorials.

Call web service over https

What do I need to call a web service over https in C#?
Do I need to get the certificate form the site? How do I use this to call the web service?
There's nothing special or different for calling a web service over https than over http. You generate a client proxy from the WSDL using either svcutil.exe (or Add Service Reference in VS) or wsdl.exe and invoke the method. The lower level classes HttpWebRequest and HttpWebResponse will eventually take care of the actual call and certificates but it should be transparent for your code. Of course the server hosting the web service needs to provide a valid certificate.
I take that you are using Visual Studio to create your projects, if you are it is pretty easy to do. I take that you have the url for the web service that you would like to connect to and it starts with HTTPS.
In your project in the solution explorer (assuming you using Visual Studio), you should see a node saying "References" and another one saying "Web References". Right click on the "Web Reference" and then basically follow the wizard. It is pretty straight forward. You can spec your own Namespace. I usually use the format SomethingAPI. Then use the API as you would like any other object in your project. You will get the intellisense and all.
There might occur known problems with some certificates though. See http://support.microsoft.com/kb/823177/en-us
Do you have a client certificate that has been supplied by the provider of the web service?
If so, there are various different ways of doing this depending upon which version of .NET you are using. What version are you using, and are you limited in how you can generate your client proxy classes?

Categories

Resources