WCF + Web API - How to integrate?

Asked

Viewed 162 times

0

I am developing a web api and need to integrate with a third party service that is a WCF. I have the definition of WSDL, integrated in my Solution as a service Ference, but is pointing to a physical file on my PC.

How do I integrate this code, which is pointing to a local WSDL, with the service hosted in another environment? I have the service url (which does not have the WSDL enabled or public, because when I add the service Ference, I have an error stating that I could not download the service media), but I do not know how to integrate with WCF.

If it were a web api, I would use Httpclient to integrate, but WCF I have no idea how to do.

  • "is pointing to a physical file on my PC" How so? You did not put the service URL?

  • If the service is WCF, normally the suffix should be added ?wsdl to display only the WSDL. However, this is all reported at the service address.

  • With the service url, it is not possible to add the reference. It shows this error: There was an error downloading 'https://***.svc/RS/_vti_bin/ListData.svc/$metadata'.
The request was aborted: Could not create SSL/TLS secure channel.
Metadata contains a reference that cannot be resolved: 'https://***.svc/RS'.
Could not establish secure channel for SSL/TLS with authority '***'.
The request was aborted: Could not create SSL/TLS secure channel.
If the service is defined in the current solution, try building the solution and adding the service reference again.

  • Directly accessing the service address (even with ?wsdl), this message appears: Metadata Publishing for this service is Currently disabled.

1 answer

0

from what I understand, you added wsdl for a correct local file ? I never did that, but when I need to change the Ws url, just set it there:

string url = "http://host.com.br/ws.asmx";
objws.Url = url;

where objws is an object of the reference type you added.

Ex: referência adicionada

[wsIntegra] is the web service namespace you defined when adding the reference. [Siintegrawebservice] is the webservice class defined on the server.

public wsIntegra.SiIntegraWebService objws = new wsIntegra.SiIntegraWebService();
  • Okay, but what is this object howitzers? For a Webapi service, I use Httpclient and I can communicate. For WCF, I have no idea how to do this.

  • edited the answer for better understanding, at the time you added wsdl, you gave a name to it, which is the namespace

  • I think I get it! I’m going to test it here. Thank you!

  • an observation, is that it is through this object (objws) that you will execute the methods available in Ws.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.