consume gsoap webservice from .NET client - c#

From a .NET application, how do I consume a Web Service developed using gSoap c/C++ library?
I can create a C/C++ client using gSoap library to consume the web service. But I need to consume it from within a .NET (C#) application. I tried Adding a Web Reference but that doesn't seem to work.
Would I need to work with raw Soap Packets?

You can try to call the Web Service dinamically (without adding the reference)
Call a webservice dynamically without webreference
Building Dynamic SOAP Requests with ASP.NET C#
You can also try to build a WCF client, and generate the managed source code file for a proxy using the ServiceModel Metadata Utility Tool (Svcutil.exe).
How to: Create a Windows Communication Foundation Client
Finally, the ProxyFactory project lets you build the proxy classes without WCF

The reason Web reference was not working was the hand crafted WSDL. It worked fine with gSoap library and gSoap C/C++ code generrator nut not with VS. With some changes in the way WSDL was written, I am now able to consume the gSoap C/C++ web service by adding a Web Reference in Visual Studio and also by using HTTP GET method.
Steps taken -
Instead of adding Web reference, use wsdl.exe in verbose mode to generate code using thee gSoap WSDL and XSD file
change the WSDL file to resolve any error and warnings reported by wsdl.exe
Once wsdl.exe can successfully generate code using the WSDL, you can now use VS add web / service reference wizard

Related

How to get single wsdl file for a WCF service?

I am trying to generate a single wsdl file for a wcf service for which .net framework version is 4.7.2. I see this link says it is supported by default in WCF 4.5 version. When I try to access ?singleWsdl of the service, it still throws an error "System.NotSupportedException: A single WSDL document could not be generated for this service. Multiple service contract namespaces were found".
Any idea why it does not work ? Thanks for any help!

WCF Proxy class not generating

I have a WCF service which is used by two client applications, one is a web application and the other is a Windows forms application.
When I add a service reference to the web application it works perfectly.
But, when I add a service reference to the Windows application it doesn't generate the proxy class.
Then I run selected the "Reuse types in referenced assemblies" in configure service reference section and it generates the reference with XML serialization. That is not what I needed because it gives me lot of errors since I'm using GUID everywhere.
Can anyone explain me how to generate the proxy class with runtime serialization? (both client application use same version of visual studio - Vs2010)
I'm really struggling with this and your help is highly appreciated.
You can use svcutil to generate proxy class. Add these proxy class in a DLL and then reference it in your Web and Windows application. In this way, you don't need to rely on Visual Studio and will have consistent proxy code for both Web and Windows app
More details - http://msdn.microsoft.com/en-us/library/aa702581(v=vs.110).aspx

Combining WCF Service Library and WCF Service Application

Thanks to Stack Overflow and a few other sites, I understand the difference between the WCF LIbrary and WCF Service Application templates.
Briefly the Library is a DLL that allows for multiple types of hosting. It does not have a .svc file. While the Service Applications template is created specifically with IIS in mine with a .svc file.
I read that WCF Service Library is the best way because it is the most flexible. But I NEVER see instructions on how to do it apart from using the WCF Service Application template.
Is it difficult to go from WCF Service Library to hosting on IIS from scratch? I have two books on WCF and I've read numerous articles and none of them cover how to create a svc file using only the WCF Service Library and No WCF Service Application. Why?
Nigel Shaw also mentions on the following link that there are limitations to using the Library option. What is the purpose of WCF Service Library?
Basically What I want to do is host the WCF Service on both IIS and a Windows Service. Thus it appears that the combined way is the best way. Nevertheless, I'm trying to learn why there aren't more instructions on using the WCF Service Library.
Ok, I did find a couple of articles that seem to use an ASP.NET Web Application and tells you how to create a text file for the svc file.
This article: http://debugmode.net/2010/12/25/wcf-service-library-creating-hosting-and-consuming-wcf-service-with-wcf-service-library-project-template/
and this one: http://danielvanwyk.wordpress.com/2010/04/30/create-host-and-consume-a-wcf-service-using-the-wcf-service-library-template-in-visual-studio-2008/
But what I still don't understand is why is the ASP.NET Application still needed? And If i add a svc file does it get placed in the wwwroot directory (that seems to be where the WCF Service Application places it .svc file?
Thanks!
A WCF Service Library has to be hosted in order to be used - you can host it in IIS, a Windows Service or some self-hosted option (like a console app, WinForm, WPF, etc).
In the last two links you provide, they're demonstrating how to host the library in an ASP.NET service application, but you don't have to use that project template to host it. It's simply one option out of several.
You can create an IIS-hosted implementation of your class library without using a VS project template, but you'll need to manually add the .svc file and the Web.config. I have done this several times:
Create a folder (I normally put mine in the wwwroot folder of inetpub, but you can put it wherever you desire).
Create a bin folder in the folder you created in step 1, and put the WCF service library and any other required assemblies in it.
Add a .svc file with the appropriate markup in the folder created in step 1.
Add a Web.config with the appropriate service model configuration in the folder created in step 1.
Create an application in IIS that points to the folder you created.
Now you have an IIS-hosted instance of your service. You can then use another copy of the WCF service library for your Windows-Service hosted instance.

Secure WSDL for Metro Style Apps

I have some web services that I need to reference in a Windows 8 Metro style application, normally you can just add a reference to the service via VS2012, but the services are behind a security layer.
I have downloaded the .WSDL file to my local PC, and now I need to generate the class file for this service.
The WSDL.exe that I have found on my local PC is for .NET 4.0 and produces code that is not suitable for the .NETCore framework. Is there a WSDL.exe equivalent for Windows 8 apps?
Visual Studio 2012 can obviously add a reference to non-secure asmx WSDL web services, so the functionality must be somewhere.
As per little investigation, the original .NET 1.x asmx-based Web Reference proxies are not supported in Metro style apps.
Web Service with SOAP 1.1 end point is supported by Add Service Reference (right-click on a project and choose Add Service Reference) in Metro style apps.
A workaround should be remove the offending constructor that fails to build (unfortunately, you'll need to do that everytime you regenerate the code), and to pass an instance BasicHttpBinding and EndpointAddress to one of the constructors of the WSFTerminalsSoapClient.
Have a look at following references, which might help you in this regard:
Web Services from WinRT Metro
WCF in Windows 8 Metro styled apps? Absolutely supported
I found out how to do this if anyone is interested.
You simply download the XML WSDL file from the site via a normal browser.
Then in VS2012, you can add a service reference to that file directly (i.e. put in the full path to the file c:\tmp\mywsdl.xml) and it will be able to generate the proxy for you.

How do I consume an existing webservice in ASP.NET?

I need to consume an existing web service in ASP.net.
The documentation of the website that provides the web servicesays that I have to use WSDL.exe to generate a stub, but I can't find this tool.
I also tried the Add web reference wizard in Visual Studio 2010 (VS2010), but if I paste the URL in, VS2010 doesn't work anymore.
What am I missing?
As far as I remember there should be a choice between .net 2.0 and WCF services.
Try to select .net 2.0 web service type. We had to do it for using SOAP web services running on Python.
You might also try using the Add Service Reference Wizard instead - worked for me for WebServices the Web Reference Wizard did not like quite as much. Make sure to use the link to either the asmx (if it's one) or the .wsdl
As far as I know, you can't create SOAP webservice with .net 4. When you creating new project, you need to choos .net 3.5 or earlier first, and then create project.
As for creating stub from existing wsdl, I don't know how to do it.

Categories

Resources