suppose when i have only wsdl file then how can i create proxy class just to call webservice various method. how webservice related all class and its property & method will be exposed in my c# apps. can anyone help guiding me. thanks
You would need to use the ServiceModel Metadata Utility Tool, or Visual Studio's Add Service Reference Dialog in order to generate a client proxy for the service with which you want to communicate. The generated proxy will provide classes that abstract the service contract, and you can program your client applications to interact with these classes.
There is an utility, it shipps with Visual Studio (since 2005, I think), called wsdl.exe
It's commandline, and can be used to generate proxy.
You can use WSDL.exe tool using command line.
i.e. WseWsdl3 WSDLPath /out:MyProxyClass.cs
if WseWsdl3.exe is unable to create the proxy class, there is still a way.
If you can run your service as a regular ASP.NET web application in IIS, it creates temporary ASP.NET files where the proxy class is nicely generated for you.
You can find it in folder:
C:\Windows\Microsoft.NET\Framework\vMAJOR.MINOR.BUILD\Temporary
ASP.NET Files\YOUR_WEB_APP.
There are some subfolders with random names, go to most recent one and look something like "App_WebReferences.XXXX.0.cs".
Related
I am attempting to connect to the Taleo API from my solution in Visual Studio. The Enterprise API (not to be confused with the Taleo Business Edition API) is a SOAP-based Web Service with a number of WSDL endpoints.
I can successfully query the API in SoapUI, however, I am not having luck when attempting to add a Service Reference in Visual Studio.
Here's what I've tried:
Added a reference to the WSDL (Note the Operations that appear). So far so good...
Visual Studio successfully generates the necessary classes, however, the methods circled above are nowhere to be found. I've searched the API for hours and even ran a few searches in Reflector... they are truly MIA.
A few observations:
I can see the methods when viewing the raw WSDL XML in a browser (if you need a sample, I can post it)
I can query the three methods just fine in SoapUI
It's my understanding that the methods only support HTTP POST, so perhaps Visual Studio is performing a GET and the service is rejecting it? (I've FIDDLED this, and all I see is a 200 response)
I am behind a Proxy (although, I was able to connect in SoapUI without having to configure a proxy)
At this point, I'm considering writing my own SOAP client to perform the queries using an HttpWebRequest, but I thought I would try and figure out what's wrong before diving too deep into that.
Any idea what I'm doing wrong here?
I was also having trouble with the API. When I tried adding the service reference as described by the OP, I received a series of errors in the Error List including the following:
Error: Member BusinessGoal.Items of type System.Object[] hides base
class member BaseMultilingualEntity.Items of type
multilingualStringField[]. Use XmlElementAttribute or
XmlAttributeAttribute to specify a new name.
I was able to use the older Web Reference mechanism to generate the proxy classes. You can find this under Add Service Reference → Advanced → Add Web Reference. This will generate a Reference.cs file that contains the proxy class code for the service. You will need to have Show All Files selected in Visual Studio to see this file buried under the generated Web Reference. (You can also use the WSDL.exe command line tool included with Visual Studio to generate the Reference.cs file)
Using this approach, my proxy class included the methods that were missing, but I still needed to manually edit the Reference.cs file to replace all "[][]" with "[]" as many of the generated types were erroneously created as jagged arrays.
I was unable to add a reference to the Taleo API either through the "Add Service Reference" wizard, or though the legacy "Web Reference" method. I ended up writing my own SOAP client using a HttpWebRequest to get and post the XML directly.
We've requested a company to write a webservice that we can use to get some information.They have sent us WSDL and XSD files. Could you please tell me how I can use these files to query data?
I can do it easily if I have a link to a webservice. I just provide the link and Visual Studio generates web reference for me. After that I can use that reference just like a normal class. In this case I have no link. Just above mentioned files. Thank you.
You can create a proxy (add service reference in visual studio) from a wsdl file. You can read about svcutil at http://msdn.microsoft.com/en-us/library/aa347733.aspx, but VS2010 allow you to put a wsdl file on adress when adding service reference.
VS2010 can't create a web service reference from some WSDLs. Have
to write custom wrapper for those. OR edit your WSDL in a way so
VS can consume it. For example it may be ok for you to remove web
service method references for the methods that you are not planning to
use if those references create trouble for you.
Unless you're stuck with .NET 2.0, you should not use ASMX web service technology.
You should use "Add Service Reference" and point it to the WSDL on disk. It will create a set of "proxy" classes with methods that you can call just as though it were a "normal" class.
See "How to Consume a Web Service" for a walkthrough with example.
Use WSDL.EXE utility to generate a Web Service proxy from WSDL.
e.g.
wsdl /language:CS /n:"Microsoft.SqlServer.ReportingServices2010" http://<Server
Name>/reportserver/reportservice2010.asmx?wsdl
check this for Creating and Consuming .NET Web Services in 5 Easy Steps Article and then Creating the Web Service Proxy
Ref:
WSDL and consume web service
consume non .NET webservice through WSDL file
How to use a WSDL
I have a sharepoint web service running at specified host + "/_vti_bin/UserProfileWebService.asmx". I would like to instantiate a web service client, so that i could interact with this service. This is basically what I am trying to do: http://msdn.microsoft.com/en-us/library/ms550407.aspx.
How is this done in .NET? And do I have to use the MOSS API to know what functions it supports?
EDIT:
I guess I should add that I want to connect programmatically, not through a web reference, because that seems to be static.
In VS (2008/2010) you can add a web service reference to your console project for example. It will auto-generate the proxy classes for you to use in your code.
Disclaimer: My experience/knowledge of web services is very limited.
There is an existing web service WSDL that I have reverse engineered with wsdl.exe to create a C# proxy class.
Using Visual Studio 2008 I created a default web service template.
How do I reference the generated proxy class so that it will work in the web service?
For example -> calling http://localhost/webservice/service.asmx?WSDL will return the details from the proxy class.
First of all, you should not be using ASMX web services. Microsoft now considers them to be "legacy technology", and suggests that all new development of web service clients or services be done using WCF. Don't start off at a disadvantage.
Secondly, the normal way to make use of a WSDL is to use the "Add Web Reference" command in Visual Studio ("Add Service Reference" if you were using WCF). This generates the proxy classes for you and adds them to your project.
I'm not sure from your question that this is what you want, since you first talk about the WSDL, but then talk about a "default web service template". What do you mean to do with the "default web service template"?
Try using the svcutil.exe program (not WSDL.EXE) as follows:
svcutil YourWsdl.WSDL /language:C# /d:subdirectory
This should produce a number of files in the subdirectory. Take a look at the .cs files, one of which will contain an interface which is the service contract. That is the interface that your service must implement. Look at your "default" WCF service application and you'll see that it does the same thing - produces an interface that is implemented by the service.
I've a relatively small problem.
I'm developing and interface between my application and a third party program. The communication between both of them is made by SOAP webservices. They have provided me the wsdl that they are going to use to receive AND send data. I've create the service interface and the client with the wsdl.exe tool, and there are no errors or warnings while the generation.
The problem comes from the generated code namespace. Instead of using the one defined in the interface, it uses the tempuri.org one.
Ok, no big deal, I can define the namespace in the
[ServiceContract (Namespace = "theDesiredNamespace")]
The problem is that i want to provide access to my webservice method from
http://theDesiredNamespace/myMethod
and instead my service provides it at:
http://theDesiredNamespace/nameOfTheInterface/myMethod
where nameOfTheInterface is the name of the interface generated automatically by the wsdl tool.
Any advice on how i can handle this? I know the easiest solution would be to actually send my new wsdl version to the third party (as it should be done) but I don't really have a choice.
Is there any workaround to this problem?
WSDL.EXE is for legacy ASMX web services, not for WCF (which is what you're using when you use [ServiceContract]).
Although it may look like a URL, the XML namespace has nothing to do with the location on the web. You want to use a single namespace like http://www.company.com/webservices/applicationName/serviceName/. You can then access your service at whatever URL you like. There is no relation between XML Namespace and the URL of the service.