add web reference in visual studio for a restful web service - asp.net

I'm trying to add a web reference to a restful service, here is one sample URL:
http://dailymed.nlm.nih.gov/dailymed/services/v1/ndc/0409-3613-01/spls.xml
and I'm getting the following error (I'm guessing because I have no access to WSDL or DISCO they aren't listed on the API help page):
The document at the url http://dailymed.nlm.nih.gov/dailymed/services/v1/ndc/0409-3613-01/spls.xml was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be
I don't have access to this web service, it's run by the national library of medicine. Any thoughts on how I can add a reference within VS? Do I have to access this manually?

There is no standard metadata format to describe REST services. There's nothing similar to WSDL. Therefore, "Add Service Reference" or "Add Web Reference" won't work.
You'll have to look at the documentation of the service, or possibly at sample code, and build your own access layer.

Related

calling SOAP API + WSDL with static website in asp.net

The project I'm holding is asp.net website with static content [aspx files]
SOAP WSDL to the web services is provided and it's built with java and I have added a service to the project using "Add Service Reference".
I am looking for a way to consume that API with the website so as I could not understand how to call and integrate the data out of service and locate it into HTML[.aspx] page.
I have worked mostly with MVC projects but in this case I have not found any clue on how to do that.
After looking for many resources, Here is a conclusion how i solved my problem in case anyone needed that later in WebForms and C#.
1.Add Service Reference to your project using the WSDL link
provided
now you have classes and functions identified to your project.
Import the namespace to your class or your webform page using corresponding syntax and after that you can instantiate object out of classes and use functions
using namespace.webserviceName; with class
<%# Import Namespace="namespace.webserviceName" %> with webForm page.
One more issue popped up while I was trying to connect to the service with TLS/SSL protocols using asp.net 4.0.The Exception I received was: "The request was aborted: Could not create SSL/TLS secure channel"
-To solve this refer to this question answer

Consuming WSDL inside ASP.net MVC project

I have an WSDL at my disposal. it's address is : http://gy30.com/webservice/index/wsdl
when i import the WSDL through asp.net "add service references" i can see the "Operations(methods)".
After importing the WSDL i can't see any methods in the object browser. And there isn't any generated classes for this kind of WSDL.
I have read several posts on S/O and many articles about how to consume WSDL by googling, but i didn't find any solution.
http://johnwsaunders3.wordpress.com/2009/05/17/how-to-consume-a-web-service/
what are the problems ?
If i am not mistaken "Add Service Reference" is for wcf services. What you need is add Web Reference.
This service is legacy and you should use "Add Service Reference" -> "Advanced" > "Add Web Reference" and you will see old beautiful Add Web Reference dialog. And it will add reference but i couldn't consume this service. There was something wrong.

using a wsdl in ASP.net

I have downloaded a WSDL file from Internet and just want to know how to use the webservices out of the provided wsdl file using ASP.net version 2.0.
You can just add a web service reference. Back in Visual Studio 2005, this was in the context menu of the project and is called "Add Web Reference". In the dialog, just enter the location where you downloaded the WSDL file and a proxy will be generated for you.
When you use Add Service reference
The “Address” text box at the top can be used to type the URL to the Service Description, or “WSDL” file. Since the service is in the same solution as the project we’re trying to add it to, we can take advantage of the “Discover” dropdown at the right. Clicking the arrow shows “Services in this solution”:
Follow these links for detailed information:
How to Consume a Web Service
How to use WSDL file - asp.net forum thread
I think this is answered in this post: You can use WSDL.exe to generate a client, which you can access from code.

Consuming a WSE-enabled Web Service in an ASP.NET 2.0 web site

I'm trying to consume a WSE enabled Web Service from an ASP.NET Web Site.
I've installed WSE 3.0, used the config tool to add WSE info to my web.config and then done an Add Web Reference.
I believe that the problem may be that this is a Web SITE, not a Web APPLICATION. As such, the proxy class is generated at runtime, perhaps not adding the WSE magic.
I can access the proxy class from metadata, and it's of type System.Web.Services.Protocols.SoapHttpClientProtocol, which as far as I can tell doesn't have any WSE functionality.
I realize that this is all old technology, but I don't get to decide what the servers run :(
Any help would be greatly appreciated
You are wrong, proxy is generated when you are adding web reference.
Could you tell me how you are adding web reference to the website.
Please refer following article - http://msdn.microsoft.com/en-us/library/5sds7a0b.aspx
After you have located a Web service
for your application to access by
using the Add Web Reference dialog
box, clicking the Add Reference
button will instruct Visual Studio to
download the service description to
the local machine and then generate a
proxy class for the chosen Web
service. The proxy class will
contain methods for calling each
exposed Web service method both
synchronously and asynchronously. This
class is contained in the local .wsdl
file's code-behind file. For more
information, see Web References in
Visual Studio and Add Web Reference
Dialog Box.
Please refer following article - How to Add a Web Reference

Changing "web reference" to "service reference" changes method signature

I'm helping out a colleague on this one so if I'm missing some details that's why.
We have an asp.net 3.5 web application calling a WCF service. Originally the app used a "Web Reference" to register the service however after having some trouble and burning an incident with Microsoft their solution was to replace the "Web Reference" with a "Service Reference" to the WCF service.
This is great except the problem is that when we create a Service Reference, the method signatures are different than they were when a Web Reference was used.
From what I've read this may be expected, however in our case this would mean some significant changes to the application and of course it was due yesterday...so...
...I'm wondering two things:
Is it normal/expected that method signatures will change based on the reference type?
Is there a way to create the Service Reference that will generate method signatures identical to the original Web Reference?
You could create another layer between your current Web Reference calls and the new Service Reference proxy.
Create your service ref with a different name and/or namespace then what exists today.
Create a class with the name/namespace of the old Web Reference proxy.
Create the method signatures in the new class and wrap your calls to the Service Reference proxy.
Does this make sense. It's a very simple Adapter pattern.

Resources