"use" a wsdl (SOAP)
Hello all,
I have recently beeing asked to create a client application in .net and visual c# that will be able to communicate with a server application over soap. I have bee given a WSDL file but i am struggling to see how i will use that in a client application.
My reading provided some basics on what the WSDL file describes and how it is used in the SOAP context, but i am trying to find a library/mechanism that will create a class which will be able to construct the XML file according to the wsdl definition.
I have checked that the SOAP toolkit seems to be of no use (and it is now depricated) and i was trying to see if there is any other tool in VS 2008 that will ease my way in doing that (or any good reading pointers)...
Thanks a lot in advance,
Panos
Todas las respuestas
- Hi,
Microsoft provide a tool for creating C# or VB.NET classes from a WSDL document, it's included with VS2003/2005 at least so I can't think it wouldn't be there in 2008, it's called wsdl.exe
Hope this helps,
David
Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 1.1.4322.573]
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
wsdl.exe -
Utility to generate code for xml web service clients and xml web services
using ASP.NET from WSDL contract files, XSD schemas and .discomap discovery
documents. This tool can be used in conjunction with disco.exe.
wsdl.exe <options> <url or path> <url or path> ...
- OPTIONS -
<url or path> -
A url or path to a WSDL contract, an XSD schema or .discomap document.
/nologo
Suppresses the banner.
/language:<language>
The language to use for the generated proxy class. Choose from 'CS',
'VB', 'JS', 'VJS' or provide a fully-qualified name for a class
implementing System.CodeDom.Compiler.CodeDomProvider. The default is 'CS'
(CSharp). Short form is '/l:'.
/server
Generate an abstract class for an xml web service implementation using
ASP.NET based on the contracts. The default is to generate client proxy
classes.
/namespace:<namespace>
The namespace for the generated proxy or template. The default namespace
is the global namespace. Short form is '/n:'.
/out:<fileName>
The filename for the generated proxy code. The default name is derived from
the service name. Short form is '/o:'.
/protocol:<protocol>
Override the default protocol to implement. Choose from 'SOAP', 'SOAP12',
'HttpGet', 'HttpPost', or custom protocol as specified in the configuration
file.
/username:<username>
/password:<password>
/domain:<domain>
The credentials to use when the connecting to a server that
requires authentication. Short forms are '/u:', '/p:' and '/d:'.
/proxy:<url>
The url of the proxy server to use for http requests.
The default is to use the system proxy setting.
/proxyusername:<username>
/proxypassword:<password>
/proxydomain:<domain>
The credentials to use when the connecting to a proxy server that
requires authentication. Short forms are '/pu:', '/pp:' and '/pd:'.
/appsettingurlkey:<key>
The configuration key to use in the code generation to read the default
value for the Url property. The default is to not read from the config
file. Short form is '/urlkey:'.
/appsettingbaseurl:<baseurl>
The base url to use when calculating the url fragment. The
appsettingurlkey option must also be specified. The url fragment is
the result of calculating the relative url from the appsettingbaseurl
to the url in the WSDL document. Short form is '/baseurl:'.
/parsableerrors
Print errors in a format similar to those reported by compilers. - Hello David and many thanks for your reply!
In fact i used succesfully the wsdl.exe utility and managed to recreate and run the simple example from ms's website (http://msdn.microsoft.com/en-us/library/ms734712.aspx)
However, and although i have succesfully created the generatedProxy and the api.config files from the remote web service, i keep receiving hundreds of exceptions when i am trying to use it.
Before posting the exceptions i wanted to make sure that my client is accessing the service correctly using our proxy server. What do i have to do to declare that programmatically in my client application?
I have noticed that there are some setting about the proxy in the api.config file (generated from the wsdl). do i have to declare it in there and how?
Many many thanks,
Panos - There's a Proxy property on SoapHttpClientProtocol (the base clase for the generated proxy), so if you need to set up proxy authentication that's the place to do it
-smaine
Brain.Save() -- http://hyperthink.net/blog - Hello Steve,
Thanks a lot for your reply, indeed there is a property there to define the proxy settings.
I have also found that the
System.Net.GlobalProxySelection.Select = new System.Net.WebProxy("putyourproxyURLhere",8080);
is doing the job!
Cheers,
Panos

