Consume web-service in ASP.NET MVC

2

I need to consume some methods on my page through a Web-Service. This Web-Service is in Europe.

What is the best way to do this? What are End-Points?

    
asked by anonymous 24.03.2014 / 17:29

2 answers

8

According to link , an endpoint is defined in translated text below:

  

An endpoint is a connection point from where the HTML or dynamic files are exposed. Endpoints provide information needed to access a Webservice . The endpoint provides a reference or specification that is used to define a group or family of message-addressing properties and provide end-to-end message characteristics such as references to the origin and destination of the endpoints, as well as the identity of messages to allow uniform addressing of "independent" messages. The endpoint can be a PC, PDA, or point-of-sale terminal.

In your case, the endpoint is the WebService address itself that you want to access.

To add a WebService to your application, do the following:

Step 1

Right click on the project > Add > Service Reference

Step2

Onthisscreen,clickAdvanced

Step 3

Click Add Web Reference ...

Step4

PastetheWebServiceaddressyouwanttoaccessintheURLfield.IfitisevenaWebServicewithavalidWSDL,themethodswillappearinthebottomsquare.JustclickAddReferencetoaddaclassthatrepresentsaccesstotheWebServicetoyourproject.

Consuming the WebService

To access the data from your WebService in Controller, use a statement something like this:

var wsMeuWebService = new wsMeuWebService.MeuWebService();
wsMeuWebService.MetodoDoWebService();
    
24.03.2014 / 17:48
0

Do the following, right-click the project and choose the Adicionar referência de serviço option.

Paste the WS URL, change the namespace, and click OK.

    
24.03.2014 / 17:41