Why would someone use SvcUtil.exe when Add Service Reference in VS.NET provides all the proxy classes you'll need?
Sometimes Add Service Reference in VS fails to create a useful proxy. Instead it gives you an empty Reference.cs details here and here file. I've created a series of bat files to call SvcUtil.exe to generate the proxy classes.
Both svcutil.exe & 'Add Service reference' will use the same proxy generation code underneath. Think of 'Add service reference' as a UI way to generate proxy where it pre-populates a set of switches that you will have to do in svcutil command line. For example when you add service reference in VS the UI lets you to reuse types from referenced assemblies, specify the kind of proxy to be generated (sync-async / task based etc). svcutil will also be useful if you want to automate service reference generation.
Related
I have a WF [Workflow Foundation] project and when I try adding a service reference [Visual Studio 2013-Target Framework is 4.5.1] to it the generated reference code doesn't contain the client proxy code. I tried adding a service reference to other non WF projects [Library projects] and it works fine and the reference.cs contains the Client proxy code. Why Visual Studio doesn't generate client proxy for WF projects? If the facility is not there then obviously I am taking the wrong approach. How can I use a WCF method inside my CodeActivity?
Just to remind you that this is not the duplicate of the following thread :
Service reference not generating client types
Instead of a simple Reference.cs file Visual Studio kindly adds 7 more files to the service reference folder. When I recompile the project and build it all the methods of my WCF service appeared on the toolbox [and became available] and now I can use them in my Work Flows.
I need to add a service reference using a WSDL supplied by a customer. The WSDL contains references to their WCF web service which I cannot see from my development machine. The reference is resolvable on our acceptance environment but I cannot install Visual Studio there.
I thought the point of the WSDL was that it contained all the information for VS to generate the classes necessary to talk to the WS (even without direct access to the WS).
Have have 2 questions:
Is it possible to add this WSDL to my C# project without visibility to their WS
otherwise
Is it possible to generate the classes from the environment that does have direct access to the WS, without installing VS? Maybe by just installing the svcutil.exe (but I imagine this to0l will also require VS)
i got a folder with a WSDL file (and all the xsd files related to it) but i can't seem to generate a web service from it using the "Add service reference" option in VS2013 (also tried in 2008 just to test). I'm using .net 4.0.
i get multiple error such as:
Custom tool error: The global type ('WarningType') has been defined in both
'file:///D:/WSDL/AMA/2011Y/chameleon/AMA_CommonTypes.xsd' and
'file:///D:/WSDL/IATA/2010.1/chameleon/IATA_CommonTypes.xsd'.
They are different at './simpleContent/extension/#base'.
so, i was advised to use "Add Web reference" tool.
this works for some reason. i get no errors now.
But, the problem is that i found out that a web reference do not support WS-Security /WS-Adressing
(someone wrote this as a comment in how to add SOAP Security header) and i MUST specify in the header those elements.
Also, i keep reading not to use a web reference since this is an old technology.
So, does anyone know how to solve the errors I'm getting ?
There are multiple tools that generate service proxy objects. Apart from using Add Service Reference you can use command line tool svcutil.exe which is included as part of the visual studios installation for generating service objects.
Here is how to do this
http://msdn.microsoft.com/en-us/library/ff623148.aspx
This alternative command line approach will help you resolve issue related to WS-Security / WS-Adressing.
I've recently had an issue where I have a web service asmx file where clients can access the wsdl through an https address, such as https://example.address/webservice.asmx?wsdl. When adding a web reference to Visual Studio, it tries to access http://example.address/webservice.asmx?wsdl — which returns a 404 error as the server is not configured to allow non-secured access. This also occurs in SSIS when adding a web service reference, or web service task (even when a certificate is added).
In Visual Studio, I'm also able to add it as a service reference which generally works (except for double[] being changed to ArrayOfDouble, etc.), but it doesn't appear that service references are an option in the Visual Studio provided within SSIS.
I've searched around for this quite a bit and there seems to be no easy solution to force https to be used. Instead, I'm wondering if there is a way to import wsdl references into a project manually without adding it as a web reference (just to add the request methods). That way I can create my own https SoapClient that uses these methods without the web reference issue.
You can generate client proxy classes by using the wsdl.exe
Web Services Description Language Tool (Wsdl.exe)
wsdl /out:myProxyClass.cs https://example.address/webservice.asmx?wsdl
wsdl.exe can be used either by opening the Developer Command Prompt, or executing it from the folder it resides in: ProgramFiles/Microsoft SDKs\Windows\v7.0A\Bin\wsdl.exe
You can generate client proxy classes by using the svcutil.exe
svcutil.exe [/t:code] <metadataDocumentPath>* | <url>* | <epr>
ServiceModel Metadata Utility Tool
The svcutil.exe is like a next generation of wsdl.exe utility. Svcutil allows you to generate proxies for both - web services and WCF services.
Svcutil supports DISCO protocol along with WS-Metadata Exchange protocol, which is an interopable standart of SOA.
In some cases both utilities wasn't generate client proxy, therefore you will need to do two things to get the WSDL you need:
Download all of the files that are referenced; these will be either <?include> directives or <wsdl:import> tags found within the other XMLs file, which pull in a second one. You need to check each new file, as there are often second and third level imports. Put everything into one folder.
Edit all of those include references to remove the URLs and just use local file references.
Once that's done, you can generate client proxy from local files by next command
svcutil *.wsdl *.xsd /l:C#
You can download the WSDL file by using disco.exe located in the same folder as wsdl.exe to download your web service wsdl file.
Web Services Discovery Tool (Disco.exe)
disco http://www.proseware.com/prosewareWebservice.disco /o:"c:\folder"
And then you can go on and use Wsdl.exe to generate your proxy class
Our customer sent us a WSDL file for their web service API. We used Visual Studio's "Add Service Reference" to consume it.
However: we only want to generate a service proxy, not the data contract classes. We want to reuse classes we already have within a referenced assembly.
How to instruct "Add Service Reference" to not create Data Contract classes?
...or how to instruct WCF to use our Data Contract classes from the referenced assembly instead?
This comes down to the following options on the Advanced... part of "Add Service Reference":
which also map to the /r / /reference option in svcutil.exe.
This defaults to enabled, so if it isn't working: there's a good chance your types are not exact matches. The easiest way to ensure exact matches is to reference the same library dll from both projects, or worst case the same .cs file (a dll reference would be preferable, IMO). The data-contract namespace and name are the usual culprits here, and must match exactly (as must the members).
Add your data contract classes (or even better create a new library for you data contract classes and reuse both in the service and client side) to the project including your service references. When adding a new service reference or updating an existing one, select "Reuse Types in Referenced Assemblies".
This is old but I have one doubt about this.
I can access classes when adding service reference, this is ok
I can't see these classes when working with all projects inside the same solution in Visual Studio and adding "project" references.
Is there a way to test client side code using all projects inside the same solution in Visual Studio?
thanks