WCF + Web API - How to integrate?

0

I'm developing a web api and need to integrate with a service from a third party that is a WCF. I have the WSDL definition, I integrated it into my solution as a service reference, but it 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 url of the service (which does not have WSDL enabled or public, because when I add the service reference, I have an error informing that the service metadata could not be downloaded), but I do not know how to integrate with WCF.

If it was an api web, I would use HttpClient to integrate, but WCF I have no idea how.

    
asked by anonymous 25.04.2017 / 20:09

1 answer

0

From what I understand, did you add wsdl to a correct local file? I've never done this, but when I need to change the url of ws, just set it:

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

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

Ex:

[wsIntegra] is the namespace of the webservice that you set when adding the reference. [SiIntegraWebService] is the webservice class defined on the server.

public wsIntegra.SiIntegraWebService objws = new wsIntegra.SiIntegraWebService();
    
25.04.2017 / 20:34