Creating a SOAP Service with C# - 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.

Related

How to Consume an OData v3.0 Service within Visual Studio 2017

I am struggling to find a way to simply use a OData v3.0 service in any way from within Visual Studio 2017, so I can use the Client library to help develop my app/service to consume the data.
According to the Microsoft OData Stack page, they seem to have all of the tools and support to consume an OData v4.0 service. Not knowing I was in fact dealing with a v3.0 service, I followed these instructions and as the page describes, there are two tooling options to get you started. One is the OData Client Code Generator, and the other is the OData Connected Service extensions
After having to go thru some hoops to even get either one to work (see GitHub Issue for actually finding a version of the Client Code Generator that actually works with VS2017, and and trying a work around to get the OData Connected Service to work with a service that requires authentication, I finally realized I was working with an OData v3.0 response. So these tools couldn't help.
Now contradictory to what is actually mentioned on the OData Connected Service marketplace page, where is says "OData Connected Service for V1-V4", this did not work. If the OData service requires authentication, then I get this error dialog from trying to add a Connected Service via the extension:
So then I read in a GitHub issue (can't find it), is that a potential work around is to download the XML that is returned from hitting the /$metadata endpoint, rename it to whatever.edmx and try to use that for the extension by providing a file:// URI to that file. That didn't work with the following error dialog:
So then I ditched that approach and tried to instead use the Client Code Generator, and providing the edmx file to that in the TT config (to solve the auth issues, and that didn't work because it was OData v3.0 and not 4.0.
So then, it seems for v3.0, the approach is to use Add Service Reference, but when I do that, I get the following error:
..but that tool doesn't support v3.0.. so now I have no idea how to proceed!?
Any help would be greatly appreciated!
Just in case someone else stumbles on this particular combination and can't seem to proceed with consuming an OData v3.0 service with current VS2017, (and specifically on how to use it in an Azure Function), here is what I did to get around this:
Reinstall VS2015 and create a new library project
Add a new Service Reference and point to your OData v3 (or earlier) service. if the service requires authentication, this dialog will allow you to enter the creds. I was prompted to enter them 2x.
Create a class / service / interface that will expose all of the relevant tables / queries that you are interested in consuming from that OData service
Save the project and close VS2015
Copy this project to your VS2017 solution. In my case, I had a solution containing an Azure Function.
Now call upon this new project/library to obtain the data.
This is the only way I could get this to work after many many hours of troubleshooting various limitations and workarounds of the current versions. Needless to say, I am quite disappointed in the current state of the tooling + VS2017's support for consuming older versions of OData.

How does one add the reference to use the SOAP API 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,

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/

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.

How can I write tests for web services (in C#) outside of the Solution they exist in?

I have been recently added to a project where I will need to be doing functional and load testing for some existing Web Services (SOAP).
I was wondering if it is possible to call a web service from a console application for testing purposes? I do not have permissions to code in the existing Project so I need to create a new one, which is what my real issue is, I do not know how to call the web services (or the web service code) from outside of their Solution.
I know this will make things more difficult, especially for recording test results, but I have no choice as I am a contractor and can not get the required permissions. I can pull code and see the source code, I just don't want to code in the existing project as my local changes will get blown away every time there is new code to pull down.
I have done some basic testing using SoapUI, but the open Source version does not meet all the requirements I have and would rather just write my own tests then try and find a free 3rd party solution (as I also have no budget).
Thanks,
cwlovell13
You can write a simple WCF client to consume existing Web Services (SOAP).
Maybe you can reference this .
Accessing Services Using a WCF Client

Categories

Resources